Skip to content

Commit

Permalink
even nicer warnUser code
Browse files Browse the repository at this point in the history
  • Loading branch information
3vorp committed Nov 19, 2023
1 parent 667046d commit c00831b
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions src/helpers/warnUser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,17 @@ export async function warnUser(
};

// make ephemeral if possible
if (interaction instanceof Message) {
const reply = await interaction.reply(args);
console.log("message reply");
reply.deleteButton();
} else {
args.ephemeral = true;
if (interaction instanceof Message)
return await interaction.reply(args).then((message: Message) => message.deleteButton());

// no need for delete button because we force ephemeral always
await (interaction as ChatInputCommandInteraction)
.reply(args)
.catch(async () => await (interaction as ChatInputCommandInteraction).ephemeralReply(args));
// no need for delete button because it's guaranteed ephemeral

args.ephemeral = true;
try {
await (interaction as ChatInputCommandInteraction).reply(args);
} catch {
// deferred
await (interaction as ChatInputCommandInteraction).ephemeralReply(args);
}
}

Expand Down

0 comments on commit c00831b

Please sign in to comment.