mirror of
https://github.com/LBRYFoundation/lbry-wunderbot.git
synced 2025-08-23 17:47:27 +00:00
37 lines
842 B
JavaScript
37 lines
842 B
JavaScript
"use strict";
|
|
let commands = require("../../config/commands");
|
|
const Discord = require("discord.js");
|
|
let initialized = false;
|
|
let discordBot = null;
|
|
|
|
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.author.bot &&
|
|
message.content.toLowerCase().indexOf(command.toLowerCase()) >= 0 &&
|
|
commands[command].operation === "send"
|
|
) {
|
|
console.log("sending message");
|
|
console.log(commands[command].bundle);
|
|
message.channel.send("", new Discord.RichEmbed(commands[command].bundle));
|
|
}
|
|
});
|
|
};
|