mirror of
https://github.com/LBRYFoundation/lbry-wunderbot.git
synced 2025-08-31 17:31:32 +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';
|
'use strict';
|
||||||
let commands = require('../../config/commands');
|
let commands = require('../../config/commands');
|
||||||
|
let commandsVerify = require('../../config/verify')
|
||||||
const Discord = require('discord.js');
|
const Discord = require('discord.js');
|
||||||
let initialized = false;
|
let initialized = false;
|
||||||
let discordBot = null;
|
let discordBot = null;
|
||||||
let commandsList = null;
|
let commandsList = null;
|
||||||
|
let commandsVerifyList = null;
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
init: init
|
init: init
|
||||||
|
@ -30,6 +32,13 @@ let checkForCommand = function(message) {
|
||||||
firstRun = true;
|
firstRun = true;
|
||||||
commandsList = '';
|
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
|
//for each message go through all the commands and check if there are any matches
|
||||||
Object.keys(commands).forEach(command => {
|
Object.keys(commands).forEach(command => {
|
||||||
//if a command is found
|
//if a command is found
|
||||||
|
@ -37,9 +46,17 @@ let checkForCommand = function(message) {
|
||||||
//send a message to the channel according to the config
|
//send a message to the channel according to the config
|
||||||
message.channel.send('', new Discord.RichEmbed(commands[command].bundle));
|
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) {
|
if (firstRun) {
|
||||||
commandsList = Object.keys(commands)
|
commandsList = Object.keys(commands)
|
||||||
|
commandsVerifyList = Object.keys(commandsVerify)
|
||||||
.sort()
|
.sort()
|
||||||
.join(', ');
|
.join(', ');
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue