Skip to content

[Bug]: Discord Application ID Precision Loss #29608

@shguilin

Description

@shguilin

Summary

Summary

OpenClaw fails to resolve Discord Application IDs that exceed JavaScript's Number.MAX_SAFE_INTEGER (2^53 - 1), resulting in "Failed to resolve Discord application id" errors even with valid bot tokens.

Version

  • OpenClaw: 2026.2.26 (bc50708)
  • Node: v22.22.0
  • Platform: macOS (Darwin 23.5.0)

Description

Discord Application IDs are 64-bit integers that can exceed JavaScript's safe integer range. When OpenClaw parses the bot token to extract the Application ID, it appears to use Number type instead of BigInt or string, causing precision loss for IDs >= 2^53.

Steps to reproduce

  1. Create a Discord application with Application ID: 1477179610322964541 (19 digits)
  2. Generate a bot token from Discord Developer Portal
  3. Configure OpenClaw with the bot token:
    {
      "channels": {
        "discord": {
          "enabled": true,
          "token": "[REDACTED Discord Bot Token]"
        }
      }
    }
  4. Start OpenClaw gateway
  5. Check logs: tail -f ~/.openclaw/logs/gateway.err.log

Expected behavior

  • Discord bot connects successfully
  • No "Failed to resolve Discord application id" errors

Actual behavior

[discord] [default] channel exited: Failed to resolve Discord application id

Repeated every few seconds with auto-retry attempts.

OpenClaw version

2026.2.26

Operating system

Node: v22.22.0

Install method

No response

Logs, screenshots, and evidence

Impact and severity

No response

Additional information

Suggested Fix

Update Discord token parsing to use BigInt or preserve as string:

// Current (buggy)
const appId = Number(Buffer.from(tokenPart, 'base64').toString())

// Fixed option 1: Use BigInt
const appId = BigInt('0x' + Buffer.from(tokenPart, 'base64').toString('hex'))

// Fixed option 2: Keep as string
const appId = Buffer.from(tokenPart, 'base64').toString()

Workaround

Currently no known workaround within configuration. Users affected must:

  1. Use a Discord application with ID < 2^53 (unlikely for newer applications)
  2. Wait for OpenClaw fix

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