File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11import { Client , GatewayIntentBits } from "discord.js" ;
2+ import { connectDatabase , disconnectDatabase } from "./database/operations.js" ;
23import { config } from "./env.js" ;
34import { loadCommands , registerCommands } from "./utils/commands.js" ;
45import { loadEvents } from "./utils/events.js" ;
56
67const client = new Client ( { intents : [ GatewayIntentBits . Guilds ] } ) ;
78
9+ // Connect to database before starting bot
10+ await connectDatabase ( ) ;
11+
812loadCommands ( client ) ;
913loadEvents ( client ) ;
1014registerCommands ( ) ;
1115
16+ // Graceful shutdown
17+ process . on ( "SIGINT" , async ( ) => {
18+ console . log ( "Shutting down..." ) ;
19+ await disconnectDatabase ( ) ;
20+ process . exit ( 0 ) ;
21+ } ) ;
22+
23+ process . on ( "SIGTERM" , async ( ) => {
24+ console . log ( "Shutting down..." ) ;
25+ await disconnectDatabase ( ) ;
26+ process . exit ( 0 ) ;
27+ } ) ;
28+
1229client . login ( config . discord . token ) ;
You can’t perform that action at this time.
0 commit comments