From 8638ab54322719515f0e08efca47bab730cd192d Mon Sep 17 00:00:00 2001 From: Axodouble Date: Fri, 15 May 2026 06:55:43 +0000 Subject: [PATCH] Updated formatting for discord messages --- internal/alerts/discord.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/internal/alerts/discord.go b/internal/alerts/discord.go index 4d42808..251d517 100644 --- a/internal/alerts/discord.go +++ b/internal/alerts/discord.go @@ -25,12 +25,20 @@ type discordPayload struct { } // sendDiscord posts msg.Subject + body to the configured webhook URL. +// When the alert has a custom BodyTemplate, the rendered body is shipped +// verbatim — the operator has opted out of the default subject header +// and code-block wrapping in favour of their own formatting. func sendDiscord(a *config.Alert, msg Message) error { if a.DiscordWebhook == "" { return errors.New("discord webhook url not set") } - content := msg.Subject + "\n```\n" + msg.Body + "\n```" + var content string + if a.BodyTemplate != "" { + content = msg.Body + } else { + content = msg.Subject + "\n```\n" + msg.Body + "\n```" + } raw, err := json.Marshal(discordPayload{Content: content}) if err != nil { return err