| 18 | name: Events.InteractionCreate, |
| 19 | once: false, |
| 20 | async execute(interaction, client) { |
| 21 | if ( |
| 22 | !interaction.isChatInputCommand() && |
| 23 | !interaction.isContextMenuCommand() |
| 24 | ) |
| 25 | return; |
| 26 | var commands = await client.commands.toJSON(); |
| 27 | const command = interaction.client.commands.get(interaction.commandName); |
| 28 | |
| 29 | if (!command) { |
| 30 | console.error( |
| 31 | `No command matching ${interaction.commandName} was found.` |
| 32 | ); |
| 33 | return; |
| 34 | } |
| 35 | var guildId; |
| 36 | if (interaction.guild) guildId = interaction.guild.id; |
| 37 | |
| 38 | try { |
| 39 | await command.execute(interaction, client, commands, interactionType); |
| 40 | } catch (error) { |
| 41 | console.log(error); |
| 42 | await interactionType.reply(interaction, { |
| 43 | content: "There was an error while executing this command!", |
| 44 | ephemeral: true, |
| 45 | }); |
| 46 | } |
| 47 | }, |
| 48 | }; |