-
Notifications
You must be signed in to change notification settings - Fork 0
/
replyWithSuccess.ts
31 lines (29 loc) · 984 Bytes
/
replyWithSuccess.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import { BaseCommandInteraction, EmojiResolvable } from 'discord.js';
import { successEmbed } from '../embeds';
/**
* Replies to an interaction with a success embed
* @param {BaseCommandInteraction} interaction The interaction to reply to
* @param {string} message The success message to display
* @param {boolean} ephemeral Whether to make reply ephemeral (default: false)
* @param {string} details Optional details to include in the message
* @param {EmojiResolvable} emoji Emoji to include in the title
*/
export const replyWithSuccess = async (
interaction: BaseCommandInteraction,
message: string,
ephemeral: boolean = false,
details?: string,
emoji?: EmojiResolvable,
): Promise<void> => {
const embed = successEmbed(message, details, emoji);
if (interaction.deferred || interaction.replied) {
await interaction.editReply({
embeds: [embed],
});
} else {
await interaction.reply({
embeds: [embed],
ephemeral,
});
}
};