-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
32 lines (28 loc) · 841 Bytes
/
app.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
28
29
30
31
32
const { Intents, Client } = require('discord.js');
const fs = require('fs');
const { SECRETS } = require('./config');
// initialize discord client
const client = new Client({
partials: ['MESSAGE', 'REACTION', 'CHANNEL'],
intents: [
Intents.FLAGS.GUILDS,
Intents.FLAGS.GUILD_MESSAGES,
Intents.FLAGS.GUILD_MEMBERS,
Intents.FLAGS.GUILD_MESSAGE_REACTIONS,
Intents.FLAGS.DIRECT_MESSAGES,
Intents.FLAGS.GUILD_INVITES,
],
});
// creating events reader
const eventFiles = fs
.readdirSync('./events')
.filter(file => file.endsWith('.js'));
eventFiles.forEach(file => {
const event = require(`./events/${file}`);
if (event.once) {
client.once(event.name, (...args) => event.execute(...args));
} else {
client.on(event.name, (...args) => event.execute(...args));
}
});
client.login(SECRETS.TOKEN);