hermes - 💡(How to fix) Fix send_message: Discord DMs fail with 'Unknown Channel' when target is a user ID

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…

send_message cannot deliver Discord DMs when given a user ID. It treats every numeric ID after discord: as a channel ID and calls POST /channels/{id}/messages directly, which returns 404 Unknown Channel (10003) because user IDs are not channel IDs.

Discord requires opening a DM channel first via POST /users/@me/channels with {"recipient_id": USER_ID}, then posting to the resulting channel ID.

Error Message

{"error": "Discord API error (404): {"message": "Unknown Channel", "code": 10003}"}

Root Cause

send_message cannot deliver Discord DMs when given a user ID. It treats every numeric ID after discord: as a channel ID and calls POST /channels/{id}/messages directly, which returns 404 Unknown Channel (10003) because user IDs are not channel IDs.

Fix Action

Workaround

Currently the only path is calling Discord's REST API directly:

# 1) Open or fetch DM channel
curl -X POST https://discord.com/api/v10/users/@me/channels \
  -H "Authorization: Bot $DISCORD_BOT_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"recipient_id":"USER_ID"}'
# → returns {"id": "DM_CHANNEL_ID", ...}

# 2) Send message
curl -X POST https://discord.com/api/v10/channels/DM_CHANNEL_ID/messages \
  -H "Authorization: Bot $DISCORD_BOT_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"content":"hi"}'

This works but bypasses the tool entirely (no chunking, retries, or adapter features).

Code Example

send_message(target="discord:1173534822736597085", message="hi")

---

{"error": "Discord API error (404): {\"message\": \"Unknown Channel\", \"code\": 10003}"}

---

# 1) Open or fetch DM channel
curl -X POST https://discord.com/api/v10/users/@me/channels \
  -H "Authorization: Bot $DISCORD_BOT_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"recipient_id":"USER_ID"}'
# → returns {"id": "DM_CHANNEL_ID", ...}

# 2) Send message
curl -X POST https://discord.com/api/v10/channels/DM_CHANNEL_ID/messages \
  -H "Authorization: Bot $DISCORD_BOT_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"content":"hi"}'
RAW_BUFFERClick to expand / collapse

Summary

send_message cannot deliver Discord DMs when given a user ID. It treats every numeric ID after discord: as a channel ID and calls POST /channels/{id}/messages directly, which returns 404 Unknown Channel (10003) because user IDs are not channel IDs.

Discord requires opening a DM channel first via POST /users/@me/channels with {"recipient_id": USER_ID}, then posting to the resulting channel ID.

Reproduction

  1. Configure Discord bot token (DISCORD_BOT_TOKEN) and confirm gateway is running.
  2. Get any Discord user ID that shares a guild with the bot.
  3. Call:
    send_message(target="discord:1173534822736597085", message="hi")

Expected

DM is delivered to the target user.

Actual

{"error": "Discord API error (404): {\"message\": \"Unknown Channel\", \"code\": 10003}"}

Workaround

Currently the only path is calling Discord's REST API directly:

# 1) Open or fetch DM channel
curl -X POST https://discord.com/api/v10/users/@me/channels \
  -H "Authorization: Bot $DISCORD_BOT_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"recipient_id":"USER_ID"}'
# → returns {"id": "DM_CHANNEL_ID", ...}

# 2) Send message
curl -X POST https://discord.com/api/v10/channels/DM_CHANNEL_ID/messages \
  -H "Authorization: Bot $DISCORD_BOT_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"content":"hi"}'

This works but bypasses the tool entirely (no chunking, retries, or adapter features).

Suggested fix

In tools/send_message_tool.py Discord branch (around the Platform.DISCORD dispatch, ~L250):

  1. Introduce an explicit discord:dm:USER_ID syntax (most explicit, no ambiguity), or
  2. Auto-detect: when the supplied ID resolves to a user (via GET /users/{id} or by failing the channel send with 10003), open a DM channel via POST /users/@me/channels and retry.

Option 1 is preferable — it's unambiguous, avoids an extra round-trip, and is consistent with Telegram-style chat_id semantics. The existing target-parser (_parse_target / _NUMERIC_TOPIC_RE) already handles prefix-style routing (e.g. discord:CHANNEL_ID:THREAD_ID), so adding a dm: keyword is a small change.

Cache the resulting DM channel id per-recipient to avoid hitting /users/@me/channels on every send.

Doc update

The target parameter description in the tool schema (line ~130) lists Discord formats but not DMs. Should mention discord:dm:USER_ID (or whatever syntax is chosen) once implemented.

Environment

  • Hermes v2026.3.28
  • discord.py 2.7.1, aiohttp 3.13.5
  • Python venv at ~/.hermes/hermes-agent/venv

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING