Polarcraft/discordbot/events/interactionCreate.js

23 lines
564 B
JavaScript
Raw Normal View History

2023-08-02 14:16:30 +02:00
const { Events } = require('discord.js');
module.exports = {
2023-08-03 12:06:31 +02:00
name: Events.InteractionCreate,
async execute(interaction) {
if (!interaction.isChatInputCommand()) return;
2023-08-02 14:16:30 +02:00
2023-08-03 12:06:31 +02:00
const command = interaction.client.commands.get(interaction.commandName);
2023-08-02 14:16:30 +02:00
2023-08-03 12:06:31 +02:00
if (!command) {
console.error(`No command matching ${interaction.commandName} was found.`);
return;
}
2023-08-02 14:16:30 +02:00
2023-08-03 12:06:31 +02:00
try {
await command.execute(interaction);
} catch (error) {
console.error(`Error executing ${interaction.commandName}`);
console.error(error);
}
},
2023-08-02 14:16:30 +02:00
};