-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.js
26 lines (26 loc) · 1.45 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
const fs = require('node:fs');
const path = require('node:path');
const { Client, Collection, GatewayIntentBits, Partials } = require('discord.js'); /* Events */
require('dotenv').config();
const client = new Client({
intents: [GatewayIntentBits.Guilds, GatewayIntentBits.GuildMembers, GatewayIntentBits.GuildMessages, GatewayIntentBits.MessageContent, GatewayIntentBits.GuildMessageReactions],
partials: [Partials.Message, Partials.Channel, Partials.Reaction],
});
client.commands = new Collection();
const commandsPath = path.join(__dirname, 'commands');
const commandFiles = fs.readdirSync(commandsPath).filter(f => f.endsWith('.js'));
for (const file of commandFiles) {
const filePath = path.join(commandsPath, file); const command = require(filePath);
if ('data' in command && 'execute' in command) {
client.commands.set(command.data.name, command)
} else {
console.log(`[WARNING] The command at ${filePath} is missing a required "data" or "execute" property.`)
};
};
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);
event.once?client.once(event.name, (...args) => event.execute(...args, client)):client.on(event.name, (...args) => event.execute(...args, client));
};
client.login(process.env.BOT_TOKEN);