This repository has been archived by the owner on Feb 9, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
bot.js
57 lines (47 loc) · 1.38 KB
/
bot.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
require('dotenv').config();
const Database = require('./config/Database.js');
const { readdirSync } = require('fs');
const { Client, Intents, Collection } = require('discord.js');
const db = new Database();
db.connect();
const client = new Client({
intents : [
Intents.FLAGS.GUILDS,
Intents.FLAGS.GUILD_MESSAGES,
Intents.FLAGS.GUILD_MEMBERS,
Intents.FLAGS.GUILD_MESSAGE_REACTIONS,
Intents.FLAGS.GUILD_VOICE_STATES
],
partials : [
'MESSAGE',
'CHANNEL',
'REACTION'
]
});
const commandFiles = [];
// Gets files inside the folders inside of the root "commands" folder
// Ignores the test folder
readdirSync('commands').forEach((dir) => {
'test' != dir &&
readdirSync(`commands/${dir}`).forEach((file) => {
file.endsWith('.js') && commandFiles.push(`./commands/${dir}/${file}`);
});
});
const commands = [];
client.commands = new Collection();
for (const file of commandFiles) {
const command = require(file);
commands.push(command.data.toJSON());
client.commands.set(command.data.name, command);
}
const eventFiles = 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, commands));
}
else {
client.on(event.name, (...args) => event.execute(...args, commands));
}
}
client.login(process.env.TOKEN);