Skip to main content

discord-cli

Headless, JSON-first Discord CLI for AI agents, shell scripts, cron jobs, and CI/CD.

PyPI version PyPI Downloads License: MIT Python 3.9+ CI skills.sh

Current release: 1.7.0 (PyPI)

64 commands across 13 groups — manage channels, categories, roles, permissions, members, messages, threads, webhooks, invites, search, and JSON/CSV exports from one command-line binary. No long-running bot daemon. No MCP tool-schema context bloat.


Why discord-cli?

  • Built for AI coding agents without MCP overhead — ships with a prompt-injection-hardened skills.sh skill for Claude Code, Codex, Cursor, and GitHub Copilot. Load instructions on demand instead of injecting dozens of tool schemas into every turn.
  • JSON-first by default, human tables on demand — every command returns {"ok": true, "data": ...} (or {"ok": false, "error": {...}} with exit code 1) for clean jq pipelines and agent parsing. Add --human for Rich terminal tables.
  • Headless & fire-and-exit — authenticates with a Discord bot token, executes one command, prints the payload, and exits. Drop it straight into GitHub Actions, cron jobs, or shell scripts.
  • Extensible & offline-documented — add custom command groups via Python entry-point plugins (discord_cli.plugins), and read the full auto-generated reference offline with man discord-cli.

Example output

$ discord-cli guild info
{
  "ok": true,
  "data": {
    "id": 123456789012345678,
    "name": "Engineering HQ",
    "member_count": 42,
    "channel_count": 18,
    "role_count": 9,
    "verification_level": "medium"
  }
}

Pipe directly into jq:

# Find the ID of #announcements and post a release message
CHANNEL_ID=$(discord-cli channel list | jq -r '.data.channels[] | select(.name == "announcements") | .id')
discord-cli message send "$CHANNEL_ID" --content "v1.4.0 deployed to production"

Install

Package vs. command name: The PyPI distribution is discordcli-agents; the installed executable is discord-cli.

# Using uv (fastest)
uv tool install discordcli-agents

# Or using pipx
pipx install discordcli-agents

# Or standard pip
pip install discordcli-agents

Homebrew (macOS / Linux)

brew install 1solomonwakhungu/tap/discordcli-agents

Windows (Scoop manual manifest)

A CI-synced Scoop manifest is provided in packaging/scoop/ for local/manual installs.

Offline manual page

A man page ships with the Python package:

man discord-cli

If your virtualenv prefix is not on MANPATH:

man "$(python -c 'import sysconfig; print(sysconfig.get_path("data"))')/share/man/man1/discord-cli.1"

Use with AI Agents (Claude Code, Codex, Cursor, Copilot)

Install the bundled discord-cli-server-management skill via the open skills CLI:

npx skills add 1solomonwakhungu/discord-cli --skill discord-cli-server-management

Once installed (with DISCORD_BOT_TOKEN in your environment or .env), ask your agent things like:

  • "Audit channel permission overwrites across the server and flag anything open to @everyone."
  • "Create a Releases category with #changelog and #alerts channels, and post today's release notes."
  • "Export the last 500 messages from #support to JSON and summarize recurring user issues."

The published skill includes explicit prompt-injection guardrails instructing agents to treat retrieved Discord messages, usernames, topics, and embeds as untrusted data. See docs/ai-agents.md for full integration patterns.


Quick setup (2 minutes)

  1. Create an application and bot in the Discord Developer Portal and copy the Bot Token.
  2. Under Bot → Privileged Gateway Intents, enable Server Members Intent and Message Content Intent if you use member listing/search or message search/export. (Non-privileged commands automatically fall back if privileged intents are disabled.)
  3. Invite the bot to your server with the permissions your workflows need.
  4. Provide your token via environment variable or a local .env file:
export DISCORD_BOT_TOKEN="your-bot-token-here"
# Optional: default server when the bot is in multiple guilds
export DISCORD_GUILD_ID="123456789012345678"

Verify connectivity:

discord-cli --human guild info

Quick start

# Inspect server & channels (JSON by default; pass --human before the subcommand for Rich tables)
discord-cli guild info
discord-cli --human channel list

# Create a category and a channel inside it
CAT_ID=$(discord-cli category create "Releases" | jq -r '.data.created.id')
discord-cli channel create "announcements" --type text --category "$CAT_ID" --topic "Release updates"

