Skip to content

Commit 217955e

Browse files
committed
Allow disabling timeout for command executions
1 parent d3ae526 commit 217955e

File tree

1 file changed

+15
-7
lines changed

1 file changed

+15
-7
lines changed

src/main/kotlin/com/mrkirby153/botcore/command/slashcommand/dsl/DslCommandExecutor.kt

+15-7
Original file line numberDiff line numberDiff line change
@@ -296,10 +296,12 @@ class DslCommandExecutor private constructor(
296296
if (slashCommand != null) {
297297
scope.launch {
298298
log.trace("Running command ${slashCommand.name} with a timeout of ${slashCommand.timeout}")
299-
withTimeout(slashCommand.timeout) {
299+
if (slashCommand.timeout != 0L)
300+
withTimeout(slashCommand.timeout) {
301+
execute(event, this)
302+
}
303+
else
300304
execute(event, this)
301-
}
302-
303305
}
304306
}
305307
}
@@ -320,9 +322,12 @@ class DslCommandExecutor private constructor(
320322
scope.launch {
321323
userContextCommands.firstOrNull { it.name == event.name }
322324
?.apply {
323-
withTimeout(timeout) {
325+
if (timeout != 0L)
326+
withTimeout(timeout) {
327+
execute(UserContext(event, scope))
328+
}
329+
else
324330
execute(UserContext(event, scope))
325-
}
326331
}
327332
}
328333
}
@@ -331,9 +336,12 @@ class DslCommandExecutor private constructor(
331336
scope.launch {
332337
messageContextCommands.firstOrNull { it.name == event.name }
333338
?.apply {
334-
withTimeout(timeout) {
339+
if (timeout != 0L)
340+
withTimeout(timeout) {
341+
execute(MessageContext(event, scope))
342+
}
343+
else
335344
execute(MessageContext(event, scope))
336-
}
337345
}
338346
}
339347
}

0 commit comments

Comments
 (0)