Files
config
src
.gitignore
deploy-commands.js
index.js
package.json
README.md
Code
52 3,333
src/bot.js
const { Client, GatewayIntentBits, Partials, Collection } = require('discord.js');
const config = require('../config/config');
const commandHandler = require('./handlers/commandHandler');
const eventHandler = require('./handlers/eventHandler');
const errorHandler = require('./handlers/errorHandler');
const client = new Client({
intents: [
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildMembers,
GatewayIntentBits.GuildBans,
GatewayIntentBits.GuildEmojisAndStickers,
GatewayIntentBits.GuildIntegrations,
GatewayIntentBits.GuildWebhooks,
GatewayIntentBits.GuildInvites,
GatewayIntentBits.GuildVoiceStates,
GatewayIntentBits.GuildMessages,
GatewayIntentBits.GuildMessageReactions,
GatewayIntentBits.MessageContent,
GatewayIntentBits.DirectMessages
],
partials: [
Partials.Message,
Partials.Channel,
Partials.Reaction,
Partials.User,
Partials.GuildMember
]
});
client.commands = new Collection();
client.cooldowns = new Collection();
async function startBot() {
try {
await commandHandler.loadCommands(client);
await eventHandler.loadEvents(client);
errorHandler.initialize(client);
await client.login(config.discord.token);
return client;
} catch (error) {
console.error('Failed to start bot:', error);
throw error;
}
}
module.exports = { startBot, client };