Skip to content

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

@hooziwang

Description

@hooziwang

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

Problem

When a Discord user sends a message like @username message, the bot receives <@USER_ID> message in the content field. While Discord API provides resolved user data in the mentions array, OpenClaw currently passes the raw <@id> format to the LLM, making it hard for agents to understand who is being mentioned.

Current Behavior

{
  "content": "<@USER_ID_PLACEHOLDER> hello",
  "mentions": [{
    "id": "USER_ID_PLACEHOLDER",
    "username": "username",
    "global_name": "Display Name"
  }]
}

LLM receives: <@USER_ID_PLACEHOLDER> hello

Desired Behavior

LLM should receive: @Display Name hello (using global_name or username)

Proposed Solution

Add a Discord message preprocessor that:

  1. Parses the mentions, mention_roles, and mention_channels arrays
  2. Replaces <@id>, <@&role_id>, and <#channel_id> with human-readable names
  3. Preserves the original format for sending messages back to Discord

Example mapping:

  • <@USER_ID>@DisplayName
  • <@&ROLE_ID>@RoleName
  • <#CHANNEL_ID>#channel-name

Use Cases

  1. Multi-agent conversations where agents need to understand who is being mentioned
  2. Role-based triggers (related to Feature Request: Discord role-mention triggers #7717)
  3. Better context understanding for AI agents

Workaround

Currently, we have to manually configure user ID mappings in each agent's SOUL.md:

- `<@USER_ID>` = @username
- `<@USER_ID_2>` = @username2

This is tedious and error-prone when adding new users or agents.

Related Issues

Metadata

Metadata

Assignees

No one assigned

    Labels

    staleMarked as stale due to inactivity

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions