PineaFan | 9b2ac4d | 2023-01-18 14:41:07 +0000 | [diff] [blame] | 1 | import type { ButtonInteraction, ContextMenuCommandInteraction } from 'discord.js'; |
| 2 | import type { CommandInteraction } from 'discord.js'; |
| 3 | import type { NucleusClient } from "../utils/client.js"; |
pineafan | 4edb776 | 2022-06-26 19:21:04 +0100 | [diff] [blame] | 4 | import EmojiEmbed from "../utils/generateEmojiEmbed.js"; |
pineafan | 34369e6 | 2022-05-18 16:52:37 +0100 | [diff] [blame] | 5 | |
pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame] | 6 | export const event = "commandError"; |
pineafan | 34369e6 | 2022-05-18 16:52:37 +0100 | [diff] [blame] | 7 | |
PineaFan | 9b2ac4d | 2023-01-18 14:41:07 +0000 | [diff] [blame] | 8 | export async function callback(_: NucleusClient, interaction: CommandInteraction | ButtonInteraction | ContextMenuCommandInteraction, error: string) { |
PineaFan | c4d6c3f | 2023-01-19 12:17:25 +0000 | [diff] [blame] | 9 | const embed = new EmojiEmbed() |
| 10 | .setTitle("Something went wrong") |
| 11 | .setDescription(error) |
| 12 | .setStatus("Danger") |
| 13 | .setEmoji("CONTROL.BLOCKCROSS") |
pineafan | 34369e6 | 2022-05-18 16:52:37 +0100 | [diff] [blame] | 14 | if (interaction.replied || interaction.deferred) { |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 15 | await interaction.followUp({ |
PineaFan | c4d6c3f | 2023-01-19 12:17:25 +0000 | [diff] [blame] | 16 | embeds: [embed], |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 17 | ephemeral: true |
| 18 | }); |
pineafan | 34369e6 | 2022-05-18 16:52:37 +0100 | [diff] [blame] | 19 | } else { |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 20 | await interaction.reply({ |
PineaFan | c4d6c3f | 2023-01-19 12:17:25 +0000 | [diff] [blame] | 21 | embeds: [embed], |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 22 | ephemeral: true |
| 23 | }); |
pineafan | 34369e6 | 2022-05-18 16:52:37 +0100 | [diff] [blame] | 24 | } |
| 25 | } |