diff --git a/CustomModules/NodBot.js b/CustomModules/NodBot.js index 24efec3..ac29c41 100644 --- a/CustomModules/NodBot.js +++ b/CustomModules/NodBot.js @@ -3,18 +3,32 @@ module.exports = { constructor(message) { // Get the location of the final period in the message this.finalPeriod = message.content.lastIndexOf('.'); - this.isCommand = finalPeriod >= 0 ? true : false; // Check if there is a period somewhere in the message to flag as a possible command - this.args = message.content.slice(0,finalPeriod).toLowerCase(); // Grab everything leading up to the final period - this.command = message.content.slice(finalPeriod + 1).toLowerCase(); // Grab everything after the final period + this.isCommand = this.finalPeriod >= 0 ? true : false; // Check if there is a period somewhere in the message to flag as a possible command + this.isValid = false; + this.args = message.content.slice(0,this.finalPeriod).toLowerCase(); // Grab everything leading up to the final period + this.command = message.content.slice(this.finalPeriod + 1).toLowerCase(); // Grab everything after the final period this.author = message.author.username; return this; } - isValid(validCommands) { + validate(dotCommands) { if (this.args.startsWith('http')) return false; if (this.args.startsWith('www')) return false; - return validCommands.includes(this.command); + + for (const [key, value] of dotCommands) { + if (key === this.command) { + this.isValid = true; + return this.isValid; + } else if (value.alias && value.alias.includes(this.command)) { + this.command = key; + this.isValid = true; + return this.isValid; + } + } + + this.isValid = validCommands.includes(this.command); + return this.isValid; } }, GifData: class { diff --git a/functions.js b/functions.js index 7a27238..eeaeb3f 100644 --- a/functions.js +++ b/functions.js @@ -82,13 +82,13 @@ const functions = { for (const file of dotCommandFiles) { const dotCommand = require(`./dot-commands/${file}`); client.dotCommands.set(dotCommand.name, dotCommand); - if (Array.isArray(dotCommand.alias)) { - dotCommand.alias.forEach(element => { - client.dotCommands.set(element, dotCommand); - }); - } else if (dotCommand.alias != undefined) { - client.dotCommands.set(dotCommand.alias, dotCommand); - } + // if (Array.isArray(dotCommand.alias)) { + // dotCommand.alias.forEach(element => { + // client.dotCommands.set(element, dotCommand); + // }); + // } else if (dotCommand.alias != undefined) { + // client.dotCommands.set(dotCommand.alias, dotCommand); + // } } if (isDev) console.log('Dot Commands Collection Built'); }, @@ -174,7 +174,9 @@ const functions = { dot: { getCommandData(message) { const commandData = new CommandData(message); - return commandData.isValid(require('./config.json').validCommands); + const { validCommands } = require('./config.json'); + commandData.validate(message.client.dotCommands); + return commandData; } }, embeds: {