Skip to content

Commit

Permalink
Add utility for safely replying to interactions
Browse files Browse the repository at this point in the history
  • Loading branch information
eritislami committed Mar 7, 2024
1 parent 27d971c commit 5fc5da2
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions utils/safeReply.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { ButtonInteraction, CommandInteraction } from "discord.js";

export async function safeReply(interaction: CommandInteraction | ButtonInteraction, content: string) {
try {
if (interaction.deferred || interaction.replied) {
await interaction.followUp(content);
} else {
await interaction.reply(content);
}
} catch (error) {
console.error(error);
}
}

0 comments on commit 5fc5da2

Please sign in to comment.