diff --git a/bot/modules/commandsV2.js b/bot/modules/commandsV2.js index 3c0243a..c1b4719 100644 --- a/bot/modules/commandsV2.js +++ b/bot/modules/commandsV2.js @@ -1,9 +1,11 @@ 'use strict'; let commands = require('../../config/commands'); +let commandsVerify = require('../../config/verify') const Discord = require('discord.js'); let initialized = false; let discordBot = null; let commandsList = null; +let commandsVerifyList = null; module.exports = { init: init @@ -30,6 +32,13 @@ let checkForCommand = function(message) { firstRun = true; commandsList = ''; } + let checkForCommand = function(message) { + //build the command list ONLY on first run + let firstRun = false; + if (commandsVerifyList === null) { + firstRun = true; + commandsVerifyList = ''; + } //for each message go through all the commands and check if there are any matches Object.keys(commands).forEach(command => { //if a command is found @@ -37,9 +46,17 @@ let checkForCommand = function(message) { //send a message to the channel according to the config message.channel.send('', new Discord.RichEmbed(commands[command].bundle)); } + }); + Object.keys(commandsVerify).forEach(command => { + //if a command is found + if (!message.author.bot && message.content.toLowerCase().indexOf(command.toLowerCase()) >= 0 && commands[command].operation === 'send') { + //send a message to the channel according to the config + message.channel.send('', new Discord.RichEmbed(commands[command].bundle)); + } }); if (firstRun) { commandsList = Object.keys(commands) + commandsVerifyList = Object.keys(commandsVerify) .sort() .join(', '); }