-
Notifications
You must be signed in to change notification settings - Fork 2
/
index.js
76 lines (57 loc) · 1.99 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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
const fs = require('fs');
const { Client, Collection, Intents } = require('discord.js');
const { token, topgg_token, debug } = require('./secret.json');
const { AutoPoster } = require('topgg-autoposter');
// Create a new client instance
const client = new Client({ intents: [Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MEMBERS] });
// Create top.gg autoposter
if (!debug) {
const auto_poster = AutoPoster(topgg_token, client);
}
/*
=== Read command files ===
*/
client.commands = new Collection();
const command_files = fs.readdirSync('./commands').filter(file => file.endsWith('.js'));
for (const file of command_files) {
// Loop over command fiels and add them to the bot
const command = require(`./commands/${file}`);
client.commands.set(command.data.name, command)
}
/*
=== Read event files ===
*/
const event_files = fs.readdirSync('./events').filter(file => file.endsWith('.js'));
for (const file of event_files) {
// Loop over event files and register them
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.on("error", () => { client.login(token) });
/*
=== Read button files ===
*/
client.buttons = new Collection();
const button_files = fs.readdirSync('./buttons').filter(file => file.endsWith('.js'));
for (const file of button_files) {
// Liioop over button files and register them
const button = require(`./buttons/${file}`);
client.buttons.set(button.name, button);
}
/*
=== Read select menu files ===
*/
client.select_menus = new Collection();
const select_menu_files = fs.readdirSync('./menus').filter(file => file.endsWith('.js'));
for (const file of select_menu_files) {
// Loop over button files and register them
const select_menu = require(`./menus/${file}`);
client.select_menus.set(select_menu.name, select_menu);
}
// Log in
client.login(token);