aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuca Matei Pintilie <lucafulger@gmail.com>2022-08-16 16:29:33 +0000
committerLuca Matei Pintilie <lucafulger@gmail.com>2022-08-16 16:29:33 +0000
commit98b7f840be40dc696be0b1159e328e657e580977 (patch)
tree2886c136a1a92c0be2bc07da0c931be549876cca
parent2342aaabb37e2359f6cdb8bc1e5192c62bd272fa (diff)
downloadspeedrunbot-slash-98b7f840be40dc696be0b1159e328e657e580977.tar
speedrunbot-slash-98b7f840be40dc696be0b1159e328e657e580977.tar.gz
speedrunbot-slash-98b7f840be40dc696be0b1159e328e657e580977.tar.bz2
speedrunbot-slash-98b7f840be40dc696be0b1159e328e657e580977.tar.lz
speedrunbot-slash-98b7f840be40dc696be0b1159e328e657e580977.tar.xz
speedrunbot-slash-98b7f840be40dc696be0b1159e328e657e580977.tar.zst
speedrunbot-slash-98b7f840be40dc696be0b1159e328e657e580977.zip
Delete the correct interaction
-rw-r--r--src/srcom/slash_commands.tsx6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/srcom/slash_commands.tsx b/src/srcom/slash_commands.tsx
index 76b1280..7c6a710 100644
--- a/src/srcom/slash_commands.tsx
+++ b/src/srcom/slash_commands.tsx
@@ -339,6 +339,9 @@ async function sendCommand(
) {
const controller = new AbortController();
const cancelButtonId = crypto.randomUUID();
+
+ controller.signal.addEventListener("abort", () => i.deleteResponse());
+
runningTasks.set(cancelButtonId, { signal: controller, user: i.user.id });
const CancelButton = (
<>
@@ -391,7 +394,7 @@ async function sendCommand(
i.data.options.map((opt) => `${opt.name}:${opt.value}`)
}`;
if (err instanceof DOMException && err.name === "AbortError") {
- await i.deleteResponse();
+ // Command canceled so just don't do anything
} else if (err instanceof CommandError) {
console.debug(err);
await i.editResponse(`Error: ${err.message}`);
@@ -460,7 +463,6 @@ export class SpeedrunCom extends ApplicationCommandsModule {
ephemeral: true,
});
}
- await i.deleteResponse();
runningTasks.delete(i.customID);
}