-
Notifications
You must be signed in to change notification settings - Fork 20
/
Copy pathindex.js
34 lines (30 loc) · 1.07 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
import { config } from 'dotenv';
import { readdir } from 'fs';
import { Client, GatewayIntentBits, Collection } from 'discord.js';
config();
const client = new Client({ intents: [GatewayIntentBits.Guilds] });
let commands = [];
client.commands = new Collection();
readdir('./commands', (err, folders) => {
folders.forEach(async (folder) => {
readdir(`./commands/${folder}`, (err, files) => {
files.forEach(async (file) => {
const command = await import(`./commands/${folder}/${file}`);
client.commands.set(command.default.data.name, command.default);
if (command.default.data.name !== 'help') commands.push(command.default.data.toJSON());
})
})
})
});
readdir('./events', (err, folders) => {
folders.forEach((folder) => {
readdir(`./events/${folder}`, (err, files) => {
files.forEach(async (file) => {
const event = await import(`./events/${folder}/${file}`);
client.on(event.default.name, (...args) => event.default.execute(...args));
})
})
})
});
client.login(process.env.token);
export default commands