This commit is contained in:
2026-01-29 12:26:13 +01:00
parent ba0f116bc2
commit 6dbcadcaee
79 changed files with 2795 additions and 657 deletions

62
src/index.ts Normal file
View File

@@ -0,0 +1,62 @@
/**
* Joel Discord Bot - Main Entry Point
*
* A well-structured Discord bot with clear separation of concerns:
* - core/ - Bot client, configuration, logging
* - commands/ - Slash command definitions and handling
* - events/ - Discord event handlers
* - features/ - Feature modules (Joel AI, message logging, etc.)
* - services/ - External services (AI providers)
* - database/ - Database schema and repositories
* - utils/ - Shared utilities
*/
import { GatewayIntentBits } from "discord.js";
import { BotClient } from "./core/client";
import { config } from "./core/config";
import { createLogger } from "./core/logger";
import { registerEvents } from "./events";
const logger = createLogger("Main");
// Create the Discord client with required intents
const client = new BotClient({
intents: [
GatewayIntentBits.MessageContent,
GatewayIntentBits.Guilds,
GatewayIntentBits.DirectMessages,
GatewayIntentBits.GuildMessages,
GatewayIntentBits.GuildModeration,
GatewayIntentBits.GuildMembers,
],
});
// Register all event handlers
registerEvents(client);
// Start the bot
async function main(): Promise<void> {
logger.info("Starting Joel bot...");
try {
await client.login(config.discord.token);
} catch (error) {
logger.error("Failed to start bot", error);
process.exit(1);
}
}
// Handle graceful shutdown
process.on("SIGINT", () => {
logger.info("Shutting down...");
client.destroy();
process.exit(0);
});
process.on("SIGTERM", () => {
logger.info("Shutting down...");
client.destroy();
process.exit(0);
});
main();