Add error logging via ntfy

This commit is contained in:
Christopher Cookman 2024-05-12 01:44:22 -06:00
parent 1e94c43aea
commit 4072116aa5
Signed by: ChrisChrome
GPG key ID: A023A26E42C33A42
2 changed files with 46 additions and 6 deletions

View file

@ -1,4 +1,5 @@
{
"debug": 0,
"priorityColors": {
"1": "#00AFFF",
"2": "#00FF00",
@ -8,14 +9,21 @@
},
"discord": {
"token": "YOUR_TOKEN",
"owner": "your_user_id",
"mainGuild": "your_guild_id",
"inviteChannel": "your_channel_id"
"owner": "YOUR_ID",
"mainGuild": "YOUR_GUILD",
"inviteChannel": "INVITE_CHANNEL",
"logChannel": "LOG_CHANNEL"
},
"ntfy": {
"enabled": false,
"server": "https://Example.com",
"token": "ntfy_access_token",
"prefix": "iem-"
"server": "https://your.ntfy.server",
"token": "tk_XXXXXXXXXXXXXXXX",
"prefix": "iem-",
"errors": "iem-errors"
},
"broadcastify": {
"enabled": false,
"username": "YOUR_USERNAME",
"password": "YOUR_PASSWORD"
}
}

View file

@ -1133,10 +1133,42 @@ discord.on("guildDelete", (guild) => {
process.on("unhandledRejection", (error) => {
console.log(`${colors.red("[ERROR]")} Unhandled Rejection: ${error.message}`);
if (config.ntfy.enabled) {
fetch(config.ntfy.server, {
method: 'POST',
body: JSON.stringify({
"topic": config.ntfy.errors,
"message": `Unhandled Rejection: ${error.message}`,
"tags": ["Error"],
"priority": 5
}),
headers: {
'Authorization': `Bearer ${config.ntfy.token}`
}
}).catch((err) => {
console.error(err)
})
}
});
process.on("uncaughtException", (error) => {
console.log(`${colors.red("[ERROR]")} Uncaught Exception: ${error.message}\n${error.stack}`);
if (config.ntfy.enabled) {
fetch(config.ntfy.server, {
method: 'POST',
body: JSON.stringify({
"topic": config.ntfy.errors,
"message": `Uncaught Exception: ${error.message}\n${error.stack}`,
"tags": ["Error"],
"priority": 5
}),
headers: {
'Authorization': `Bearer ${config.ntfy.token}`
}
}).catch((err) => {
console.error(err)
})
}
});
// Login to discord