-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
22 lines (18 loc) · 917 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
const fs = require('node:fs'); // import filesearch
const path = require('node:path'); // import node.js native filepath
const { Client, Collection, GatewayIntentBits } = require('discord.js'); // import discord.js, import intents
const { token } = require('./config.json'); // import dogestep bot credentials
const client = new Client({ intents: [GatewayIntentBits.Guilds] }); // define new discord Bot client
// Event handling ("./events", examples: "ready" / "interactionCreate")
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.once) {
client.once(event.name, (...args) => event.execute(...args));
} else {
client.on(event.name, (...args) => event.execute(...args));
}
};
client.login(token);