Maybe adds the function to bot

This commit is contained in:
eatdostacos 2020-05-27 12:43:00 -07:00 committed by GitHub
parent e6c1ddf83e
commit 2e002a3972
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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(', ');
}