This repository has been archived by the owner on May 3, 2023. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
60 lines (49 loc) · 1.78 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
52
53
54
55
56
57
58
59
60
const fs = require('fs');
const {token} = require('./config.json');
const {Intents, Client, Collection} = require("discord.js");
const {loadCommandsFromDisk} = require("./handlers/customcommands");
const client = new Client({intents: [Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MEMBERS]});
client.commands = new Collection();
client.autoComplete = new Collection();
client.selectionMenus = new Collection();
loadCommandsFromDisk()
const eventFiles = fs.readdirSync('./events').filter(file => file.endsWith('.js'));
for (const file of eventFiles) {
const event = require(`./events/${file}`);
if (event.once) {
client.once(event.name, (...args) => event.execute(...args, client));
} else {
client.on(event.name, (...args) => event.execute(...args, client));
}
}
const commandFiles = fs.readdirSync('./commands').filter(file => file.endsWith('.js'));
for (const file of commandFiles) {
const command = require(`./commands/${file}`);
if (command.id) {
client.commands.set(command.id, command);
if (command.autoComplete) {
client.autoComplete.set(command.id, command)
}
}else if (command.ids) {
for (let id of command.ids) {
client.commands.set(id, command);
if (command.autoComplete) {
client.autoComplete.set(id, command)
}
}
}
}
for (const file of fs.readdirSync('./menus').filter(file => file.endsWith('.js'))) {
const menu = require(`./menus/${file}`);
if (menu.id) {
client.selectionMenus.set(menu.id, menu);
}else if (menu.ids) {
for (let id of menu.ids) {
client.selectionMenus.set(id, menu);
}
}
}
client.login(token);
process.on('uncaughtException', function (err) {
console.error(err.stack)
});