mirror of
https://github.com/LBRYFoundation/lbry-wunderbot.git
synced 2025-08-23 17:47:27 +00:00
made is to that they get triggered even inbetween the messages UNTESTED and not fully configured yet
31 lines
No EOL
651 B
JavaScript
31 lines
No EOL
651 B
JavaScript
'use strict';
|
|
let commands = require("../../config/commands");
|
|
const Discord = require("discord.js");
|
|
let initialized = false;
|
|
|
|
module.exports = {
|
|
init: init
|
|
};
|
|
|
|
function init(discordBot_) {
|
|
if (initialized) {
|
|
throw new Error("init was already called once");
|
|
}
|
|
|
|
discordBot = discordBot_;
|
|
|
|
discordBot.on("message", checkForCommand);
|
|
}
|
|
|
|
|
|
/**
|
|
*
|
|
* @param {String} message
|
|
*/
|
|
let checkForCommand = function (message) {
|
|
Object.keys(commands).forEach(command => {
|
|
if (message.indexOf(command) && commands[command].operation === 'send') {
|
|
msg.channel.send(commands[command].bundle);
|
|
}
|
|
});
|
|
} |