const { commands } = require('../../index'); const console = require('../../functions/meta/console'); module.exports = { name: 'interactionCreate', async execute(interaction, client) { console.system(`New interaction fired: ${interaction.type} ${interaction.id}`); console.time('Interaction'); if(interaction.isCommand()) { console.system(`Command ${interaction.commandName} executing\n`); const command = commands.find(c => c.data.name === interaction.commandName); console.debug('Command data:'); console.log(command); console.debug('Command console:'); if(!command) return; try { await command.execute(interaction, client); } catch (error) { console.error(error); await interaction.reply({ content: `A error occur while trying to execute the command.\n\`\`\`diff\n- ${error}\`\`\``, ephemeral: true, }); } console.system(`Command ${interaction.commandName} executed`); } console.timeEnd('Interaction'); console.system(`Interaction finished: ${interaction.type} ${interaction.id}`); }, };