blob: e7d9bf587fed5fd0e8b9cb51f0c71dc9ac8f2dc4 [file] [log] [blame]
Skyler Greyda16adf2023-03-05 10:22:12 +00001import type { ButtonInteraction, ContextMenuCommandInteraction } from "discord.js";
2import type { CommandInteraction } from "discord.js";
PineaFan9b2ac4d2023-01-18 14:41:07 +00003import 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
Skyler Greyda16adf2023-03-05 10:22:12 +00008export async function callback(
9 _: NucleusClient,
10 interaction: CommandInteraction | ButtonInteraction | ContextMenuCommandInteraction,
11 error: string
12) {
PineaFanc4d6c3f2023-01-19 12:17:25 +000013 const embed = new EmojiEmbed()
14 .setTitle("Something went wrong")
15 .setDescription(error)
16 .setStatus("Danger")
Skyler Greyda16adf2023-03-05 10:22:12 +000017 .setEmoji("CONTROL.BLOCKCROSS");
pineafan34369e62022-05-18 16:52:37 +010018 if (interaction.replied || interaction.deferred) {
Skyler Grey75ea9172022-08-06 10:22:23 +010019 await interaction.followUp({
PineaFanc4d6c3f2023-01-19 12:17:25 +000020 embeds: [embed],
Skyler Grey75ea9172022-08-06 10:22:23 +010021 ephemeral: true
22 });
pineafan34369e62022-05-18 16:52:37 +010023 } else {
Skyler Grey75ea9172022-08-06 10:22:23 +010024 await interaction.reply({
PineaFanc4d6c3f2023-01-19 12:17:25 +000025 embeds: [embed],
Skyler Grey75ea9172022-08-06 10:22:23 +010026 ephemeral: true
27 });
pineafan34369e62022-05-18 16:52:37 +010028 }
29}