ensl_gathers/lib/discord/bot.js
2018-11-18 21:00:36 +01:00

27 lines
600 B
JavaScript

"use strict"
// Import the discord.js module
const Discord = require('discord.js');
const winston = require('winston');
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;
if (!config) throw new Error("No credentials provided for Discord Gather Bot");
bot = new DiscordBot(config);
bot.notifyChannel('Gather restarted');
return bot;
};