{"skill":{"slug":"discord-purge-bot","displayName":"Discord Purge Bot","summary":"Operate a Discord message cleanup workflow with an official bot token and Discord HTTP API. Use when asked to purge guild channel history, delete messages by...","description":"---\nname: discord-purge-bot\ndescription: \"Operate a Discord message cleanup workflow with an official bot token and Discord HTTP API. Use when asked to purge guild channel history, delete messages by user/keyword/time window, run dry-run previews, execute guarded bulk deletion jobs, or recreate a channel for fast wipe. Do not use for self-bot cleanup or personal DM history wipe.\"\n---\n\n# Discord Purge Bot\n\nRun controlled cleanup in Discord guild channels with safety gates and audit-friendly outputs.\n\n## Safety Contract\n\n- Use only a bot token (`DISCORD_BOT_TOKEN` or `--token`).\n- Refuse user-account token flows and self-bot behavior.\n- Run `purge-preview.mjs` first for every destructive request.\n- Require explicit confirmation code before running deletion.\n- Abort if channel is not a guild channel.\n- Keep logs and JSON summaries for each run.\n\n## Workflow\n\n1. Collect scope: `channel-id`, optional `author-id`, `contains`, `regex`, `after`, `before`.\n2. Read `references/discord-limits.md` before deletion runs.\n3. Run preview to estimate impact and get confirm code.\n4. Run deletion with confirm code.\n5. Share summary: scanned, matched, deleted, failed, old-vs-recent split.\n\n## Commands\n\n### Preview\n\n```bash\nnode scripts/purge-preview.mjs \\\n  --channel-id 123456789012345678 \\\n  --author-id 987654321098765432 \\\n  --contains \"error\" \\\n  --after \"2026-03-01T00:00:00Z\" \\\n  --max-scan 5000 \\\n  --out ./tmp/purge-preview.json\n```\n\n### Run Purge\n\n```bash\nnode scripts/purge-runner.mjs \\\n  --channel-id 123456789012345678 \\\n  --author-id 987654321098765432 \\\n  --contains \"error\" \\\n  --after \"2026-03-01T00:00:00Z\" \\\n  --confirm \"PURGE-XXXXXXXX\" \\\n  --state-file ./tmp/purge-state.json \\\n  --out ./tmp/purge-result.json\n```\n\n### Dry Run\n\n```bash\nnode scripts/purge-runner.mjs --channel-id 123456789012345678 --confirm \"PURGE-XXXXXXXX\" --dry-run\n```\n\n### Clone or Nuke Channel\n\n```bash\nnode scripts/purge-nuke.mjs --channel-id 123456789012345678 --confirm \"NUKE-XXXXXXXX\" --out ./tmp/nuke.json\nnode scripts/purge-nuke.mjs --channel-id 123456789012345678 --confirm \"NUKE-XXXXXXXX\" --delete-old --out ./tmp/nuke.json\n```\n\n## Script Roles\n\n- `scripts/purge-preview.mjs`: scan channel messages, apply filters, return counts and confirm code.\n- `scripts/purge-runner.mjs`: execute deletion with 2-week split (`bulk-delete` + single delete fallback).\n- `scripts/purge-nuke.mjs`: create replacement channel; optionally delete original channel.\n- `scripts/scan-filter.mjs`: reusable scan and filtering logic.\n- `scripts/discord-api.mjs`: Discord API wrapper with rate-limit retries.\n- `scripts/job-code.mjs`: deterministic confirm code helpers.\n\n## Operator Rules\n\n- Keep `max-scan` bounded for broad channels.\n- Use `--state-file` on long jobs.\n- Prefer content/user/time filters over whole-channel wipes.\n- Use nuke mode only when preserving channel history is unnecessary.\n- Treat pinned messages as protected unless `--include-pinned` is set.\n\n## Troubleshooting\n\n- 401/403: verify bot token and channel permissions.\n- Empty preview with expected history: check `READ_MESSAGE_HISTORY`.\n- Heavy 429: reduce parallelism and keep retry handling enabled.\n- `bulk-delete` failures: expect messages older than 14 days, runner falls back to single deletes.\n- Cannot reach Discord behind a proxy: export `HTTP_PROXY`/`HTTPS_PROXY` (uppercase recommended) and run with `NODE_USE_ENV_PROXY=1`, or use a recent Node that supports `setGlobalProxyFromEnv()`.\n- If your proxy tool exposes both HTTP and SOCKS ports, point `HTTP_PROXY`/`HTTPS_PROXY` at the HTTP port; `ALL_PROXY=socks5://...` alone is not enough for this skill.\n\n### Proxy Example\n\n```bash\nexport HTTP_PROXY=http://127.0.0.1:7890\nexport HTTPS_PROXY=http://127.0.0.1:7890\nexport NODE_USE_ENV_PROXY=1\n\nnode scripts/purge-preview.mjs --channel-id 123456789012345678 --max-scan 200\n```\n","topics":["Discord","Message"],"tags":{"latest":"0.1.2"},"stats":{"comments":0,"downloads":891,"installsAllTime":33,"installsCurrent":1,"stars":0,"versions":3},"createdAt":1772708960950,"updatedAt":1779077735213},"latestVersion":{"version":"0.1.2","createdAt":1772878503665,"changelog":"Add proxy-aware Discord API support and publish UI metadata.","license":null},"metadata":null,"owner":{"handle":"ginhoor","userId":"s176b0ks9nz7dh99ghrvwv4r9d884yft","displayName":"JunhuaShao","image":"https://avatars.githubusercontent.com/u/1681830?v=4"},"moderation":{"isSuspicious":false,"isMalwareBlocked":false,"verdict":"clean","reasonCodes":["review.llm_review"],"summary":"Review: review.llm_review","engineVersion":"v2.4.24","updatedAt":1780089792348}}