From ce2e244b70eb32f8d8c385a65b0ed40ae5a682a1 Mon Sep 17 00:00:00 2001 From: Guz <43732358+Guz013@users.noreply.github.com> Date: Thu, 26 Aug 2021 17:58:38 -0300 Subject: [PATCH] Little aditions Added optional propreties to commands. Commands with the proprety `folder: 'dev'` can't be reloaded via the reload command. Now the 'interactionCreate' event log the time of executing of the command. --- commands/dev/reload.js | 10 ++++++++-- events/interactions/interactionCreate.js | 6 ++++++ index.js | 4 ++++ 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/commands/dev/reload.js b/commands/dev/reload.js index 17bd12a..9b949d9 100644 --- a/commands/dev/reload.js +++ b/commands/dev/reload.js @@ -29,8 +29,12 @@ module.exports = { const command = commands.find(c => c.data.name === cmdName); - if(!command?.meta.canReload) { - interaction.reply({ content: `You can't reload the \`${command.data.name}\` command.`, ephemeral: true }); + if(command?.properties.folder == 'dev') { + interaction.reply({ content: `You can't reload \`${cmdName}\` because it is a development command.`, ephemeral: true }); + return; + } + else if(!command) { + interaction.reply({ content: `Command \`${cmdName}\` wasn't found.`, ephemeral: true }); return; } @@ -65,6 +69,8 @@ module.exports = { await clientCommand.permissions.set({ id: clientCommand.id, permissions: newCommand.permissions }); + interaction.reply({ content: `Command \`${cmdName}\` reloaded successfully.`, ephemeral: true }); + console.log( 'Old Command --------------------------------\n', oldCommand, '\nData:\n', oldCommandData, diff --git a/events/interactions/interactionCreate.js b/events/interactions/interactionCreate.js index 32a76b9..24bee4f 100644 --- a/events/interactions/interactionCreate.js +++ b/events/interactions/interactionCreate.js @@ -4,6 +4,9 @@ module.exports = { name: 'interactionCreate', async execute(interaction, client) { + console.log('NEW INTERACTION ################################'); + console.time('Interaction time'); + if(interaction.isCommand()) { console.log(`\nCommand ${interaction.commandName} executing ----------------\n`); @@ -31,5 +34,8 @@ module.exports = { } + console.timeEnd('Interaction time'); + console.log('################################################\n'); + }, }; \ No newline at end of file diff --git a/index.js b/index.js index 1d4cc1f..5a86e3f 100644 --- a/index.js +++ b/index.js @@ -23,6 +23,10 @@ for (const folder of commandFolders) { for (const file of commandFiles) { const command = require(`./commands/${folder}/${file}`); + + if(command.properties) command.proprieties.folder = folder; + else command.properties = { folder: folder }; + commands.push(command); commandsData.push(command.data.toJSON());