diff --git a/server/model/monitor.js b/server/model/monitor.js index 1cb562412..81052777f 100644 --- a/server/model/monitor.js +++ b/server/model/monitor.js @@ -1068,7 +1068,13 @@ class Monitor extends BeanModel { for (let notification of notificationList) { try { - await Notification.send(JSON.parse(notification.config), msg, await monitor.toJSON(false), bean.toJSON()); + // Prevent if the msg is undefined, notifications such as Discord cannot send out. + const heartbeatJSON = bean.toJSON(); + if (!heartbeatJSON["msg"]) { + heartbeatJSON["msg"] = ""; + } + + await Notification.send(JSON.parse(notification.config), msg, await monitor.toJSON(false), heartbeatJSON); } catch (e) { log.error("monitor", "Cannot send notification to " + notification.name); log.error("monitor", e); diff --git a/server/notification-providers/discord.js b/server/notification-providers/discord.js index 28ead7b7a..ac5c8ae84 100644 --- a/server/notification-providers/discord.js +++ b/server/notification-providers/discord.js @@ -64,7 +64,7 @@ class Discord extends NotificationProvider { }, { name: "Error", - value: heartbeatJSON["msg"], + value: heartbeatJSON["msg"] == null ? "N/A" : heartbeatJSON["msg"], }, ], }],