Files
src
.gitignore
config.json
deploy-commands.js
package.json
Code
31 1,841
src/index.js
require('dotenv').config();
const fs = require('node:fs');
const path = require('node:path');
const { Client, Collection, GatewayIntentBits } = require('discord.js');
if (!process.env.DISCORD_TOKEN) {
console.error('DISCORD_TOKEN is missing from the environment.');
process.exit(1);
}
const client = new Client({
intents: [
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildMembers,
GatewayIntentBits.GuildMessages,
GatewayIntentBits.GuildMessageReactions
]
});
client.commands = new Collection();
const commandsPath = path.join(__dirname, 'commands');
for (const file of fs.readdirSync(commandsPath).filter((file) => file.endsWith('.js'))) {
const command = require(path.join(commandsPath, file));
client.commands.set(command.data.name, command);
}
const eventsPath = path.join(__dirname, 'events');
for (const file of fs.readdirSync(eventsPath).filter((file) => file.endsWith('.js'))) {
const event = require(path.join(eventsPath, file));
if (event.once) {
client.once(event.name, (...args) => event.execute(...args));
} else {
client.on(event.name, (...args) => event.execute(...args));
}
}
process.on('unhandledRejection', (error) => {
console.error('Unhandled promise rejection:', error);
});
process.on('uncaughtException', (error) => {
console.error('Uncaught exception:', error);
});
client.login(process.env.DISCORD_TOKEN);