From d715ca02e6b8cdd2087b871ca72b8d385ab1e368 Mon Sep 17 00:00:00 2001 From: baz Date: Fri, 17 Nov 2023 23:47:34 +0000 Subject: [PATCH] Create Interaction Create event file --- events/interactionCreate.js | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 events/interactionCreate.js diff --git a/events/interactionCreate.js b/events/interactionCreate.js new file mode 100644 index 0000000..9fa876b --- /dev/null +++ b/events/interactionCreate.js @@ -0,0 +1,28 @@ +const { Events } = require('discord.js'); + +module.exports = { + name: Events.InteractionCreate, + async execute(interaction) { + if (!interaction.isChatInputCommand()) return; + + console.log(interaction); + + const command = interaction.client.commands.get(interaction.commandName); + + if (!command) { + console.error(`No command matching ${interaction.commandName} was found.`); + return; + } + + 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 the command!', ephemeral: true }); + } else { + await interaction.reply({ content: 'There was an error while executing this command!', ephemeral: true }); + } + } + }, +}; \ No newline at end of file