mirror of
https://github.com/chenasraf/venom.git
synced 2026-05-17 17:28:08 +00:00
feat: save brain on shutdown
This commit is contained in:
11
src/index.ts
11
src/index.ts
@@ -3,6 +3,7 @@ import { DISCORD_TOKEN } from '@/env'
|
||||
import { loadCommands } from '@/core/commands'
|
||||
import { logger } from '@/core/logger'
|
||||
import { handleMessage } from '@/core/message_handler'
|
||||
import { saveBrain } from '@/core/megahal'
|
||||
|
||||
const client = new Client({
|
||||
intents: [
|
||||
@@ -22,3 +23,13 @@ client.once(Events.ClientReady, (readyClient) => {
|
||||
})
|
||||
|
||||
client.login(DISCORD_TOKEN)
|
||||
|
||||
function shutdown(signal: string) {
|
||||
return async () => {
|
||||
logger.warn(`Received ${signal}, shutting down...`)
|
||||
await saveBrain()
|
||||
}
|
||||
}
|
||||
|
||||
process.once('SIGINT', shutdown('SIGINT'))
|
||||
process.once('SIGTERM', shutdown('SIGTERM'))
|
||||
|
||||
Reference in New Issue
Block a user