Repository: louislam/uptime-kuma
File: server/notification.js (JavaScript)

Code before:
                                value: monitorJSON["name"],
                            },
                            {
                                name: "Service URL",
                                value: monitorJSON["url"],
                            },
                            {
                                name: "Time (UTC)",
                                value: heartbeatJSON["time"],
                            },
                            {
                                name: "Error",
                                value: heartbeatJSON["msg"],
                            },
                        ],
                    }],
                }
                await axios.post(notification.discordWebhookUrl, discorddowndata)
                return okMsg;
                    
                } else if (heartbeatJSON["status"] == 1) {
                    let discordupdata = {
                    username: "Uptime Kuma",
                    embeds: [{
                        title: "✅ Your service " +  monitorJSON["name"] + " is up! ✅",
                        color: 65280,
                        timestamp: heartbeatJSON["time"],
                        fields: [
                            {
                                name: "Service Name",
                                value: monitorJSON["name"],
                            },
                            {
                                name: "Service URL",
                                value: "[Visit Service]("+ monitorJSON["url"] +")",
                            },
                            {
                                name: "Time (UTC)",
                                value: heartbeatJSON["time"],
                            },
                            {
                                name: "Ping",
                                value: heartbeatJSON["ping"] + "ms",
                            },
                        ],
                    }],
                }
                await axios.post(notification.discordWebhookUrl, discordupdata)
                return okMsg;
                }
            } catch (error) {

Review comment (suggestion):
Would recommend replacing these with globals, like `color: colors.green`, same with the alert color.

Code after:
                                    value: monitorJSON["name"],
                                },
                                {
                                    name: "Service URL",
                                    value: monitorJSON["url"],
                                },
                                {
                                    name: "Time (UTC)",
                                    value: heartbeatJSON["time"],
                                },
                                {
                                    name: "Error",
                                    value: heartbeatJSON["msg"],
                                },
                            ],
                        }],
                    }
                    await axios.post(notification.discordWebhookUrl, discorddowndata)
                    return okMsg;

                } else if (heartbeatJSON["status"] == 1) {
                    let discordupdata = {
                        username: notification.discordUsername || "Uptime Kuma",
                        embeds: [{
                            title: "✅ Your service " + monitorJSON["name"] + " is up! ✅",
                            color: 65280,
                            timestamp: heartbeatJSON["time"],
                            fields: [
                                {
                                    name: "Service Name",
                                    value: monitorJSON["name"],
                                },
                                {
                                    name: "Service URL",
                                    value: "[Visit Service](" + monitorJSON["url"] + ")",
                                },
                                {
                                    name: "Time (UTC)",
                                    value: heartbeatJSON["time"],
                                },
                                {
                                    name: "Ping",
                                    value: heartbeatJSON["ping"] + "ms",
                                },
                            ],
                        }],
                    }
                    await axios.post(notification.discordWebhookUrl, discordupdata)
                    return okMsg;
                }
            } catch (error) {