This repository has been archived on 2025-10-10. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
Templated.djs/events/interactions/interactionCreate.js
Guz 4944eeba1d Added the command type system.
Created the command type `per-guild` these commands are registered when the bot enters a new guild, different of the global type, they can have permissions edited (the permissions system need to be developed yet).

`guild` commands will be registered just in the development guild (probably the purpose of them need to be rethought).

The reload command became adapted to be compatible with the command type system. When a command is reloaded, it's on all other guilds.
2021-09-01 13:59:02 -03:00

42 lines
1.1 KiB
JavaScript

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}`);
},
};