import { Client, GatewayIntentBits, Partials, Collection } from 'discord.js'; import { logger } from '../utils/logger'; import { env } from '../config/env'; import { loadCommands } from '../handlers/CommandLoader'; import { loadEvents } from '../handlers/EventLoader'; import { handleGlobalExceptions } from '../utils/errorHandler'; import { connectDB } from '../database'; import { connectRedis } from '../cache'; export class KordClient extends Client { public commands: Collection = new Collection(); constructor() { super({ intents: [ GatewayIntentBits.Guilds, GatewayIntentBits.GuildVoiceStates, GatewayIntentBits.GuildMessages, GatewayIntentBits.MessageContent, GatewayIntentBits.GuildInvites, ], partials: [Partials.Message, Partials.Channel, Partials.GuildMember], }); } public async start() { handleGlobalExceptions(); // Connect to external services await connectDB(); await connectRedis(); // Load Handlers await loadCommands(this); await loadEvents(this); if (!env.DISCORD_TOKEN) { logger.warn('DISCORD_TOKEN is missing. Bot cannot start.'); return; } // Login await this.login(env.DISCORD_TOKEN); logger.info(`Started login sequence...`); } }