-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathworker.js
25 lines (24 loc) · 835 Bytes
/
worker.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
25
const Discord = require('discord.js');
const mongoose = require('mongoose');
const Guild = require("./cmds/schems/guild.js");
const fs = require('fs');
const config = require('./cmds/config.json');
require('dotenv').config();
config.cfg.intents = new Discord.Intents(config.cfg.intents);
const bot = new Discord.Client(config.cfg);
require('./events')(bot, mongoose, Guild, config);
bot.login(process.env.TOKEN);
bot.commands = new Discord.Collection();
const commandFiles = fs.readdirSync('./cmds').filter(f => f.endsWith('.js'));
for (const file of commandFiles) {
const command = require(`./cmds/${file}`);
command.names.forEach(el => {
bot.commands.set(el, command)
});
};
process.on("SIGINT", () => {
console.log('Signed out!');
mongoose.disconnect();
bot.destroy();
});
console.log(bot.commands)