diff --git a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/SendActionDSL.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/SendActionDSL.kt index 03550f4398..793a221fc0 100644 --- a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/SendActionDSL.kt +++ b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/SendActionDSL.kt @@ -24,17 +24,17 @@ public suspend fun TelegramBot.withAction( contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } - val actionScope = currentCoroutineContext().LinkedSupervisorScope(Job()) + val actionScope = currentCoroutineContext().LinkedSupervisorScope() actionScope.launch { while (isActive) { - safelyWithoutExceptions { + runCatching { execute(actionRequest) } delay(refreshTime) } } val result = runCatchingSafely { block() } - actionScope.cancel() + actionScope.coroutineContext.job.cancel() return result.getOrThrow() }