Discord CLI README

The full upstream README, mirrored for reference. Install config, tool schemas, adoption signals and our own overview live on the Discord CLI listing page.

discord β€” Your Discord, Driven From the Terminal

🚧 Active development β€” daily tested, not daily committed

This repo is under heavy daily use (automated digests, MCP integrations, agent workflows). If commit activity looks sparse, it's because the tool is stable for its current feature set β€” no open issues, no regressions, no need for churn. New features ship when real workflows surface a gap, not on a schedule. Check Releases for the latest binary.

discord β€” read, send, search, and manage any server/DM you belong to, as yourself

Platform Rust License


A Discord CLI + MCP server that operates your user account β€” so it sees every server, group, and DM you belong to. No bot invitation required.
Built in Rust for AI agents and terminal-first humans: 77 commands, SQLite archive with FTS5 search, stealth-aware, and an MCP server that plugs straight into Claude Code.

⚠️ ToS / account-risk warning β€” Automating a user account violates Discord's Terms of Service and can result in account termination. Use only on accounts you control, with restraint: rate limits are built in, reads are bounded, and destructive actions require explicit --confirm. Admin operations (channel-*, role-*, emoji-*) are the highest-risk surface β€” channel deletion is irreversible and plainly visible. auth --qr uses Discord's login API (highest risk) β€” opt-in only, never automatic. See docs/ADMIN.md for the permission matrix and ToS risk table.


Installation

bash
# macOS / Linux β€” one-liner (downloads prebuilt binary)
curl -fsSL "https://raw.githubusercontent.com/quangdang46/discord_cli/main/install.sh?$(date +%s)" | bash

# With PATH auto-update + self-test
curl -fsSL "https://raw.githubusercontent.com/quangdang46/discord_cli/main/install.sh?$(date +%s)" | bash -s -- --easy-mode --verify

# Pin a specific version
curl -fsSL "https://raw.githubusercontent.com/quangdang46/discord_cli/main/install.sh?$(date +%s)" | bash -s -- --version v0.1.0
powershell
# Windows PowerShell
irm "https://raw.githubusercontent.com/quangdang46/discord_cli/main/install.ps1" | iex

Prebuilt binaries are attached to every GitHub release (Linux x86_64/aarch64 musl, macOS x86_64/aarch64, Windows x86_64) with .sha256 checksums.

bash
# From source (requires Rust 1.80+)
cargo install --path crates/discord-cli --locked
# or build the workspace binary
cargo build --release && cp target/release/discord /usr/local/bin/

The workspace uses a tokio_unstable cfg for discord-user-rs (see .cargo/config.toml); cargo build handles it.



πŸ€– Agent Quickstart (Robot Mode)

This tool is built for AI agents. Every command emits machine-readable JSON/JSONL β€” never a bare interactive UI.

bash
# 1) Authenticate once (auto-detect from local Discord/browser, or paste)
discord auth --save

# 2) "What can I see?" β€” discovery
discord guilds --json
discord dms --json

# 3) Read a channel (the agent-facing read)
discord read "guide" -l 20 --json

# 4) Archive + search offline
discord sync-all -l 200
discord search "deploy" -n 50

# 5) Reply (gated β€” needs --confirm for new messages)
discord send "guide" --text "Deploy looks good" --reply 1087808713206804713

# 6) Or run the full MCP server
claude mcp add discord --env DISCORD_TOKEN=$DISCORD_TOKEN -- $(which discord) serve

Output contract

  • stdout = data only (JSONL when piped, --json for a single envelope)
  • stderr = diagnostics
  • exit 0 = success, 2 = usage (missing --confirm), 3 = not found, 4 = forbidden
  • Envelope: {"ok":true,"schema_version":"1","data":[...]} / {"ok":false,...,"error":{...}}

See AGENTS.md for the full agent playbook (summarize / explore / reply / watch).


TL;DR

The Problem

  • Bots are blind. A Discord bot only sees channels it was invited to β€” you can't have an AI read your private DMs, your friends' server, or a channel you joined years ago.
  • The app is manual. Opening Discord to read/search/reply is slow; scripting it means fighting a GUI.
  • Self-botting is risky. Unofficial user-token tools often scrape aggressively and get accounts banned.

The Solution

discord reads and writes Discord as your own account β€” every guild, group, and DM you belong to β€” from the terminal, with the same browser-like fingerprint a real client would send (UA, X-Super-Properties, per-install device_id). It archives what you read into SQLite for instant offline search, and exposes everything to agents over both CLI and MCP.

bash
discord guilds
discord read "general" -l 20
discord search "meeting notes"

Why discord?

