Skip to content

[Bug]: Discord outbound adapter doesn't resolve usernames to user IDs - messages fail silently #2627

@BjoernSchotte

Description

@BjoernSchotte

(happened through set reminders - the cronjobs were executed but never delivered via DM to me.)

Summary

Discord channel doesn't resolve usernames to user IDs when using the message tool or cron job delivery. Usernames like john.doe are incorrectly interpreted as channel names instead of being resolved to Discord user IDs.

Steps to reproduce

  1. Create a cron job with Discord delivery targeting a username:

json
{
"name": "Test Reminder",
"schedule": "0 8 * * *",
"text": "Hello!",
"deliver": true,
"channel": "discord",
"to": "john.doe"
}
2. Wait for the cron job to execute (or run it manually)
3. Observe that delivery fails silently with lastStatus: "error"

Expected behavior

Clawdbot should resolve the username john.doe to the Discord user ID (e.g., 987674328012545978) using the existing directory system (listDiscordDirectoryPeersLive), then deliver the message as a DM.

Actual behavior

The Discord outbound adapter has no resolveTarget hook. The parseDiscordTarget() function in /src/discord/targets.ts falls back to treating unrecognized strings as channel names:
typescript
// Line 56 in targets.ts
return buildMessagingTarget("channel", trimmed, trimmed);

So john.doe is passed as a channel name lookup, which fails because no channel named john.doe exists.

  • Workaround: Use explicit user:ID format: to: "user:987654321012345678"

Environment

  • Clawdbot version: 1.0.34
  • OS: Linux 6.8.0-90-generic (x64)
  • Install method: pnpm (global)

Logs or screenshots

Cron job execution:
Name: "Test Reminder"
lastStatus: "error"
lastDurationMs: 10128
Flow trace:

  • Cron executes with to: "john.doe"
  • resolveOutboundTarget() looks for plugin.outbound?.resolveTarget → undefined for Discord
  • Fallback: to.trim()"john.doe" passed unchanged
  • sendMessageDiscord()parseDiscordTarget("john.doe")
  • No match for user:/channel:/@/#/numeric ID patterns
  • Fallback line 56: buildMessagingTarget("channel", "john.doe", "john.doe")
  • Discord attempts to find channel "john.doe" → fails

Suggested fix: Implement a resolveTarget hook for the Discord outbound adapter that uses the existing directory lookup to resolve usernames to user IDs.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    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