File tree Expand file tree Collapse file tree 1 file changed +5
-2
lines changed
src/main/kotlin/io/github/freya022/botcommands/internal/core Expand file tree Collapse file tree 1 file changed +5
-2
lines changed Original file line number Diff line number Diff line change @@ -21,6 +21,7 @@ import io.github.freya022.botcommands.api.core.utils.loggerOf
2121import io.github.freya022.botcommands.internal.commands.application.ApplicationCommandsContextImpl
2222import io.github.freya022.botcommands.internal.commands.text.TextCommandsContextImpl
2323import io.github.freya022.botcommands.internal.core.service.SpringServiceContainer
24+ import io.github.freya022.botcommands.internal.utils.takeIfFinite
2425import io.github.freya022.botcommands.internal.utils.unwrap
2526import io.github.oshai.kotlinlogging.KotlinLogging
2627import kotlinx.coroutines.CoroutineScope
@@ -247,6 +248,8 @@ internal class BContextImpl internal constructor(
247248 }
248249
249250 private fun awaitJDAShutdown (durationUntilDeadlineFn : () -> Duration ): Boolean {
251+ fun Duration.finiteOrZero () = takeIfFinite() ? : Duration .ZERO
252+
250253 val jda = jdaOrNull
251254 if (jda == null ) {
252255 logger.debug { " Not awaiting JDA shutdown as there is no JDA instance registered" }
@@ -255,12 +258,12 @@ internal class BContextImpl internal constructor(
255258 val shardManager = jda.shardManager
256259 if (shardManager != null ) {
257260 shardManager.shards.forEach { shard ->
258- if (! shard.awaitShutdown(durationUntilDeadlineFn())) {
261+ if (! shard.awaitShutdown(durationUntilDeadlineFn().finiteOrZero() )) {
259262 return false
260263 }
261264 }
262265 } else {
263- if (! jda.awaitShutdown(durationUntilDeadlineFn())) {
266+ if (! jda.awaitShutdown(durationUntilDeadlineFn().finiteOrZero() )) {
264267 return false
265268 }
266269 }
You can’t perform that action at this time.
0 commit comments