joel bot
This commit is contained in:
62
src/index.ts
Normal file
62
src/index.ts
Normal 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();
|
||||
Reference in New Issue
Block a user