-
Notifications
You must be signed in to change notification settings - Fork 2
/
index.js
27 lines (21 loc) · 846 Bytes
/
index.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
26
27
const { Client, Collection, Intents } = require('discord.js');
const { config } = require('dotenv');
const fs = require('fs');
const client = new Client({ intents: [Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MESSAGES], partials: ['MESSAGE'] });
client.mongo = require('./utils/mongoose');
client.commands = new Collection();
client.aliases = new Collection();
client.categories = fs.readdirSync('./commands/');
config();
fs.readdir('./events/', (err, files) => {
if (err) return console.error;
files.forEach((file) => {
// eslint-disable-next-line global-require, import/no-dynamic-require
const evt = require(`./events/${file}`);
const evtName = file.split('.')[0];
console.log(`Loaded event '${evtName}'`);
client.on(evtName, evt.bind(null, client));
});
});
client.mongo.init();
client.login(process.env.TOKEN);