Files
src
.gitignore
package.json
Code
16 1,411
src/bot.js
const { Client, GatewayIntentBits, Partials, Collection } = require('discord.js');
const fs = require('fs');
const path = require('path');
require('dotenv').config();
const Database = require('./database/database');
const { initializePlayer } = require('./music/player');
const client = new Client({
intents: [
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildMembers,
GatewayIntentBits.GuildMessages,
GatewayIntentBits.MessageContent,
GatewayIntentBits.GuildVoiceStates,
GatewayIntentBits.GuildPresences,
GatewayIntentBits.GuildMessageReactions,
GatewayIntentBits.DirectMessages,
GatewayIntentBits.GuildInvites,
GatewayIntentBits.GuildModeration
],
partials: [
Partials.Channel,
Partials.Message,
Partials.User,
Partials.GuildMember,
Partials.Reaction
]
});
client.commands = new Collection();
client.cooldowns = new Collection();
client.snipes = new Collection();
client.editSnipes = new Collection();
client.afkUsers = new Collection();
client.tempVoices = new Collection();
client.activeGames = new Collection();
client.activeGiveaways = new Collection();
client.db = new Database();
const commandFolders = fs.readdirSync(path.join(__dirname, 'commands'));
for (const folder of commandFolders) {
const commandFiles = fs.readdirSync(path.join(__dirname, 'commands', folder)).filter(file => file.endsWith('.js'));
for (const file of commandFiles) {
const command = require(path.join(__dirname, 'commands', folder, file));
if (command.name) {
client.commands.set(command.name, command);
}
}
}
const eventFiles = fs.readdirSync(path.join(__dirname, 'events')).filter(file => file.endsWith('.js'));
for (const file of eventFiles) {
const event = require(path.join(__dirname, 'events', file));
if (event.once) {
client.once(event.name, (...args) => event.execute(...args, client));
} else {
client.on(event.name, (...args) => event.execute(...args, client));
}
}
initializePlayer(client);
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);
module.exports = client;