FeatureWhat it does
Sees everything you canReads any server/DM/thread you belong to β€” no bot invite
Agent-native outputJSONL/JSON envelope + exit-code contract on every command
MCP serverdiscord serve β†’ 43 tools for Claude Code, Cursor, etc.
Offline archivesync β†’ SQLite + FTS5 full-text search, search/recent/stats/top
Stealth-awareBrowser UA + X-Super-Properties + launch_signature mask + device_id
Safe by default--confirm/--dry-run on destructive ops, bounded sync, rate-limit backoff, invisible presence
Live followstail / watch stream new messages as JSONL over the gateway
Cross-platformSingle Rust binary for Linux / macOS / Windows

How discord Compares

CapabilitydiscordDiscord botdiscord.py self-botTerminal Discord app
Read any channel you belong toYesOnly invitedYesYes
Agent-friendly (JSON/JSONL/MCP)YesVia libsNoNo
Offline search archiveYesNoNoNo
Stealth fingerprintingYesN/APartialPartial
Safe write gating (--confirm)YesManualManualN/A
Banned-account risk⚠️ Low if cautiousNone⚠️ High if carelessNone
Setup frictiondiscord authApp + invite + intentsToken scrapingInstall app

Quick Example

bash
# Authenticate (auto-detect from your local Discord/Chrome session)
discord auth --save                 # β†’ {"authenticated":true,"source":"Chrome"}

# Verify who you are
discord whoami --json               # id, username, global_name, mfa_enabled

# Explore β€” what servers and DMs do you belong to?
discord guilds --json               # every guild you've joined
discord dms --json                  # DM + group-DM channels, labeled

# Drill into a server's channels
discord channels "TDG" --json       # text/announcement/forum, sorted

# Read recent messages (agent-friendly)
discord read "guide" -l 10 --json   # message_id, author, timestamp, content

# Archive a channel for offline search
discord sync "guide" -l 500         # β†’ {"messages_synced": N}
discord sync "guide" --follow       # backfill, then keep persisting new messages (gateway)
discord sync "guide" --follow --max-duration 3600   # bounded follow (cron-friendly)
discord search "release" -n 20      # FTS5 over the local SQLite archive
discord stats --json                # per-channel counts

# Act (gated)
discord send "guide" --text "hi" --confirm       # requires --confirm
discord send "guide" --text "re:" --reply <MSG_ID>  # reply is auto-approved
discord send "guide" --text "https://x.com/..." --suppress-embeds  # no link preview
discord send "guide" --text "@mods ping" --mention-roles 111 222    # role-mention allowlist
discord react "guide" <MSG_ID> "πŸ‘"

# Live follow a keyword
discord watch --keyword "incident" --jsonl

Commands

Auth & identity

CommandWhat it does
auth [--save] [--paste] [--qr]Auto-detect token, paste, or QR scan (mobile); validate + save
statusValidate configured token (exit 1 on failure)
whoami [--json]Show the authenticated user's profile

Read

CommandWhat it does
guildsList every server you belong to
channels <GUILD>List text/announcement/forum channels
dmsList DM + group-DM channels
history <CH> [-l N] [--before/--after]Paginated message history
read <CH> [-l N] [--before ID] [--around ID] [--since 12h|30d|YYYY-MM-DD] [--transcript]Recent messages β€” the agent-facing read; --around = window centered on a message (limit/2 each side); --since = time cutoff (snowflake after cursor); --transcript = compact plain-text (β‰ˆ5Γ— smaller, ideal for AI summarization)
members <GUILD> [--max N]Guild members
info <GUILD>Guild name, member/online counts
guild-search <GUILD> <QUERY>Discord native search
roles <GUILD>Guild roles, by position
profile [USER_ID]User profile (default: self)
userinfo <USER_ID>Public info for any user (username, badges, avatar, created_at) β€” user-token safe
relationshipsFriends / blocked / pending
threads <CH>Active threads (user-token fallback)
thread-create <CH> --name X [--message-id M] [--text T]Create thread (standalone/message/forum)
pins <CH>Pinned messages

Act

CommandWhat it does
send <CH> --text "..." [--file PATH]... [--reply ID] [--suppress-embeds] [--mention-roles ID]... [--confirm]Send / reply / attach (gated; --text - reads stdin; --suppress-embeds kills link previews; --mention-roles allowlists role mentions)
edit <CH> <MSG_ID> --text "..."Edit own message
delete <CH> <MSG_ID> [--confirm]Delete own message (gated)
react / unreactAdd / remove a reaction
pin <CH> <MSG_ID>Pin a message
dm-group create/add/removeGroup-DM management (gated create)
notify guild/channelNotification settings
join <INVITE> [--confirm]Preview + join a server via invite code/URL (gated)
leave <GUILD> [--confirm]Leave a server (gated)
presence [STATUS]Show/set presence (online|idle|dnd|invisible; default invisible)

Admin & moderation

