forked from batshalregmi/EmeraldBot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
bot.js
24 lines (21 loc) · 1016 Bytes
/
bot.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
const Discord = require("discord.js");
const bot = new Discord.Client({ disableEveryone: true, disabledEvents: ["TYPING_START", "TYPING_STOP", "GUILD_SYNC", "RELATIONSHIP_ADD", "RELATIONSHIP_REMOVE", "USER_SETTINGS_UPDATE", "USER_NOTE_UPDATE"], reconnect: true });
const { readdirSync } = require("fs");
bot.config = require("./config.json");
bot.login(bot.config.tokens.discord);
const startBot = async () => {
const eventFiles = readdirSync("./events/");
eventFiles.forEach(file => {
const event = require(`./events/${file}`);
bot.on(file.split(".")[0], (...args) => event(bot, ...args));
delete require.cache[require.resolve(`./events/${file}`)];
});
process.on("SIGINT", () => {
console.log(`[INFO] Shutting down with ${bot.players.size} players, ${bot.ttt.size} TicTacToe games, ${bot.guilds.size} servers and ${bot.users.size} users!`);
setTimeout(() => {
bot.destroy();
process.exit();
}, 250);
});
};
startBot();