From 1ba008a5edec98e4cc6cf4a5064a3f87bc6fce81 Mon Sep 17 00:00:00 2001 From: MilleniumModsSources <76138687+MilleniumModsSources@users.noreply.github.com> Date: Sun, 13 Mar 2022 22:09:06 -0300 Subject: [PATCH 1/2] Improve notification message on commands Improved the notification message when running Administrator commands by adding an extra option to customize the event code --- src/handlers/Command.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/handlers/Command.js b/src/handlers/Command.js index 7b5779b..93e5275 100644 --- a/src/handlers/Command.js +++ b/src/handlers/Command.js @@ -114,9 +114,16 @@ class CommandHandler { if (_this.options.logs) console.log(`[OPCommands] Command '${interaction.commandName}' executed by: '${interaction.user.tag}'`); _this.client.commands.get(interaction.commandName).run(_this.client, interaction); if (_this.options.notifyOwner && (commandFile.limits.permissions == ('ADMINISTRATOR').toLowerCase())) { + if(!_this.client.msgs.notifyCommandMessage) { + // If there isn't any message, it uses the default one _this.client.users.fetch(_this.client.owners[0]).then(user => { user.send("[Logs] Administrator command `" + interaction.commandName + "` was executed by " + `<@${interaction.user.id}> in **${interaction.guild.name}**`); }); + } else { + _this.client.users.fetch(_this.client.owners[0]).then(user => { + _this.client.msgs.notifyCommandMessage(user, interaction); + }) + } } } catch (e) { if (_this.options.logs) console.log("[OPCommands] Command error: " + interaction.commandName); From bc078f6cb6bac826da9029b37ddb4cbc3731d1ec Mon Sep 17 00:00:00 2001 From: MilleniumModsSources <76138687+MilleniumModsSources@users.noreply.github.com> Date: Sun, 13 Mar 2022 22:16:49 -0300 Subject: [PATCH 2/2] Add notifyCommandMessage MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add the message for notifications when an Administrator command is executed. How it works: If a command that requires Administrator permissions is executed, and the notifyOwner option is enabled, the notifyCommandMessage will be executed. However, if the notifyCommandMessage option is missing, the bot will simply send the default message which is set in /src/Command.js (Already tested properly, so hopefully this will work right away unlike the last PullRequest 😅) --- test/index.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/index.js b/test/index.js index daf18d0..69b548e 100644 --- a/test/index.js +++ b/test/index.js @@ -17,7 +17,8 @@ handler.setMessages({ ownerOnly: (interaction) => interaction.reply("Missing **Bot Owner** permission."), permissions: (interaction, perms) => interaction.reply(`You are missing the following permissions: **${perms.join(", ")}**`), cooldown: (interaction, cooldown) => interaction.reply(`You must wait **${cooldown}** before executing another command.`), - notifyOwnerMessage: (owner) => owner.send("I'm online!"); + notifyOwnerMessage: (owner) => owner.send("I'm online!"), + notifyCommandMessage: (owner, interaction) => owner.send("[OPCommands] Administrator command `" + interaction.commandName + "` was executed by " + `<@${interaction.user.id}> in **${interaction.guild.name}**`) }); client.login("BOT_TOKEN");