interactionCreate.js 533 B

123456789101112131415161718192021222324
  1. const { Events } = require('discord.js');
  2. module.exports = {
  3. name: Events.InteractionCreate,
  4. async execute(interaction) {
  5. if (!interaction.isChatInputCommand()) return;
  6. const command = interaction.client.commands.get(interaction.commandName);
  7. if (!command) {
  8. console.error(`No command matching ${interaction.commandName} was found.`);
  9. return;
  10. }
  11. try {
  12. await command.execute(interaction);
  13. } catch (error) {
  14. console.error(`Error executing ${interaction.commandName}`);
  15. console.error(error);
  16. }
  17. },
  18. };