blob: 8ed01d2b935a448aae95c85061ad6728cb4a8724 [file] [log] [blame]
PineaFan9b2ac4d2023-01-18 14:41:07 +00001import type { ButtonInteraction, ContextMenuCommandInteraction } from 'discord.js';
2import type { CommandInteraction } from 'discord.js';
3import type { NucleusClient } from "../utils/client.js";
pineafan4edb7762022-06-26 19:21:04 +01004import EmojiEmbed from "../utils/generateEmojiEmbed.js";
pineafan34369e62022-05-18 16:52:37 +01005
pineafan63fc5e22022-08-04 22:04:10 +01006export const event = "commandError";
pineafan34369e62022-05-18 16:52:37 +01007
PineaFan9b2ac4d2023-01-18 14:41:07 +00008export async function callback(_: NucleusClient, interaction: CommandInteraction | ButtonInteraction | ContextMenuCommandInteraction, error: string) {
pineafan34369e62022-05-18 16:52:37 +01009 if (interaction.replied || interaction.deferred) {
Skyler Grey75ea9172022-08-06 10:22:23 +010010 await interaction.followUp({
11 embeds: [
12 new EmojiEmbed()
13 .setTitle("Something went wrong")
PineaFan9b2ac4d2023-01-18 14:41:07 +000014 .setDescription(error)
Skyler Grey75ea9172022-08-06 10:22:23 +010015 .setStatus("Danger")
16 .setEmoji("CONTROL.BLOCKCROSS")
17 ],
18 ephemeral: true
19 });
pineafan34369e62022-05-18 16:52:37 +010020 } else {
Skyler Grey75ea9172022-08-06 10:22:23 +010021 await interaction.reply({
22 embeds: [
23 new EmojiEmbed()
24 .setTitle("Something went wrong")
PineaFan9b2ac4d2023-01-18 14:41:07 +000025 .setDescription(error)
Skyler Grey75ea9172022-08-06 10:22:23 +010026 .setStatus("Danger")
27 .setEmoji("CONTROL.BLOCKCROSS")
28 ],
29 ephemeral: true
30 });
pineafan34369e62022-05-18 16:52:37 +010031 }
32}