From 161b88d020687d9425083323ef5bb0bbecd3f2ef Mon Sep 17 00:00:00 2001 From: MatteZ02 <47610069+MatteZ02@users.noreply.github.com> Date: Wed, 13 May 2020 12:52:12 +0300 Subject: [PATCH] Mention commands --- src/events/clientEvents/msg.js | 38 ++++++++++++++++++---------------- 1 file changed, 20 insertions(+), 18 deletions(-) diff --git a/src/events/clientEvents/msg.js b/src/events/clientEvents/msg.js index 0029cd33..1b3e0aca 100644 --- a/src/events/clientEvents/msg.js +++ b/src/events/clientEvents/msg.js @@ -16,26 +16,28 @@ module.exports = { ); if (args[2] === "=" && args[3]) return (prefix = args[3]); } - if (args[1] === "help") { - const command = client.commands.get("help"); - return client.funcs.exe(msg, args, client, Discord, prefix, command); - } + args.shift(); + getCommand(client, args, msg, Discord); } } if (!msg.content.startsWith(prefix)) return; - if (!args[0]) return; - const commandName = args[0].toLowerCase(); - if (commandName === "none") return; - const command = - client.commands.get(commandName) || - client.commands.find( - (cmd) => cmd.aliases && cmd.aliases.includes(commandName) - ) || - client.commandAliases.get(commandName); - if (!command && msg.content !== `${prefix}`) return; - if (command.onlyDev && msg.author.id !== client.config.devId) return; - if (client.config.devMode && msg.member.id !== client.config.devId) - return msg.channel.send(client.messages.devMode); - client.funcs.exe(msg, args, client, Discord, command); + getCommand(client, args, msg, Discord); }, }; + +function getCommand(client, args, msg, Discord) { + if (!args[0]) return; + const commandName = args[0].toLowerCase(); + if (commandName === "none") return; + const command = + client.commands.get(commandName) || + client.commands.find( + (cmd) => cmd.aliases && cmd.aliases.includes(commandName) + ) || + client.commandAliases.get(commandName); + if (!command) return; + if (command.onlyDev && msg.author.id !== client.config.devId) return; + if (client.config.devMode && msg.member.id !== client.config.devId) + return msg.channel.send(client.messages.devMode); + client.funcs.exe(msg, args, client, Discord, command); +}