const { Client, Interaction } = require('discord.js'); module.exports = { name: 'interactionCreate', // Event name once: true, // client.once() or client.on() /** * @param {Client} client * @param {Interaction} interaction * @param {String[]} args */ exec: async (client, interaction, args) => { if (interaction.isCommand()) { await interaction.deferReply({ ephemeral: false }).catch(() => {}); const cmd = client.slash.get(interaction.commandName); if (!cmd) return interaction.followUp({ content: "An error has occured - Unknown command" }); const args = []; for (let option of interaction.options.data) { if (option.type === "SUB_COMMAND") { if (option.name) args.push(option.name); option.options?.forEach((x) => { if (x.value) args.push(x.value); }); } else if (option.value) args.push(option.value); } interaction.member = interaction.guild.members.cache.get(interaction.user.id); cmd.exec(client, interaction, args); } // Context Menu Handling if (interaction.isContextMenu()) { await interaction.deferReply({ ephemeral: false }); const command = client.slash.get(interaction.commandName); if (command) command.exec(client, interaction); } } };