-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
33 lines (28 loc) · 951 Bytes
/
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
import fs from 'node:fs';
import path from 'node:path';
import { Client, Events, GatewayIntentBits } from 'discord.js';
const client = new Client({
intents: [
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildMessages,
GatewayIntentBits.MessageContent,
],
});
client.once(Events.ClientReady, (readyClient) => {
console.log(`Ready! Logged in as ${readyClient.user.tag}`);
console.log(client.user);
});
const eventsPath = path.join(import.meta.dirname, 'events');
const eventFiles = fs
.readdirSync(eventsPath)
.filter((file) => file.endsWith('.js'));
eventFiles.forEach(async (file) => {
const filePath = path.join(eventsPath, file);
const event = (await import(`file://${filePath}`)).default;
if (event.once) {
client.once(event.name, (...args) => event.execute(client, ...args));
} else {
client.on(event.name, (...args) => event.execute(client, ...args));
}
});
client.login(process.env.DISCORD_TOKEN);