-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
47 lines (34 loc) · 1.54 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
const { Client, GatewayIntentBits, Collection, Partials} = require('discord.js');
const server = require('./api/server.js')
const config = require('./config.json');
const client = new Client({ intents: [ GatewayIntentBits.Guilds, GatewayIntentBits.GuildMembers ], partials: [ Partials.GuildMember ] });
const fs = require('node:fs');
const path = require('node:path');
// --------------------------- Event Initialization -------------------------- \\
const eventsDir = path.join(__dirname, 'events');
const eventsFolder = fs.readdirSync(eventsDir).filter(file => file.endsWith('js'));
client.justUpdatedNickname = new Collection();
for (let file of eventsFolder) {
const eventPath = path.join(eventsDir, file);
const event = require(eventPath);
if (event.once) {
client.once(event.name, (...args) => event.execute(...args))
} else {
client.on(event.name, (...args) => event.execute(...args))
}
}
// --------------------------- Command Initialization -------------------------- \\
const commandsDir = path.join(__dirname, 'commands');
const commandFolder = fs.readdirSync(commandsDir).filter(file => file.endsWith('js'));
client.commands = new Collection();
for (let file of commandFolder) {
const commandPath = path.join(commandsDir, file);
const cmd = require(commandPath);
if ('data' in cmd && 'execute' in cmd) {
client.commands.set(cmd.data.name, cmd);
} else {
console.warn(`The command at ${commandPath} is incomplete!`);
}
}
server.start(client);
client.login(config.production_token);