Skip to content

feat(discord): auto-resolve user mentions in message content#20697

Closed
tdjackey wants to merge 2 commits intoopenclaw:mainfrom
tdjackey:feature/20617-discord-mention-resolution
Closed

feat(discord): auto-resolve user mentions in message content#20697
tdjackey wants to merge 2 commits intoopenclaw:mainfrom
tdjackey:feature/20617-discord-mention-resolution

Conversation

@tdjackey
Copy link
Copy Markdown

@tdjackey tdjackey commented Feb 19, 2026

Summary

Resolves Discord user mentions (e.g., <@123>) in incoming message content to human-readable names (e.g., @Alice) using the message's mentions metadata.

Fixes #20617.

Implementation

  • Added resolveDiscordMentions helper in message-utils.ts
  • Maps ID to global_name (priority) or username
  • Handles both <@id> and <@!id> formats
  • Added unit tests covering resolution and no-op cases

Impact

  • Agents now see @Alice hello instead of <@12345> hello
  • Improves context understanding for multi-user conversations

Greptile Summary

Adds user mention resolution to Discord message content, converting <@id> format to readable names like @Alice. The implementation correctly prioritizes global_name over username and handles both <@id> and <@!id> formats. The change is scoped to the message text resolution flow and includes appropriate test coverage for basic cases.

Confidence Score: 5/5

  • This PR is safe to merge with minimal risk
  • The implementation is clean, focused, and follows existing patterns in the codebase. The change is scoped to message text resolution with appropriate guards. Test coverage validates the core functionality. No breaking changes or security concerns identified.
  • No files require special attention

Last reviewed commit: 0cb7e10

(4/5) You can add custom instructions or style guidelines for the agent here!

@openclaw-barnacle openclaw-barnacle bot added channel: discord Channel integration: discord size: XS labels Feb 19, 2026
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 0cb7e10eb9

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

if (Array.isArray(mentions)) {
for (const user of mentions) {
const label = user.global_name || user.username;
out = out.replace(new RegExp(`<@!?${user.id}>`, "g"), `@${label}`);
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Escape replacement text when inserting mention labels

resolveDiscordMentions passes @${label} directly as the replacement string, but JavaScript treats $ sequences in replacement strings as special tokens ($&, $1, etc.). If a Discord global_name/username contains $ (which is valid for display names), the resolved text is corrupted (for example, $& re-inserts the original <@...> token), so mention normalization can fail for real users. Use a replacer function (e.g. replace(regex, () => ...)) or escape $ in the label before replacing.

Useful? React with 👍 / 👎.

@openclaw-barnacle
Copy link
Copy Markdown

This pull request has been automatically marked as stale due to inactivity.
Please add updates or it will be closed.

@openclaw-barnacle openclaw-barnacle bot added the stale Marked as stale due to inactivity label Feb 28, 2026
@thewilloftheshadow thewilloftheshadow added no-stale Exclude from stale automation and removed stale Marked as stale due to inactivity labels Mar 3, 2026
@thewilloftheshadow
Copy link
Copy Markdown
Member

Superseded by #33224.

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

Labels

channel: discord Channel integration: discord no-stale Exclude from stale automation size: XS

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature Request: Auto-resolve Discord user mentions from <@id> to @username

2 participants