From fd6675cd310e90e500aa1aeb7ba07cfbcde6f0d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christer=20War=C3=A9n?= Date: Fri, 1 Nov 2024 01:57:08 +0200 Subject: [PATCH] Handle CTRL + C with SIGINT event & Add Error handling --- src/index.ts | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 src/index.ts diff --git a/src/index.ts b/src/index.ts new file mode 100644 index 0000000..6df7b58 --- /dev/null +++ b/src/index.ts @@ -0,0 +1,28 @@ +import { Client as DiscordClient, Collection, IntentsBitField } from "discord.js"; + + +process.on('SIGINT', () => { + process.exit(); +}); + +process.on('SIGTERM', () => { + process.exit(); +}); + +process.on('uncaughtException', (error) => { + console.error("Error"); + console.error(error.name); + console.error(error.message); + console.error(error.stack); +}); + +process.on('exit', () => { + +}); + +process.on('warning', (warning) => { + console.warn("Warning"); + console.warn(warning.name); + console.warn(warning.message); + console.warn(warning.stack); +});