From 18f58deaf205123d35c46d3b954b4cfb9a2bece5 Mon Sep 17 00:00:00 2001 From: Battlesquid Date: Sun, 21 Jul 2024 22:00:08 -0700 Subject: [PATCH] fix: exit on uncaught exception --- src/index.ts | 5 ++--- src/listeners/imageboard_check.ts | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/index.ts b/src/index.ts index 35e211b..7b9c7d0 100644 --- a/src/index.ts +++ b/src/index.ts @@ -35,13 +35,12 @@ const cleanup = () => { container.pool.end(); }; -main().catch((error) => { - container.logger.error(error); -}); +main(); process.on("uncaughtException", (error) => { console.error(error); cleanup(); + process.exit(1); }); process.on("SIGTERM", () => { diff --git a/src/listeners/imageboard_check.ts b/src/listeners/imageboard_check.ts index cac4676..8f6bd59 100644 --- a/src/listeners/imageboard_check.ts +++ b/src/listeners/imageboard_check.ts @@ -35,7 +35,7 @@ export class ImageboardCheckListener extends Listener { const notWhitelisted = !roles?.hasAny(...settings.whitelist); if (locked && hasNoLink && hasNoAttachments && notWhitelisted) { - msg.delete(); + ttry(() => msg.delete()); } } }