run eslint for discord enhancement

This commit is contained in:
LouisLam 2021-08-08 02:18:33 +08:00
parent 4469b3a19b
commit 2677f5dd87

View File

@ -96,63 +96,63 @@ class Notification {
// If heartbeatJSON is not null, we go into the normal alerting loop. // If heartbeatJSON is not null, we go into the normal alerting loop.
if (heartbeatJSON["status"] == 0) { if (heartbeatJSON["status"] == 0) {
let discorddowndata = { let discorddowndata = {
username: notification.discordUsername || "Uptime Kuma", username: notification.discordUsername || "Uptime Kuma",
embeds: [{ embeds: [{
title: "❌ One of your services went down. ❌", title: "❌ One of your services went down. ❌",
color: 16711680, color: 16711680,
timestamp: heartbeatJSON["time"], timestamp: heartbeatJSON["time"],
fields: [ fields: [
{ {
name: "Service Name", name: "Service Name",
value: monitorJSON["name"], value: monitorJSON["name"],
}, },
{ {
name: "Service URL", name: "Service URL",
value: monitorJSON["url"], value: monitorJSON["url"],
}, },
{ {
name: "Time (UTC)", name: "Time (UTC)",
value: heartbeatJSON["time"], value: heartbeatJSON["time"],
}, },
{ {
name: "Error", name: "Error",
value: heartbeatJSON["msg"], value: heartbeatJSON["msg"],
}, },
], ],
}], }],
} }
await axios.post(notification.discordWebhookUrl, discorddowndata) await axios.post(notification.discordWebhookUrl, discorddowndata)
return okMsg; return okMsg;
} else if (heartbeatJSON["status"] == 1) { } if (heartbeatJSON["status"] == 1) {
let discordupdata = { let discordupdata = {
username: notification.discordUsername || "Uptime Kuma", username: notification.discordUsername || "Uptime Kuma",
embeds: [{ embeds: [{
title: "✅ Your service " + monitorJSON["name"] + " is up! ✅", title: "✅ Your service " + monitorJSON["name"] + " is up! ✅",
color: 65280, color: 65280,
timestamp: heartbeatJSON["time"], timestamp: heartbeatJSON["time"],
fields: [ fields: [
{ {
name: "Service Name", name: "Service Name",
value: monitorJSON["name"], value: monitorJSON["name"],
}, },
{ {
name: "Service URL", name: "Service URL",
value: "[Visit Service]("+ monitorJSON["url"] +")", value: "[Visit Service](" + monitorJSON["url"] + ")",
}, },
{ {
name: "Time (UTC)", name: "Time (UTC)",
value: heartbeatJSON["time"], value: heartbeatJSON["time"],
}, },
{ {
name: "Ping", name: "Ping",
value: heartbeatJSON["ping"] + "ms", value: heartbeatJSON["ping"] + "ms",
}, },
], ],
}], }],
} }
await axios.post(notification.discordWebhookUrl, discordupdata) await axios.post(notification.discordWebhookUrl, discordupdata)
return okMsg; return okMsg;
} }
} catch (error) { } catch (error) {
throwGeneralAxiosError(error) throwGeneralAxiosError(error)