From 1851a29cd0ff67fa0f258ef0ae547d1f73741cda Mon Sep 17 00:00:00 2001 From: Supositware Date: Mon, 29 Aug 2022 20:37:38 +0200 Subject: [PATCH] Check if command has alias --- events/client/messageCreate.js | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/events/client/messageCreate.js b/events/client/messageCreate.js index 6705848a..ab6a7fa6 100644 --- a/events/client/messageCreate.js +++ b/events/client/messageCreate.js @@ -260,9 +260,22 @@ export default { if (!hasPrefix) return; const messageArray = message.content.match(/"[^"]*"|\S+/g).map(m => m.slice(0, 1) === '"' ? m.slice(1, -1) : m); - const commandName = messageArray[1].toLowerCase(); + let commandName = messageArray[1].toLowerCase(); let messageArgs = messageArray.splice(2, messageArray.length); + // Search for alias + client.commands.find(c => { + if (c.alias) { + if (c.alias.includes(commandName)) { + commandName = c.data.name; + } + } + }); + + const command = client.commands.get(commandName); + + if (!command) return; + const globalBlacklist = await db.Blacklists.findOne({ where: { type:'global', uid:message.author.id } }); const commandBlacklist = await db.Blacklists.findOne({ where: { type:commandName, uid:message.author.id } }); @@ -276,10 +289,6 @@ export default { const userTag = message.author.tag; const userID = message.author.id; - const command = client.commands.get(commandName); - - if (!command) return; - console.log(`\x1b[33m${userTag} (${userID})\x1b[0m launched command \x1b[33m${commandName}\x1b[0m`); // Owner only check