{"id":51442867,"url":"https://github.com/zachlagden/discordctl","last_synced_at":"2026-07-05T13:01:50.124Z","repository":{"id":365787815,"uuid":"1273767175","full_name":"zachlagden/discordctl","owner":"zachlagden","description":"Control a Discord server from the command line — a localhost command bus and dctl CLI for full, dry-run-safe bot-driven server management.","archived":false,"fork":false,"pushed_at":"2026-07-03T17:07:23.000Z","size":719,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-07-03T19:09:34.638Z","etag":null,"topics":["automation","cli","command-bus","devops","discord","discord-bot","discord-py","python","server-management","uv"],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/zachlagden.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":"AGENTS.md","dco":null,"cla":null}},"created_at":"2026-06-18T21:16:23.000Z","updated_at":"2026-07-03T17:07:19.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/zachlagden/discordctl","commit_stats":null,"previous_names":["zachlagden/discordctl"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/zachlagden/discordctl","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zachlagden%2Fdiscordctl","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zachlagden%2Fdiscordctl/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zachlagden%2Fdiscordctl/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zachlagden%2Fdiscordctl/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zachlagden","download_url":"https://codeload.github.com/zachlagden/discordctl/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zachlagden%2Fdiscordctl/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":35154748,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-07-05T02:00:06.290Z","response_time":100,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["automation","cli","command-bus","devops","discord","discord-bot","discord-py","python","server-management","uv"],"created_at":"2026-07-05T13:01:49.460Z","updated_at":"2026-07-05T13:01:50.092Z","avatar_url":"https://github.com/zachlagden.png","language":"Python","funding_links":["https://github.com/sponsors/zachlagden"],"categories":[],"sub_categories":[],"readme":"\u003cdiv align=\"center\"\u003e\n\n# discordctl\n\n**Control a Discord server from the command line — full, bot-driven server management with dry-run-by-default safety.**\n\n[![License](https://img.shields.io/github/license/zachlagden/discordctl?style=flat-square)](LICENCE)\n[![Stars](https://img.shields.io/github/stars/zachlagden/discordctl?style=flat-square)](https://github.com/zachlagden/discordctl/stargazers)\n[![Last Commit](https://img.shields.io/github/last-commit/zachlagden/discordctl?style=flat-square)](https://github.com/zachlagden/discordctl/commits/main)\n[![Issues](https://img.shields.io/github/issues/zachlagden/discordctl?style=flat-square)](https://github.com/zachlagden/discordctl/issues)\n\n![Python](https://img.shields.io/badge/Python-3.11+-3776AB?style=flat-square\u0026logo=python\u0026logoColor=white)\n![discord.py](https://img.shields.io/badge/discord.py-2.x-5865F2?style=flat-square\u0026logo=discord\u0026logoColor=white)\n![uv](https://img.shields.io/badge/uv-managed-DE5FE9?style=flat-square\u0026logo=astral\u0026logoColor=white)\n![Docker](https://img.shields.io/badge/Docker-ready-2496ED?style=flat-square\u0026logo=docker\u0026logoColor=white)\n\n[Setup](docs/SETUP.md) · [Live smoke test](docs/SMOKE.md) · [Report Bug](https://github.com/zachlagden/discordctl/issues) · [Request Feature](https://github.com/zachlagden/discordctl/issues)\n\n\u003c/div\u003e\n\n---\n\n## What is discordctl?\n\n`discordctl` turns a Discord bot into a scriptable command-line control plane for your server. A\npersistent [discord.py](https://discordpy.readthedocs.io/) daemon holds the gateway connection and\nexposes a **localhost-only HTTP command bus**; the `dctl` CLI drives that bus over the shell — so you\n(or an automation, or an AI coding agent) can ban and edit members, manage roles, channels, categories,\npermissions, messages, threads, emojis, invites, and webhooks. **179 operations** in all, covering the\nwhole management surface.\n\nIt was built to let an AI agent administer a server safely, so safety is the headline: **every mutating\noperation is dry-run by default** and requires an explicit `--confirm`, writes are bounded by a guild\nallowlist and a global kill switch, and every call is appended to an audit log.\n\n---\n\n## Features\n\n| Feature | Description |\n| --- | --- |\n| **179 operations** | Guild, channel, category, role, member, message, permissions, thread, emoji, invite, and webhook management — driven as `dctl op \u003cname\u003e`. |\n| **Dry-run by default** | Every mutation previews what it *would* do and changes nothing until you pass `--confirm`. The client cannot bypass this. |\n| **Guarded \u0026 auditable** | Guild allowlist, `WRITE_ENABLED` kill switch, owner-ban refusal, `--yes-really` for destructive ops, and an append-only JSONL audit log of every call. |\n| **Declarative state** | `guild.snapshot` → `guild.diff` → `guild.apply`: capture the server to JSON, edit it, apply the difference. |\n| **Localhost-only bus** | The control bus binds `127.0.0.1`, trusts only loopback peers, and authenticates every request with a constant-time bearer check. |\n\n---\n\n## Quick Start\n\n### 1. Clone \u0026 install\n\n```bash\ngit clone https://github.com/zachlagden/discordctl.git\ncd discordctl\nuv sync\n```\n\n### 2. Configure\n\n```bash\ncp .env.example .env\n# Set DISCORD_TOKEN, BUS_TOKEN, ALLOWED_GUILD_IDS, DEFAULT_GUILD_ID\n```\n\nGenerate the bot invite URL and authorize it into your server (see [docs/SETUP.md](docs/SETUP.md) for\nthe full walkthrough, including the required privileged intents):\n\n```bash\nuv run python scripts/invite_url.py \u003cCLIENT_ID\u003e\n```\n\n### 3. Run \u0026 drive it\n\n```bash\nuv run python -m discordctl                               # or: docker compose up -d\n\nuv run dctl health\nuv run dctl ops\nuv run dctl op guild.info\nuv run dctl op role.create --arg name=example             # dry-run (preview only)\nuv run dctl op role.create --arg name=example --confirm   # executes\n```\n\n---\n\n## How it works\n\n```\nyou / a script / an agent\n        │  shell\n        ▼\n      dctl  ──HTTP POST /v1/op (bearer, 127.0.0.1)──►  control bus (aiohttp)\n        ▲                                                   │\n        │  JSON                                             ▼\n        └──────────────────────────────────────  op registry → handler → discord.py\n                                                            │\n                                                            ▼\n                                                       Discord API\n```\n\nThe daemon stays connected to the gateway (warm cache, bot shows online). `dctl` is stateless and talks\nto the bus over loopback. For mutating ops the **server** decides the effective dry-run state from\n`confirm` + `WRITE_ENABLED` — a crafted request body can't force a live write.\n\n---\n\n## Tech Stack\n\n| Layer | Technology |\n| --- | --- |\n| **Gateway daemon** | Python 3.11+, discord.py 2.x |\n| **Control bus** | aiohttp (localhost), pydantic v2 |\n| **CLI** | `dctl` (stdlib argparse + urllib) |\n| **Tests / quality** | pytest, pytest-asyncio, ruff |\n| **Deploy / observability** | Docker, Docker Compose, Sentry |\n\n---\n\n## Project Structure\n\n```\nsrc/discordctl/\n├── __main__.py        # python -m discordctl -\u003e runs the daemon\n├── config.py          # env-driven configuration\n├── schemas.py         # OpRequest / OpResponse\n├── daemon/            # discord.py client + aiohttp control bus\n├── ops/\n│   ├── registry.py    # @op decorator, BusContext, dry-run plan()\n│   ├── lookup.py      # entity resolution + guild allowlist\n│   ├── serialize.py   # discord objects -\u003e JSON\n│   ├── audit.py       # append-only audit writer\n│   └── handlers/      # one module per domain (179 ops)\n└── cli/dctl.py        # the CLI\ndocs/                  # SETUP.md, SMOKE.md, design spec \u0026 plan\n```\n\n---\n\n## Configuration\n\nLoaded from `.env` (gitignored — never commit real values).\n\n| Variable | Purpose |\n| --- | --- |\n| `DISCORD_TOKEN` | Bot token (all privileged intents required) |\n| `BUS_TOKEN` | 256-bit hex bearer token for the control bus |\n| `BUS_HOST` / `BUS_PORT` | Bus bind address (keep loopback) / port |\n| `ALLOWED_GUILD_IDS` | Comma-separated guild allowlist (empty disables it) |\n| `DEFAULT_GUILD_ID` | Guild used when an op omits `guild_id` |\n| `WRITE_ENABLED` | Global kill switch; `false` forces every mutation to dry-run |\n| `AUDIT_PATH` | Path to the append-only audit log |\n| `SENTRY_DSN` | Optional Sentry DSN |\n\n---\n\n## Star History\n\n\u003ca href=\"https://star-history.com/#zachlagden/discordctl\u0026Date\"\u003e\n \u003cpicture\u003e\n   \u003csource media=\"(prefers-color-scheme: dark)\" srcset=\"https://api.star-history.com/svg?repos=zachlagden/discordctl\u0026type=Date\u0026theme=dark\" /\u003e\n   \u003csource media=\"(prefers-color-scheme: light)\" srcset=\"https://api.star-history.com/svg?repos=zachlagden/discordctl\u0026type=Date\" /\u003e\n   \u003cimg alt=\"Star History Chart\" src=\"https://api.star-history.com/svg?repos=zachlagden/discordctl\u0026type=Date\" /\u003e\n \u003c/picture\u003e\n\u003c/a\u003e\n\n---\n\n## Support\n\nIf this project is useful to you, consider supporting development:\n\n\u003ca href=\"https://github.com/sponsors/zachlagden\"\u003e\n  \u003cimg src=\"https://img.shields.io/badge/Sponsor_on_GitHub-ea4aaa?style=for-the-badge\u0026logo=github\u0026logoColor=white\" alt=\"Sponsor on GitHub\" /\u003e\n\u003c/a\u003e\n\n---\n\n## License\n\nThis project is licensed under the MIT License — see the [LICENCE](LICENCE) file for details.\n\n---\n\n\u003cdiv align=\"center\"\u003e\n\n**[Report Bug](https://github.com/zachlagden/discordctl/issues)** · **[Request Feature](https://github.com/zachlagden/discordctl/issues)**\n\nMade by [Zach Lagden](https://github.com/zachlagden)\n\n\u003c/div\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzachlagden%2Fdiscordctl","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzachlagden%2Fdiscordctl","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzachlagden%2Fdiscordctl/lists"}