-
Notifications
You must be signed in to change notification settings - Fork 2
/
index.js
51 lines (41 loc) · 1.63 KB
/
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
const fs = require('fs');
const { Client, Collection, Intents } = require('discord.js');
require('dotenv').config();
const client = new Client({
intents: [
Intents.FLAGS.GUILDS,
Intents.FLAGS.GUILD_MESSAGES,
Intents.FLAGS.GUILD_MESSAGE_REACTIONS,
Intents.FLAGS.GUILD_MEMBERS,
],
});
client.handlers = new Collection();
client.handlers.commands = new Collection();
const commandFiles = fs.readdirSync('./src/handlers/commands').filter(file => file.endsWith('.js'));
for (const file of commandFiles) {
const command = require(`./src/handlers/commands/${file}`);
client.handlers.commands.set(command.data.name, command);
}
client.handlers.selectMenu = new Collection();
const selectMenuHandlers = fs.readdirSync('./src/handlers/selectMenu').filter(file => file.endsWith('.js'));
for (const file of selectMenuHandlers) {
const selectMenuHandler = require(`./src/handlers/selectMenu/${file}`);
client.handlers.selectMenu.set(selectMenuHandler.name, selectMenuHandler);
}
client.handlers.button = new Collection();
const buttonHandlers = fs.readdirSync('./src/handlers/button').filter(file => file.endsWith('.js'));
for (const file of buttonHandlers) {
const buttonHandler = require(`./src/handlers/button/${file}`);
client.handlers.button.set(buttonHandler.name, buttonHandler);
}
const eventFiles = fs.readdirSync('./src/events').filter(file => file.endsWith('.js'));
for (const file of eventFiles) {
const event = require(`./src/events/${file}`);
if (event.once) {
client.once(event.name, (...args) => event.execute(...args));
}
else {
client.on(event.name, (...args) => event.execute(...args, client));
}
}
client.login(process.env.TOKEN);