lbry-wunderbot/bot/modules/supportbot.js
Niko Storni 1631d4aeab
big cleanup
how does this bot even work?
2018-11-27 20:01:58 -05:00

32 lines
704 B
JavaScript

'use strict';
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) {
//if the close command is found
if (!message.author.bot && message.content.toLowerCase().indexOf('!close') >= 0) {
//send the -close command twice with a 4 seconds timeout
message.channel.send('-close').catch(console.error);
setTimeout(() => {
message.channel.send('-close').catch(console.error);
}, 4000);
}
};