mirror of
https://github.com/LBRYFoundation/lbry-wunderbot.git
synced 2025-08-23 17:47:27 +00:00
Maybe adds the function to bot
This commit is contained in:
parent
e6c1ddf83e
commit
2e002a3972
1 changed files with 17 additions and 0 deletions
|
@ -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(', ');
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue