Skip to main content

Discord CLI for AI agents

Project description

discli

A command-line interface for Discord, built for AI agents and humans. Manage servers, send messages, react, handle DMs, threads, and monitor events — all from the terminal.

Install

# macOS/Linux
curl -fsSL https://raw.githubusercontent.com/DevRohit06/discli/main/installers/install.sh | bash

# Windows (PowerShell)
irm https://raw.githubusercontent.com/DevRohit06/discli/main/installers/install.ps1 | iex

Or with pip:

pip install discord-cli-agent

Requires Python 3.10+.

Setup

  1. Create a bot at Discord Developer Portal
  2. Enable all privileged intents (Presence, Server Members, Message Content)
  3. Add the bot to your server with appropriate permissions
  4. Configure your token:
# Option A: Save to config
discli config set token YOUR_BOT_TOKEN

# Option B: Environment variable
export DISCORD_BOT_TOKEN=YOUR_BOT_TOKEN

# Option C: Pass directly
discli --token YOUR_BOT_TOKEN server list

Usage

Every command supports --json for machine-readable output.

Messages

discli message send #general "Hello world!"
discli message send #general "Check this out" --embed-title "News" --embed-desc "Big update"
discli message list #general --limit 20
discli message get #general 123456789
discli message reply #general 123456789 "Thanks for your question!"
discli message edit #general 123456789 "Updated text"
discli message delete #general 123456789

Direct Messages

discli dm send alice "Hey, need help?"
discli dm send 123456789 "Sent by user ID"
discli dm list alice --limit 10

Reactions

discli reaction add #general 123456789 👍
discli reaction remove #general 123456789 👍
discli reaction list #general 123456789

Channels

discli channel list --server "My Server"
discli channel create "My Server" new-channel --type text
discli channel create "My Server" voice-room --type voice
discli channel info #general
discli channel delete #old-channel

Threads

discli thread create #general 123456789 "Support Ticket"
discli thread list #general
discli thread send 987654321 "Following up on your issue"

Servers

discli server list
discli server info "My Server"

Roles

discli role list "My Server"
discli role create "My Server" Moderator --color ff0000
discli role assign "My Server" alice Moderator
discli role remove "My Server" alice Moderator
discli role delete "My Server" Moderator

Members

discli member list "My Server" --limit 100
discli member info "My Server" alice
discli member kick "My Server" alice --reason "Spam"
discli member ban "My Server" alice --reason "Repeated violations"
discli member unban "My Server" alice

Typing Indicator

discli typing #general                # 5 seconds (default)
discli typing #general --duration 10  # 10 seconds

Live Event Monitoring

# Listen to everything
discli listen

# Filter by server/channel
discli listen --server "My Server" --channel #general

# Filter by event type
discli listen --events messages,reactions

# Include bot messages (ignored by default)
discli listen --include-bots

# JSON output for piping to an agent
discli listen --json --events messages

Supported event types: messages, reactions, members, edits, deletes

Resolving Identifiers

All commands accept both IDs and names:

Type By ID By Name
Channel 123456789 #general
Server 123456789 My Server
Member 123456789 alice
Role 123456789 Moderator
Thread 123456789 Support Ticket
User (DM) 123456789 alice

JSON Output

Add --json to any command for machine-readable output:

$ discli message list #general --limit 1 --json
[
  {
    "id": "123456789",
    "author": "alice",
    "content": "Hello!",
    "timestamp": "2026-03-14T10:32:00+00:00"
  }
]

$ discli listen --json
{"event": "message", "server": "My Server", "channel": "general", "channel_id": "111", "author": "alice", "author_id": "222", "content": "hello", "message_id": "333", "mentions_bot": false, "attachments": [], ...}

Examples

Ready-to-run examples in the examples/ directory:

Example Description
claude_agent.py AI support agent powered by Claude Agent SDK — persistent session, loads instructions from agents/discord-agent.md
support_agent.py Keyword-based support bot that replies to @mentions
thread_support_agent.py Creates a thread per support request and continues conversations inside
moderation_bot.py Watches for banned words, warns users, kicks after repeated violations
channel_logger.sh Logs all messages from a channel to a JSONL file
reaction_poll.sh Creates a poll with emoji reactions

Agent Instructions

The agents/discord-agent.md file contains the full discli command reference for AI agents. Drop it into any agent's system prompt — works with Claude, OpenAI, LangChain, or any framework.

Quick start — Claude Agent

pip install discord-cli-agent claude-agent-sdk
discli config set token YOUR_BOT_TOKEN
python examples/claude_agent.py

Uses your existing Claude Code authentication — no API key needed.

Quick start — Bash agent loop

discli --json listen --events messages | while read -r event; do
  mentions_bot=$(echo "$event" | jq -r '.mentions_bot')
  if [ "$mentions_bot" = "true" ]; then
    channel_id=$(echo "$event" | jq -r '.channel_id')
    message_id=$(echo "$event" | jq -r '.message_id')
    discli typing "$channel_id" --duration 3 &
    discli message reply "$channel_id" "$message_id" "Hello! How can I help?"
  fi
done

Project Structure

discli/
├── src/discli/          # CLI source code
│   ├── cli.py           # Root click group
│   ├── client.py        # Async discord.py wrapper
│   ├── config.py        # Token storage
│   ├── utils.py         # Output formatting, resolvers
│   └── commands/        # Command groups (message, channel, role, etc.)
├── agents/              # Agent instruction files
│   └── discord-agent.md # Full discli reference for AI agents
├── examples/            # Ready-to-run agent examples
├── installers/          # Install scripts (curl-friendly)
├── tests/               # Unit tests
└── pyproject.toml

Configuration

Config is stored at ~/.discli/config.json.

discli config set token YOUR_TOKEN
discli config show
discli config show --json

Token resolution order: --token flag > DISCORD_BOT_TOKEN env var > config file.

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

discord_cli_agent-0.2.0.tar.gz (17.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

discord_cli_agent-0.2.0-py3-none-any.whl (20.0 kB view details)

Uploaded Python 3

File details

Details for the file discord_cli_agent-0.2.0.tar.gz.

File metadata

  • Download URL: discord_cli_agent-0.2.0.tar.gz
  • Upload date:
  • Size: 17.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for discord_cli_agent-0.2.0.tar.gz
Algorithm Hash digest
SHA256 b19c18c5e9e5466acaef378acac5cba13e881faf3a3ac87e70923e4deeb46080
MD5 4c4d3759cd74b4f9249a17a66bbfe565
BLAKE2b-256 48b195b6fe6903e671da137e3c81d7255248aee8c97289899699d6d890e91c64

See more details on using hashes here.

Provenance

The following attestation bundles were made for discord_cli_agent-0.2.0.tar.gz:

Publisher: release.yml on DevRohit06/discli

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file discord_cli_agent-0.2.0-py3-none-any.whl.

File metadata

File hashes

Hashes for discord_cli_agent-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 57ed4e7827d52f2eacb5f6e0e7b9c3a78cfae0836e870aa6441e434132a74e4a
MD5 0c3756ea5a50ab5a64069840cf8830e5
BLAKE2b-256 ae1282d2a2394cf76f4393841bb6bb9c0dc77732415816f7ffd7ff9523fd39b4

See more details on using hashes here.

Provenance

The following attestation bundles were made for discord_cli_agent-0.2.0-py3-none-any.whl:

Publisher: release.yml on DevRohit06/discli

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page