From 1f7c60f07dea75c4a21e813fce5e7bb1fe706f6f Mon Sep 17 00:00:00 2001 From: Luca Matei Pintilie Date: Tue, 16 Aug 2022 17:18:27 +0200 Subject: Don't cancel command if the wrong person pressed cancel --- src/srcom/slash_commands.tsx | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) (limited to 'src/srcom/slash_commands.tsx') diff --git a/src/srcom/slash_commands.tsx b/src/srcom/slash_commands.tsx index 3586a81..4aabda3 100644 --- a/src/srcom/slash_commands.tsx +++ b/src/srcom/slash_commands.tsx @@ -430,23 +430,17 @@ const runningTasks = new Map< >(); export class SpeedrunCom extends ApplicationCommandsModule { - static async handleCancelButton(i: MessageComponentInteraction) { + static async handleCancelButton(i: MessageComponentInteraction): Promise { const task = runningTasks.get(i.customID)!; if (!task) { - try { - await i.respond({ - content: "Sorry, but I couldn't find the running task to cancel.", - ephemeral: true, - }); - } catch { - await i.editResponse({ - content: "Sorry, but I couldn't find the running task to cancel.", - ephemeral: true, - }); - } + await i.respond({ + content: "Sorry, but I couldn't find the running task to cancel.", + ephemeral: true, + }); + return; } if (task.user !== i.user.id) { - i.send({ + await i.send({ content: "You are not allowed to cancel this.", ephemeral: true, }); -- cgit v1.2.3