Add error logging via ntfy
This commit is contained in:
parent
1e94c43aea
commit
4072116aa5
|
@ -1,4 +1,5 @@
|
||||||
{
|
{
|
||||||
|
"debug": 0,
|
||||||
"priorityColors": {
|
"priorityColors": {
|
||||||
"1": "#00AFFF",
|
"1": "#00AFFF",
|
||||||
"2": "#00FF00",
|
"2": "#00FF00",
|
||||||
|
@ -8,14 +9,21 @@
|
||||||
},
|
},
|
||||||
"discord": {
|
"discord": {
|
||||||
"token": "YOUR_TOKEN",
|
"token": "YOUR_TOKEN",
|
||||||
"owner": "your_user_id",
|
"owner": "YOUR_ID",
|
||||||
"mainGuild": "your_guild_id",
|
"mainGuild": "YOUR_GUILD",
|
||||||
"inviteChannel": "your_channel_id"
|
"inviteChannel": "INVITE_CHANNEL",
|
||||||
|
"logChannel": "LOG_CHANNEL"
|
||||||
},
|
},
|
||||||
"ntfy": {
|
"ntfy": {
|
||||||
"enabled": false,
|
"enabled": false,
|
||||||
"server": "https://Example.com",
|
"server": "https://your.ntfy.server",
|
||||||
"token": "ntfy_access_token",
|
"token": "tk_XXXXXXXXXXXXXXXX",
|
||||||
"prefix": "iem-"
|
"prefix": "iem-",
|
||||||
|
"errors": "iem-errors"
|
||||||
|
},
|
||||||
|
"broadcastify": {
|
||||||
|
"enabled": false,
|
||||||
|
"username": "YOUR_USERNAME",
|
||||||
|
"password": "YOUR_PASSWORD"
|
||||||
}
|
}
|
||||||
}
|
}
|
32
index.js
32
index.js
|
@ -1133,10 +1133,42 @@ discord.on("guildDelete", (guild) => {
|
||||||
|
|
||||||
process.on("unhandledRejection", (error) => {
|
process.on("unhandledRejection", (error) => {
|
||||||
console.log(`${colors.red("[ERROR]")} Unhandled Rejection: ${error.message}`);
|
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) => {
|
process.on("uncaughtException", (error) => {
|
||||||
console.log(`${colors.red("[ERROR]")} Uncaught Exception: ${error.message}\n${error.stack}`);
|
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
|
// Login to discord
|
||||||
|
|
Loading…
Reference in a new issue