This repository was archived by the owner on Sep 16, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
45 lines (36 loc) · 1.21 KB
/
index.js
File metadata and controls
45 lines (36 loc) · 1.21 KB
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
const { Client, Collection, GatewayIntentBits } = require('discord.js');
const { readdirSync } = require('node:fs');
const { join }= require('node:path');
require('dotenv').config();
const client = new Client({
intents: [
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildMembers,
GatewayIntentBits.GuildMessages,
GatewayIntentBits.GuildPresences,
GatewayIntentBits.GuildVoiceStates,
GatewayIntentBits.GuildMessageReactions
]
});
client.commands = new Collection();
const cmd_dir = join(__dirname, 'src', 'commands');
const cmd_files = readdirSync(cmd_dir)
.filter(file => file.endsWith('.js'));
for (const file of cmd_files) {
const cmd_file = join(cmd_dir, file);
const cmd = require(cmd_file);
client.commands.set(cmd.data.name, cmd);
}
const event_path = join(__dirname, 'src', 'events');
const event_files = readdirSync(event_path)
.filter(file => file.endsWith('.js'));
for (const file of event_files) {
const event_file = join(event_path, file);
const event = require(event_file);
if (event.once) {
client.once(event.name, (...args) => event.execute(...args, client));
} else {
client.on(event.name, (...args) => event.execute(...args, client));
}
}
client.login(process.env.DISCORD_TOKEN);