From 9680dc46f067f35a0082028efd59541248515a69 Mon Sep 17 00:00:00 2001 From: ChrisChrome Date: Sun, 10 Mar 2024 16:12:31 -0600 Subject: [PATCH] add ntfy logs --- index.js | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/index.js b/index.js index 0f33b0b..685aff0 100644 --- a/index.js +++ b/index.js @@ -193,4 +193,35 @@ client.on("interactionCreate", async (interaction) => { }); +// Lets actually handle exceptions now +process.on('unhandledRejection', (error) => { + // Log a full error with line number + sendLog(`${colors.red("[ERROR]")} ${error}`); + // If config.ntfyUrl is set, Send the exception to ntfy + if (config.ntfyUrl) fetch(config.ntfyUrl, { + method: 'POST', // PUT works too + body: error, + headers: { + 'Title': 'TicketTool Watcher Bot Rejection', + 'Priority': 5, + 'Tags': 'warning,inbox_tray,TicketTool Watcher' + } + }); +}); + +process.on('uncaughtException', (error) => { + // Log a full error with line number + sendLog(`${colors.red("[ERROR]")} ${error}`); + // If config.ntfyUrl is set, Send the exception to ntfy + if (config.ntfyUrl) fetch(config.ntfyUrl, { + method: 'POST', // PUT works too + body: error, + headers: { + 'Title': 'TicketTool Watcher Bot Exception', + 'Priority': 5, + 'Tags': 'warning,inbox_tray,TicketTool Watcher' + } + }); +}); + client.login(config.token) \ No newline at end of file