Skip to content

Discord Send CLI

Rina edited this page May 12, 2026 · 1 revision

Discord Send CLI

discord-send is a zero-dependency CLI that Claude Code uses to send messages back to Discord. It lives in the cli/ directory and is published as the @aomkoyo/discord-cli package.

How It Works

Claude Code runs inside a tmux session. Its system prompt instructs it to use discord-send for all replies. The CLI hits the Discord REST API v10 directly using Node.js built-in fetch — no Discord.js or other dependencies.

Usage

discord-send "Hello from Claude!"
discord-send "Reply to this" -r 1234567890123456789
discord-send "Here's a file" -f ./output.png
discord-send "Multiple files" -f ./a.png -f ./b.txt
discord-send "Remote file" -f https://example.com/image.png

Flags

Flag Description
-c <channelId> Target channel ID (defaults to DEFAULT_CHANNEL_ID)
-r <messageId> Reply to a specific message
-f <path or URL> Attach a file (can be repeated for multiple files)
-t <token> Discord bot token (overrides env/.env)

Token Resolution

The CLI resolves credentials in this order:

  1. -t <token> flag (highest priority)
  2. DISCORD_TOKEN environment variable
  3. DISCORD_TOKEN in .env file (searches current directory, then parent directories)

Channel Resolution

  1. -c <channelId> flag (highest priority)
  2. DEFAULT_CHANNEL_ID environment variable
  3. DEFAULT_CHANNEL_ID in .env file

How the Bot Injects Credentials

When a tmux session is created, the bot runs exportEnvToSession() which:

  1. Sets DISCORD_TOKEN and DEFAULT_CHANNEL_ID via tmux set-environment (for future child processes)
  2. Types export DISCORD_TOKEN=... DEFAULT_CHANNEL_ID=... as keystrokes into the shell (for the current session)

This ensures discord-send can find credentials regardless of Claude's working directory.

Safety

  • Uses allowed_mentions: { parse: [] } to prevent accidental @mentions
  • Text content is sent as-is — no markdown processing or escaping by the CLI
  • File attachments are uploaded as multipart form data
  • Remote URLs are fetched and re-uploaded (not linked)

Package Info

Name: @aomkoyo/discord-cli
Version: 0.2.0
Binary: discord-send
Dependencies: none (zero runtime deps)
Node.js: 22+

Clone this wiki locally