-
Notifications
You must be signed in to change notification settings - Fork 3
/
index.js
58 lines (46 loc) · 1.24 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
const fs = require('fs');
const path = require('path');
const Discord = require('discord.js');
const Intents = Discord.GatewayIntentBits;
const client = new Discord.Client({
intents: [
Intents.GuildMessages,
Intents.GuildMembers,
Intents.GuildEmojisAndStickers,
Intents.Guilds
]
});
client.version = 0;
const db = require('quick.db');
client.db = {
bot: new db.table('bot'),
guilds: new db.table('guilds'),
}
// Require the token from the .env file
require("dotenv").config();
// ========================================================
// BOT EXECUTION
// ========================================================
// Handle all the events
const eventsPath = path.join(__dirname, 'events');
const eventFiles = fs.readdirSync(eventsPath).filter(file => file.endsWith('.js'));
for (const file of eventFiles) {
const filePath = path.join(eventsPath, file);
const event = require(filePath);
if (!event) continue;
// If the event is only supposed to run once, then we'll add it to the client.once array.
if (event.once) {
client.once(
event.name,
(...args) => event.run(...args)
);
}
else {
client.on(
event.name,
(...args) => event.run(...args)
);
}
}
// Login into the client
client.login(process.env.DISCORD_TOKEN);