diff --git a/server/notification-providers/discord.js b/server/notification-providers/discord.js index e0798831..a2b42319 100644 --- a/server/notification-providers/discord.js +++ b/server/notification-providers/discord.js @@ -14,9 +14,11 @@ class Discord extends NotificationProvider { try { const discordDisplayName = notification.discordUsername || "Uptime Kuma"; - var threadQuery = ""; + let threadQuery = ""; - if (notification.discordChannelType == "postToThread") threadQuery = "?thread_id=" + notification.threadId; + if (notification.discordChannelType === "postToThread") { + threadQuery = "?thread_id=" + notification.threadId; + } // If heartbeatJSON is null, assume we're testing. if (heartbeatJSON == null) { @@ -25,7 +27,9 @@ class Discord extends NotificationProvider { content: msg, }; - if (notification.discordChannelType == "createNewForumPost") discordtestdata.thread_name = notification.postName; + if (notification.discordChannelType === "createNewForumPost") { + discordtestdata.thread_name = notification.postName; + } await axios.post(notification.discordWebhookUrl + threadQuery, discordtestdata); return okMsg; @@ -54,9 +58,11 @@ class Discord extends NotificationProvider { // If heartbeatJSON is not null, we go into the normal alerting loop. if (heartbeatJSON["status"] === DOWN) { const discordDisplayName = notification.discordUsername || "Uptime Kuma"; - var threadQuery = ""; + let threadQuery = ""; - if (notification.discordChannelType == "postToThread") threadQuery = "?thread_id=" + notification.threadId; + if (notification.discordChannelType === "postToThread") { + threadQuery = "?thread_id=" + notification.threadId; + } let discorddowndata = { username: discordDisplayName, @@ -84,12 +90,14 @@ class Discord extends NotificationProvider { ], }], }; - if (notification.discordChannelType == "createNewForumPost") discorddowndata.thread_name = notification.postName; + if (notification.discordChannelType === "createNewForumPost") { + discorddowndata.thread_name = notification.postName; + } if (notification.discordPrefixMessage) { discorddowndata.content = notification.discordPrefixMessage; } - await axios.post(notification.discordWebhookUrl, discorddowndata); + await axios.post(notification.discordWebhookUrl + threadQuery, discorddowndata); return okMsg; } else if (heartbeatJSON["status"] === UP) { @@ -120,7 +128,9 @@ class Discord extends NotificationProvider { }], }; - if (notification.discordChannelType == "createNewForumPost") discordupdata.thread_name = notification.postName; + if (notification.discordChannelType === "createNewForumPost") { + discordupdata.thread_name = notification.postName; + } if (notification.discordPrefixMessage) { discordupdata.content = notification.discordPrefixMessage; diff --git a/src/components/notifications/Discord.vue b/src/components/notifications/Discord.vue index 6e251d66..2ceaaec6 100644 --- a/src/components/notifications/Discord.vue +++ b/src/components/notifications/Discord.vue @@ -20,7 +20,7 @@

- @@ -42,8 +42,8 @@ \ No newline at end of file +}; +