CommandWhat it does
channel-create <GUILD> <NAME> [--type T] [--category C] [--topic T] [--slowmode N] [--dry-run]Create a channel (MANAGE_CHANNELS)
channel-rename <GUILD> <CH> <NAME> [--dry-run]Rename a channel
channel-topic <GUILD> <CH> <TOPIC>Set a channel topic (≀1024)
channel-move <GUILD> <CH> [--category C] [--position N]Move a channel (β‰₯1 option)
channel-clone <GUILD> <CH> [--name N]Clone a channel (same type/parent/topic)
channel-slowmode <GUILD> <CH> <SECONDS>Set slowmode (0-21600)
channel-delete <GUILD> <CH> [--confirm]Delete a channel (gated β€” highest ToS risk)
role-create <GUILD> <NAME> [--color C] [--permissions P] [--mentionable] [--hoist] [--dry-run]Create a role (MANAGE_ROLES)
role-edit <GUILD> <ROLE> [--name N] [--color C] [--permissions P] [--mentionable] [--no-mentionable] [--hoist] [--no-hoist] [--dry-run]Edit a role (β‰₯1 option)
role-delete <GUILD> <ROLE> [--confirm]Delete a role (gated; @everyone guarded)
role-assign <GUILD> <ROLE> <USER>Assign a role to a member
role-remove <GUILD> <ROLE> <USER>Remove a role from a member
emoji-list <GUILD> [--count N]List custom emojis (MANAGE_GUILD_EXPRESSIONS)
emoji-upload <GUILD> <NAME> <FILE>Upload a custom emoji (≀256KiB png/jpg/gif)
emoji-delete <GUILD> <EMOJI> [--confirm]Delete a custom emoji (gated)
member-kick <GUILD> <USER> [--reason R] [--confirm]Kick a member (KICK_MEMBERS; gated)
member-ban <GUILD> <USER> [--reason R] [--delete-days D] [--confirm]Ban a member (BAN_MEMBERS; gated)
member-unban <GUILD> <USER> [--confirm]Unban a user by ID (BAN_MEMBERS; gated)
member-nick <GUILD> <USER> <NICKNAME>Set/clear a member's nickname (MANAGE_NICKNAMES; empty clears)
perm-view <GUILD> <CHANNEL>List a channel's permission overwrites
perm-set <GUILD> <CHANNEL> <ROLE> [--allow A] [--deny D]Set a role's channel overwrite (MANAGE_CHANNELS; β‰₯1 of allow/deny)
perm-lock <GUILD> <CHANNEL> [--dry-run] [--confirm]Make a channel read-only for @everyone (gated)
perm-unlock <GUILD> <CHANNEL> [--confirm]Remove the @everyone overwrite (gated)
perm-listList permission names β†’ bit table (local)
server-set <GUILD> [--name N] [--description D] [--verification V] [--notifications N] [--content-filter C] [--afk-timeout T] [--system-channel ID] [--rules-channel ID] [--dry-run]Edit server settings (MANAGE_GUILD; β‰₯1 option)
server-icon <GUILD> <FILE>Set the server icon (≀256KiB png/jpg/gif)
audit-log <GUILD> [--count N] [--type ACTION] [--user ID]View the audit log (VIEW_AUDIT_LOG)
audit-typesList audit action names β†’ codes (local)
invite-list <GUILD>List guild invites (MANAGE_CHANNELS)
invite-create <GUILD> <CHANNEL> [--max-age N] [--max-uses N] [--temporary]Create an invite (CREATE_INSTANT_INVITE; unique link)
invite-delete <CODE|URL> [--guild G] [--confirm]Delete an invite by code/URL (gated)
embed <CH> --title T [--description D] [--color HEX] [--field 'N|V|inline']... [--confirm] [--dry-run]Send a rich-embed message (gated; validated)

Admin ops map 403 β†’ exit 4. Full permission matrix + risk table: docs/ADMIN.md.

Archive & query (local SQLite + FTS5)

CommandWhat it does
sync <CH> [-l N] [--follow [--max-duration S]]Incremental two-phase sync to SQLite; --follow keeps tailing new messages into the archive via gateway (invisible presence)
sync-all [-l N]Discover + sync accessible channels (bounded)
search <KW> [-c CH] [--author A] [--since 12h|30d|DATE] [-n N]FTS5 full-text search
recent [--hours N] [--since 12h|30d|DATE]Newest stored messages
statsPer-channel counts
todayPer-channel counts since 00:00 local
timeline [--by day|hour]Message volume per bucket (ASCII bars)
top [-c CH]Top senders
top-reactions [--guild G] [--channel C] [--limit N]Hottest messages by reaction count
export <CH> [-f json] [-o FILE]Export archive
purge <CH> [-y]Delete archive for a channel (gated)
download [--guild G] [--channel C] [--type T] [--since S] [--min-reactions N] [--out DIR]Download archived attachments to disk

