const DiscordClient = require('./DiscordClient'); const StaticEventEmitter = require('./StaticEventEmitter'); module.exports = class Bot extends StaticEventEmitter { static start(token) { this.prefix = "f/"; DiscordClient.start(token); this.bindEventListeners(); this.commands = new Map(); this.admin = []; this.loadCommands(); } static bindEventListeners() { this.on("chat.receive", msg => { console.log(msg.author.username + ": " + msg.content); let m = { referer: msg.author, }; }); this.on("chat.send", msg => { DiscordClient.sendChat(msg); }); } static runCommand(msg) { this.commands.forEach(cmd => { let usedCommand = false; cmd.cmd.forEach(c => { if (msg.cmd == c) { usedCommand = true; } }); if (!usedCommand) return; if (msg.rank == 'admin') { cmd.func(msg, true); } else { cmd.func(msg, false); } }); } static fixUsage(str) { return str.split("&PREFIX").join(this.prefix); } static getRank(id) { if (this.admin.indexOf(id) !== -1) { return "admin"; } else { return "none"; } } static loadCommands() { } }