Skip to content

fix: Move Discord alert message to embed description field#368

Open
khj68 wants to merge 2 commits intografana:mainfrom
khj68:fix/discord-embed-description
Open

fix: Move Discord alert message to embed description field#368
khj68 wants to merge 2 commits intografana:mainfrom
khj68:fix/discord-embed-description

Conversation

@khj68
Copy link

@khj68 khj68 commented Aug 16, 2025

What this PR does

This PR fixes the Discord notification formatting issue where alert messages appear above the title instead of below it. The issue was caused by the message content being placed in the Discord message's main content field rather than in the embed's description field.

Changes:

  • Added a Description field to the discordLinkEmbed struct to support embed descriptions
  • Modified the notification logic to place the alert message in the embed's description field
  • Set the main content field to an empty string to prevent text from appearing above the embed
  • Updated tests to reflect the new message structure

Which issue(s) this PR fixes

Fixes grafana/grafana#86565

Special notes for reviewer

The Discord API documentation specifies that the content field appears outside of embeds, while the embed's description field appears below the title within the embed itself. This change aligns our implementation with Discord's expected behavior and matches what users see with other notification channels like Slack.

Before:

[Message content appears here above everything]
┌─────────────────────────┐
│ [Title]                 │
│ Footer                  │
└─────────────────────────┘

After:

┌─────────────────────────┐
│ [Title]                 │
│ [Message content here]  │
│ Footer                  │
└─────────────────────────┘

Checklist

  • Tests updated
  • Documentation updated (not needed for this fix)
  • Code follows the project's style guidelines

Previously, alert messages appeared above the title in Discord notifications
because they were being sent in the 'content' field. This change:

- Adds a 'description' field to the discordLinkEmbed struct
- Moves the message content from the main 'content' field to the embed's
  'description' field
- Leaves the main 'content' field empty to avoid displaying text above the embed
- Updates tests to reflect the new message structure

This ensures that alert messages appear below the title in a properly
formatted Discord embed, providing a better user experience.

Fixes grafana/grafana#86565
@khj68 khj68 requested a review from a team as a code owner August 16, 2025 14:36
@github-project-automation github-project-automation bot moved this to In review in Alerting Aug 16, 2025
@CLAassistant
Copy link

CLAassistant commented Aug 16, 2025

CLA assistant check
All committers have signed the CLA.

…mentation

Removed explanatory comments that were added during the implementation
as they are no longer needed now that the code is self-explanatory.
@yuri-tceretian yuri-tceretian self-assigned this Nov 6, 2025
@yuri-tceretian
Copy link
Collaborator

Hey @khj68. Thanks for opening it. I am very sorry that it's been ignored for so long. Perhaps nobody just noticed it in this repository. We will improve, I promise.

In the meantime, while I am reviewing the change, could you please rebase your fix on main and resolve the conflicts?

@@ -42,10 +42,11 @@ type discordMessage struct {

// discordLinkEmbed implements https://discord.com/developers/docs/resources/channel#embed-object
Copy link
Collaborator

@yuri-tceretian yuri-tceretian Nov 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please change to https://discord.com/developers/docs/resources/message#embed-object-embed-structure

Copy link
Collaborator

@yuri-tceretian yuri-tceretian left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Thanks. Just needs rebase

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: In review

Development

Successfully merging this pull request may close these issues.

Alerting: Discord alert message is above the title

3 participants