ensl_gathers/lib/discord/bot.js

28 lines
600 B
JavaScript
Raw Normal View History

2017-06-22 13:47:29 +00:00
"use strict"
// Import the discord.js module
const Discord = require('discord.js');
2018-11-18 19:41:33 +00:00
const winston = require('winston');
2017-06-22 13:47:29 +00:00
function DiscordBot(config) {
this.hook = new Discord.WebhookClient(config.hook_id,config.hook_token);
this.spamProtection = {
fillStatus: null,
};
}
DiscordBot.prototype.notifyChannel = function(message) {
this.hook.send(message);
};
var bot;
module.exports = (config) => {
if (bot) return bot;
2018-11-18 19:41:33 +00:00
if (!config) throw new Error("No credentials provided for Discord Gather Bot");
bot = new DiscordBot(config);
2018-11-18 20:00:36 +00:00
bot.notifyChannel('Gather restarted');
2017-06-22 13:47:29 +00:00
return bot;
2018-11-18 19:41:33 +00:00
};