-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBot.js
28 lines (21 loc) · 790 Bytes
/
Bot.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
const { Client, GatewayIntentBits, Collection } = require('discord.js');
const path = require('path');
const fs = require('node:fs');
require('dotenv').config();
const TOKEN = process.env.TOKEN;
const bot = new Client({
intents: [GatewayIntentBits.Guilds, GatewayIntentBits.GuildMembers, GatewayIntentBits.GuildMessages]
});
bot.commands = new Collection();
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) {
bot.once(event.name, (...args) => event.execute(...args));
} else {
bot.on(event.name, (...args) => event.execute(...args));
}
}
bot.login(TOKEN);