2024-03-19 17:41:20 -04:00
|
|
|
import DiscordEvent from "../../util/DiscordEvent";
|
|
|
|
import { DiscordInteractionCommands } from "../../index";
|
2024-03-22 00:18:45 -04:00
|
|
|
import { Client, Interaction } from "discord.js";
|
2024-03-19 17:41:20 -04:00
|
|
|
|
|
|
|
export default class InteractionCreate extends DiscordEvent {
|
|
|
|
constructor(client: Client) {
|
|
|
|
super("interactionCreate", client);
|
|
|
|
}
|
|
|
|
|
|
|
|
public async execute(interaction: Interaction): Promise<void> {
|
|
|
|
if (!interaction.isChatInputCommand()) return;
|
|
|
|
const command = DiscordInteractionCommands.get(interaction.commandName);
|
|
|
|
if (!command) return console.error(`No command matching ${interaction.commandName} was found.`);
|
|
|
|
try {
|
|
|
|
await command.execute(interaction);
|
|
|
|
} catch (error) {
|
|
|
|
console.error(error);
|
|
|
|
if (interaction.replied || interaction.deferred) {
|
|
|
|
await interaction.followUp({ content: 'There was an error while executing this command!', ephemeral: true });
|
|
|
|
} else {
|
|
|
|
await interaction.reply({ content: 'There was an error while executing this command!', ephemeral: true });
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|