diff options
author | Luca Matei Pintilie <lucafulger@gmail.com> | 2022-08-31 18:10:41 +0000 |
---|---|---|
committer | Luca Matei Pintilie <lucafulger@gmail.com> | 2022-08-31 18:10:41 +0000 |
commit | 59456f6fa2303972c0ac7de1d1a33f16df89f544 (patch) | |
tree | 86498bd0d0d20f18e6d2e6a798657daf123b5735 /src/srcom | |
parent | bc94583564499d32586b6b1d4eb304f127d1100d (diff) | |
download | speedrunbot-slash-59456f6fa2303972c0ac7de1d1a33f16df89f544.tar speedrunbot-slash-59456f6fa2303972c0ac7de1d1a33f16df89f544.tar.gz speedrunbot-slash-59456f6fa2303972c0ac7de1d1a33f16df89f544.tar.bz2 speedrunbot-slash-59456f6fa2303972c0ac7de1d1a33f16df89f544.tar.lz speedrunbot-slash-59456f6fa2303972c0ac7de1d1a33f16df89f544.tar.xz speedrunbot-slash-59456f6fa2303972c0ac7de1d1a33f16df89f544.tar.zst speedrunbot-slash-59456f6fa2303972c0ac7de1d1a33f16df89f544.zip |
Try catch everything in handleCancelButton
Diffstat (limited to '')
-rw-r--r-- | src/srcom/slash_commands.tsx | 52 |
1 files changed, 28 insertions, 24 deletions
diff --git a/src/srcom/slash_commands.tsx b/src/srcom/slash_commands.tsx index 69d1878..15698d5 100644 --- a/src/srcom/slash_commands.tsx +++ b/src/srcom/slash_commands.tsx @@ -437,31 +437,35 @@ export class SpeedrunCom extends ApplicationCommandsModule { i: MessageComponentInteraction, ): Promise<void> { const task = runningTasks.get(i.customID)!; - if (!task) { - await i.send({ - content: "Sorry, but I couldn't find the running task to cancel.", - ephemeral: true, - }); - return; - } - if (task.user !== i.user.id) { - await i.send({ - content: "You are not allowed to cancel this.", - ephemeral: true, - }); - return; - } - task.signal.abort(); try { - await i.respond({ - content: "Canceled", - ephemeral: true, - }); - } catch { - await i.editResponse({ - content: "Canceled", - ephemeral: true, - }); + if (!task) { + await i.send({ + content: "Sorry, but I couldn't find the running task to cancel.", + ephemeral: true, + }); + return; + } + if (task.user !== i.user.id) { + await i.send({ + content: "You are not allowed to cancel this.", + ephemeral: true, + }); + return; + } + task.signal.abort(); + try { + await i.respond({ + content: "Canceled", + ephemeral: true, + }); + } catch { + await i.editResponse({ + content: "Canceled", + ephemeral: true, + }); + } + } catch (err) { + console.error(err); } runningTasks.delete(i.customID); } |