Skip to content

Commit 50d8f18

Browse files
committed
Ignore TimeoutCancellationExceptions
1 parent 0e1d483 commit 50d8f18

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

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

+3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package com.mrkirby153.botcore.command.slashcommand.dsl
22

33
import com.mrkirby153.botcore.utils.PrerequisiteCheck
4+
import kotlinx.coroutines.TimeoutCancellationException
45
import net.dv8tion.jda.api.interactions.commands.context.ContextInteraction
56
import java.util.concurrent.TimeUnit
67

@@ -57,6 +58,8 @@ open class ContextCommand<Event : ContextInteraction<*>>(
5758
}
5859
try {
5960
commandAction(event)
61+
} catch (e: TimeoutCancellationException) {
62+
// Ignore
6063
} catch (e: Exception) {
6164
val msg = ":no_entry: ${e.message ?: "An unknown error occurred!"}"
6265
if (event.isAcknowledged) {

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

+3
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import kotlinx.coroutines.CoroutineDispatcher
99
import kotlinx.coroutines.CoroutineScope
1010
import kotlinx.coroutines.Dispatchers
1111
import kotlinx.coroutines.SupervisorJob
12+
import kotlinx.coroutines.TimeoutCancellationException
1213
import kotlinx.coroutines.launch
1314
import kotlinx.coroutines.withTimeout
1415
import net.dv8tion.jda.api.JDA
@@ -228,6 +229,8 @@ class DslCommandExecutor private constructor(
228229
}
229230
}
230231
replyOrEdit(msg)
232+
} catch (e: TimeoutCancellationException) {
233+
log.debug("Execution timed out. Ignoring...")
231234
} catch (e: Exception) {
232235
log.error("Error executing slash command ${event.fullCommandName}", e)
233236
replyOrEdit(":no_entry: Something went wrong when processing this command")

0 commit comments

Comments
 (0)