From 667046ddbdfd777eb8bef28f4529ef441c31726d Mon Sep 17 00:00:00 2001 From: Evorp <3vorpgaming@gmail.com> Date: Sun, 19 Nov 2023 12:42:19 -0800 Subject: [PATCH] much nicer warnUser code --- src/helpers/warnUser.ts | 25 +++++++++---------------- 1 file changed, 9 insertions(+), 16 deletions(-) diff --git a/src/helpers/warnUser.ts b/src/helpers/warnUser.ts index e8ee42a7..0b76d14d 100644 --- a/src/helpers/warnUser.ts +++ b/src/helpers/warnUser.ts @@ -22,25 +22,18 @@ export async function warnUser( }; // make ephemeral if possible - if (!(interaction instanceof Message)) { + if (interaction instanceof Message) { + const reply = await interaction.reply(args); + console.log("message reply"); + reply.deleteButton(); + } else { args.ephemeral = true; - args.fetchReply = true; - } - let reply: Message; - try { - reply = await (interaction as ChatInputCommandInteraction).reply(args); - } catch { - try { - // check if deferred - reply = await (interaction as ChatInputCommandInteraction).editReply(args); - } catch { - // follow up if original message not found - reply = await (interaction as ChatInputCommandInteraction).followUp(args); - } + // no need for delete button because we force ephemeral always + await (interaction as ChatInputCommandInteraction) + .reply(args) + .catch(async () => await (interaction as ChatInputCommandInteraction).ephemeralReply(args)); } - - if (interaction instanceof Message) reply.deleteButton(); } /**