# Send a plain or embed message
discord-cli message send 123456789012345678 --content "Deploy finished!"
discord-cli message send 123456789012345678 --embed-json '{"title":"Release v1.4.0","color":5763719}'

# Search messages or members (positional query)
discord-cli search messages "deployment" --channel-id 123456789012345678 --limit 25
discord-cli search members "alice"

# Export channel history to JSON or extract CSV
discord-cli export channel 123456789012345678 --limit 500 --format json > history.json
discord-cli export channel 123456789012345678 --limit 500 --format csv | jq -r '.data.data' > history.csv

# Create a role and assign channel permission overwrites
ROLE_ID=$(discord-cli role create "Ops" --color "#3498db" --mentionable --hoist | jq -r '.data.created.id')
discord-cli permissions set --channel 123456789012345678 --role "$ROLE_ID" --allow "view_channel,send_messages"

# Preview inactive member pruning safely (dry-run defaults to true)
discord-cli guild prune --days 30

Command reference (64 commands, 13 groups)

Global options (placed before the command group): --token TEXT, --guild INTEGER, --human, --version.

Group Commands What it covers
channel list, create, delete, edit, move, info Text, voice, stage, and forum channels
category list, create, delete, edit Channel category organization
role list, create, delete, edit, assign, remove, info Server roles, colors, permissions, assignments
member list, info, kick, ban, unban, timeout, untimeout, nickname, roles Member lookup and moderation
message list, send, edit, delete, purge, fetch, pin, unpin, react Messaging, embeds, reactions, bulk purge
guild info, edit, emojis {list,create,delete}, stickers list, bans list, regions, prune Server profile, emojis, stickers, bans, pruning
permissions list, set, reset Per-channel role/member permission overwrites
webhook list, create, delete, info Channel webhook management
invites list, create, delete Server invite links with max-age/max-uses/temporary
threads list, create, delete, archive, unarchive, members Public/private threads and thread membership
search messages, members Substring search across channel history or members
export channel Export channel history as JSON or CSV
plugins list Inspect loaded third-party discord_cli.plugins

Recipes & Automation

Copy-paste workflows in docs/recipes.md:

  • GitHub Actions deployment & release notifications
  • Cron nightly server snapshots and channel exports
  • Bulk role & permission provisioning scripts
  • Claude Code / Codex terminal-agent shell and Python wrappers

Extending with Plugins

Third-party Python packages can register new top-level command groups via the discord_cli.plugins entry-point group. Broken plugins log a warning and never crash built-in commands. See docs/plugins.md and examples/plugin-hello/.


Documentation


License

MIT License — see LICENSE.

Metadata

Release files for discordcli-agents 1.7.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for discordcli-agents 1.7.0
File Size Uploaded Provenance Actions
discordcli_agents-1.7.0.tar.gz 87.9 kB With provenance Details for discordcli_agents-1.7.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for discordcli-agents 1.7.0
File Interpreter ABI Platform Actions
discordcli_agents-1.7.0-py3-none-any.whl Python 3 none any Details for discordcli_agents-1.7.0-py3-none-any.whl

Total release size: 138.4 kB

Release files / discordcli_agents-1.7.0.tar.gz

Download URL discordcli_agents-1.7.0.tar.gz
Size 87.9 kB
Tags Source
SHA-256 checksum
How to use checksums
4456549bc536688061ea0950b398f60c00cab36abcb522055e2e34269e091b3d
BLAKE2b-256 checksum
How to use checksums
71df083d7517cda158bc90e8f82ad2421ed94b50a89ae08493dca947659af269
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 24, 2026.

Transparency log

Release files / discordcli_agents-1.7.0-py3-none-any.whl

Download URL discordcli_agents-1.7.0-py3-none-any.whl
Size 50.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
94747183b9be85c1a602788c219a4356660b78b9428a2c7a1b81ed0e5aca6c59
BLAKE2b-256 checksum
How to use checksums
b1d59a91360e387f0fb47707ac336f6a1ddee6379658885a876d4d23f771b581
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 24, 2026.

Transparency log

Security for discordcli-agents 1.7.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for discordcli_agents-1.7.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 24, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page