mirror of
https://github.com/LBRYFoundation/lbry-wunderbot.git
synced 2025-08-23 09:37:27 +00:00
32 lines
704 B
JavaScript
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);
|
|
}
|
|
};
|