Live & AI

CommandWhat it does
typing <CH>Send a typing indicator (one-shot)
tail <CH> [--once] / watch [--typing]Gateway live follow (invisible presence)
watch [--channel C] [--keyword K]Long-running JSONL stream for agents
fetch-links <CH> [--since S] [--limit N] [--out DIR]Download external image links via Discord CDN proxy
serveMCP server (stdio, 43 tools)

Architecture

Code
crates/
  discord-core/   REST client, stealth (X-Super-Properties, launch_signature),
                  config, types, output envelope
  discord-auth/   token auto-detect (LevelDB scan), paste, keyring, device_id
  discord-db/     SQLite schema, FTS5 search, two-phase sync state
  discord-cli/    the `discord` binary + 77 commands
  discord-mcp/    MCP server (rmcp stdio) β€” 43 tools

Design principles

PrincipleWhat it means
Transport firstdiscord-core wraps discord-user-rs; every command is a thin layer
Agent-first outputJSONL/JSON envelope + exit codes on every surface
Stealth by defaultReal-client headers + per-install identity from day one

Stealth status: The CLI sends real-client browser headers, X-Super-Properties, a masked launch_signature, per-install device_id, and gateway is_fast_connect. TLS ClientHello (JA3) fingerprinting is not yet spoofed (uses rustls) β€” an optional future feature. --tls-chrome is reserved but returns "not implemented" (exit 2). | Safety gating | --confirm / --dry-run never interactive | | Local-first archive | Read once, query forever (SQLite + FTS5) | | Bounded by design | Sync caps, rate-limit backoff, invisible presence |


Safety & Rate Limits

GuardWhat it does
--confirmRequired for destructive / non-reply sends (never interactive)
--dry-runPreview what would happen without acting
Rate limitingJitter between pages, 429 backoff (2s→10s), honors X-RateLimit-*
Invalid-request budgetCloudflare-1015 protection (warn at 7k, stop at 9.5k)
sync-all boundedPer-channel cap (default 200)
Gateway presenceDefaults to Invisible
purgeOnly touches local archive, never Discord

Troubleshooting

SymptomLikely causeFix
status exits 1No token configureddiscord auth --save or --paste
auth finds tokens but none validateStale tokens in LevelDBdiscord auth --paste manually
guilds returns API errorToken expired / invalidRe-auth; check status
sync reports "upsert message"Local DB missing channel rowsync now auto-upserts; re-run
search returns emptyNo archive yetdiscord sync-all -l 200 first
Rate-limited (429s)Too many requestsWait; reduce -l; check stats

Limitations

  • User-token automation violates Discord ToS β€” accounts can be banned. Use sparingly.
  • guild-search is per-guild (Discord's native search has no global scope).
  • sync stores text content; attachments/embeds are not downloaded (extendable).
  • Gateway tail/watch require a live connection; --once fetches a bounded window.
  • MCP send_message is intentionally not auto-approved in clients β€” agents must request approval.

FAQ

Q: Why user token instead of a bot?
A bot only sees channels it's invited to. A user token sees everything you belong to β€” that's the whole point of an account-level CLI for an agent.

Q: Will I get banned?
Automating a user account violates ToS and bans are possible. This tool is designed to reduce risk (real-client headers, bounded reads, invisible presence) but cannot eliminate it. Use on accounts you control.

Q: How do I get a token?
discord auth --save scans your local Discord/Chrome LevelDB. Or discord auth --paste and paste it from DevTools β†’ Network β†’ Authorization header.

Q: Where is my data stored?
SQLite at the platform data dir ($LOCALAPPDATA/discord-cli/ on Windows, ~/.local/share/discord-cli/ on Linux, ~/Library/Application Support/discord-cli/ on macOS). Override with DB_PATH.

Q: Can an AI agent use this?
Yes β€” that's the primary design. --json/JSONL everywhere, discord serve for MCP, and AGENTS.md documents the playbook.

Q: Does it work on Windows?
Yes β€” built and tested on Windows, macOS, and Linux. Single static binary, no CGO.

Q: How do I stop watch/tail?
Ctrl+C. They run until interrupted.


Development

bash
cargo build          # debug
cargo test           # 109 unit/integration tests (no network required)
./scripts/e2e.sh     # real-token smoke (needs DISCORD_TOKEN)
./scripts/e2e_admin.sh  # admin/mod flow (needs DISCORD_TOKEN + administered server)

Repo layout: research clones in .tmp/ (source of truth for patterns), plan in COMPREHENSIVEPLANFORDISCORDCLI.md, task graph in .beads/.


Solves "I can't have an AI read my Discord" β€” by being the account, not a guest.