Skip to main content

Discord CLI for local-first sync, search, export, and agent-friendly retrieval

Project description

discord-cli

CI PyPI version License

PyPI package name: kabi-discord-cli — install with uv tool install kabi-discord-cli

中文

More Projects

  • xiaohongshu-cli — Xiaohongshu (小红书) CLI for notes and account workflows
  • twitter-cli — Twitter/X CLI for timelines, bookmarks, and posting
  • bilibili-cli — Bilibili CLI for videos, users, search, and feeds
  • tg-cli — Telegram CLI for local-first sync, search, and export

Telethon-style local-first tooling for Discord: sync messages into SQLite, search them from the terminal, export structured results, and feed them to AI agents.

discord-cli uses the Discord HTTP API with a user token from your local session. It is meant for accounts you control, on machines you control.

Warning

  • discord-cli reads a Discord user token from your local Discord/browser session.
  • Discord may restrict or suspend accounts that automate user-token traffic.
  • Use it only on your own account and only if you understand the risk.

Features

  • Local-first SQLite storage for history, sync, search, export, and analytics
  • discord dc sync-all discovers accessible text channels and bootstraps from the API
  • Query commands support --yaml and --json for scripting and AI agent integration
  • Non-TTY stdout defaults to YAML; override with OUTPUT=yaml|json|rich|auto
  • Structured output contract: SCHEMA.md

AI Agent Tip: Prefer --yaml for structured output unless a strict JSON parser is required. Use -n to limit results.

  • Safer local channel resolution for search, recent, today, export, and purge

Installation

# PyPI
uv tool install kabi-discord-cli
# or
pipx install kabi-discord-cli

# From GitHub
uv tool install git+https://github.com/jackwener/discord-cli.git

# From source
git clone git@github.com:jackwener/discord-cli.git
cd discord-cli
uv sync --extra dev

Upgrade to the latest version:

uv tool upgrade kabi-discord-cli
# Or: pipx upgrade kabi-discord-cli

Tip: Upgrade regularly to avoid unexpected errors from outdated API handling.

Quick Start

# Extract and save a token from your local Discord/browser session
discord auth --save

# Verify auth
discord status
discord whoami

# Explore guilds and channels
discord dc guilds
discord dc channels <guild_id>

# Bootstrap local storage
discord dc sync-all -n 500

# Query local cache
discord today
discord recent -n 50
discord search "rust" -c general --json
discord timeline --by hour --json

Commands

Auth & Account

Command Description
auth [--save] Extract a token from local Discord/browser session
status Check if the configured token is valid
whoami [--json] Show the current Discord profile

Discord API (discord dc ...)

Command Description
dc guilds [--json] List joined guilds
dc channels GUILD [--json] List text channels in a guild
dc history CHANNEL [-n 1000] Fetch message history for one channel
dc sync CHANNEL [-n 5000] Incrementally sync one channel
dc sync-all [-n 5000] Discover and sync accessible text channels
dc tail CHANNEL [--once] Poll and follow new messages like tail -f
dc search GUILD KEYWORD [-c CHANNEL_ID] [--json] Use Discord native search
dc members GUILD [--max 50] [--json] List guild members
dc info GUILD [--json] Show guild info

Local Query

Command Description
search KEYWORD [-c CHANNEL] [-n 50] [--json] Search locally stored messages
recent [-c CHANNEL] [--hours N] [-n 50] [--json] Show newest locally stored messages
stats [--json] Message statistics per channel
today [-c CHANNEL] [--json] Show today's messages
top [-c CHANNEL] [--hours N] [--json] Top senders
timeline [-c CHANNEL] [--hours N] [--by day|hour] [--json] Activity timeline

Data

Command Description
export CHANNEL [-f text|json] [-o FILE] [--hours N] Export stored messages
purge CHANNEL [-y] Delete stored messages for a channel

Behavior Notes

  • Most top-level query commands read from local SQLite, not directly from Discord.
  • discord dc sync-all now bootstraps by discovering guilds and channels through the API, so it works on a fresh database.
  • Channel names are resolved against the local database. If a name matches multiple channels, the CLI will stop and ask you to use a more specific name or a channel ID.

discord-cli also ships with SKILL.md for agent integration.

Development

uv sync --extra dev
uv run ruff check .
uv run python -m pytest
uv build

License

Apache-2.0

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

kabi_discord_cli-0.2.8.tar.gz (30.6 kB view details)

Uploaded Source

Built Distribution

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

kabi_discord_cli-0.2.8-py3-none-any.whl (29.5 kB view details)

Uploaded Python 3

File details

Details for the file kabi_discord_cli-0.2.8.tar.gz.

File metadata

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

File hashes

Hashes for kabi_discord_cli-0.2.8.tar.gz
Algorithm Hash digest
SHA256 05760cdeb6c4b92a2e5ad7bffc0172669b596a5acec5ab8b901261c3f1931261
MD5 800f826323d6d3fe34704ca06c841937
BLAKE2b-256 08e2e435a78d24965061fa36a04bb3aafffbde4f3fd74733ae5121fa19d60434

See more details on using hashes here.

Provenance

The following attestation bundles were made for kabi_discord_cli-0.2.8.tar.gz:

Publisher: publish.yml on jackwener/discord-cli

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

File details

Details for the file kabi_discord_cli-0.2.8-py3-none-any.whl.

File metadata

File hashes

Hashes for kabi_discord_cli-0.2.8-py3-none-any.whl
Algorithm Hash digest
SHA256 a26e80c125d9a5d5ad58c3e4e439ba7c8c1ac8e77b3434c10b1e0fee172c32d5
MD5 dda0c2001c1255609f01fcf67bec8f05
BLAKE2b-256 d5ee7af354c1c93ec9ec0cfaf7eed75bfd21b2f9c31cefad628f7af2bb81c9ee

See more details on using hashes here.

Provenance

The following attestation bundles were made for kabi_discord_cli-0.2.8-py3-none-any.whl:

Publisher: publish.yml on jackwener/discord-cli

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