-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
32 lines (26 loc) · 1023 Bytes
/
index.js
File metadata and controls
32 lines (26 loc) · 1023 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
const client = require("./src/client");
const { DISCORD_TOKEN } = require("./src/config");
const { initializeDatabase, closeDatabase } = require("./src/database/connection");
const { registerCommands } = require("./src/commands/definitions");
const { handleInteraction } = require("./src/handlers/interactionHandler");
const { handleMessage } = require("./src/handlers/messageHandler");
initializeDatabase();
client.once("ready", () => {
console.log(`Logged in as ${client.user.tag}`);
registerCommands(client);
});
client.on("interactionCreate", handleInteraction);
client.on("messageCreate", handleMessage);
function cleanup() {
console.log("Cleaning up...");
closeDatabase()
.then(() => process.exit(0))
.catch(() => process.exit(1));
}
process.on("SIGINT", cleanup);
process.on("SIGTERM", cleanup);
process.on("uncaughtException", (error) => {
console.error("Uncaught exception:", error);
cleanup();
});
client.login(DISCORD_TOKEN);