{"_id":"@dreki-gg/pi-discord","name":"@dreki-gg/pi-discord","dist-tags":{"latest":"0.2.0"},"versions":{"0.2.0":{"name":"@dreki-gg/pi-discord","version":"0.2.0","description":"Discord read tools for pi — pull channel messages and attachments for agent context with an Effect-powered bot client","keywords":["pi-package","pi","discord","messages","context"],"author":{"name":"Juan Albarran","email":"jalbarrandev@gmail.com"},"license":"MIT","repository":{"type":"git","url":"git+https://github.com/dreki-gg/pi-extensions.git","directory":"packages/discord"},"type":"module","scripts":{"typecheck":"tsc --noEmit","test":"bun test","lint":"oxlint extensions test","format":"oxfmt --write extensions test","format:check":"oxfmt --check extensions test"},"pi":{"extensions":["./extensions/discord"]},"dependencies":{"effect":"^3.16.0","@effect/platform":"^0.78.0"},"devDependencies":{"@types/node":"24","bun-types":"^1.3.14","oxfmt":"^0.43.0","oxlint":"^1.58.0","typescript":"^6.0.0"},"peerDependencies":{"@earendil-works/pi-coding-agent":"*","typebox":"*"},"peerDependenciesMeta":{"@earendil-works/pi-coding-agent":{"optional":true},"typebox":{"optional":true}},"gitHead":"3d86538d4bf92279ed000a45ee42dcd71ac11ec6","_id":"@dreki-gg/pi-discord@0.2.0","bugs":{"url":"https://github.com/dreki-gg/pi-extensions/issues"},"homepage":"https://github.com/dreki-gg/pi-extensions#readme","_nodeVersion":"26.5.0","_npmVersion":"11.17.0","dist":{"integrity":"sha512-CIlhvW+Eb9X/qOOqPSqCzkjXAmtkXsCWsRG7AQ47TiDu2c4twhjWegcVvf9Tz/5PNAC2OnfA+hFMspd4VqHvqQ==","shasum":"e2be423e7e6c4e493fabe5bb0e0c3202baa8d869","tarball":"https://registry.npmjs.org/@dreki-gg/pi-discord/-/pi-discord-0.2.0.tgz","fileCount":14,"unpackedSize":35205,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIQDbTtAiaoDNf04gyrBjbrS4XGAlJ0/rBfJj4FRMd781QgIgG3XR7KFjou0ODQ74LRAKJgDvBeWqJDZcZ70PPvsFtRc="}]},"_npmUser":{"name":"jalbarrang","email":"jalbarrandev@gmail.com"},"directories":{},"maintainers":[{"name":"jalbarrang","email":"jalbarrandev@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/pi-discord_0.2.0_1783716545780_0.729092958895645"},"_hasShrinkwrap":false}},"time":{"created":"2026-07-10T20:49:05.676Z","0.2.0":"2026-07-10T20:49:05.935Z","modified":"2026-07-10T20:49:06.189Z"},"maintainers":[{"name":"jalbarrang","email":"jalbarrandev@gmail.com"}],"description":"Discord read tools for pi — pull channel messages and attachments for agent context with an Effect-powered bot client","homepage":"https://github.com/dreki-gg/pi-extensions#readme","keywords":["pi-package","pi","discord","messages","context"],"repository":{"type":"git","url":"git+https://github.com/dreki-gg/pi-extensions.git","directory":"packages/discord"},"author":{"name":"Juan Albarran","email":"jalbarrandev@gmail.com"},"bugs":{"url":"https://github.com/dreki-gg/pi-extensions/issues"},"license":"MIT","readme":"# @dreki-gg/pi-discord\n\nDiscord read tools for [pi](https://github.com/earendil-works/pi-coding-agent) — pull channel messages and attachments so agents have product context (e.g. a `#issues-and-suggestions` channel).\n\nUses [Effect](https://effect.website) for the Discord client layer (typed errors, retries, rate limit handling). Bot-token auth only — automating a **user** account violates Discord's ToS.\n\n## Tools\n\n| Tool | Description |\n|------|-------------|\n| `discord_list_channels` | List text channels in a server (guild) the bot can access |\n| `discord_read_messages` | Read message history from a channel (oldest-first, paginate with `before`) |\n| `discord_download_attachment` | Download an image/file from a message to a temp path |\n\n> No search tool: Discord's message search is user-account-only and not available to bots.\n\n## Setup\n\n### 1. Create a Discord app + bot\n\nGo to [discord.com/developers/applications](https://discord.com/developers/applications) → **New Application** → name it (e.g. `pi-context`).\n\nIn the left sidebar → **Bot** → **Reset Token** → copy the token → this is your `DISCORD_BOT_TOKEN`.\n\n### 2. Enable the Message Content intent (required)\n\nStill on the **Bot** page → scroll to **Privileged Gateway Intents** → toggle **Message Content Intent** ON.\n\n> ⚠️ Without this, the REST API returns **empty `content`** for every message. For a bot in fewer than 100 servers this toggle needs no Discord verification.\n\n### 3. Invite the bot to your server\n\nLeft sidebar → **OAuth2** → **URL Generator**:\n\n- **Scopes**: `bot`\n- **Bot Permissions**: `View Channels`, `Read Message History`\n\nCopy the generated URL, open it, pick your server, authorize. (You need **Manage Server** permission on that server, or ask an admin.)\n\n### 4. Get guild + channel IDs\n\nIn the Discord client → **Settings → Advanced → Developer Mode** ON. Then right-click a server → **Copy Server ID** (guild), and right-click a channel → **Copy Channel ID**.\n\n### 5. Set the token\n\n```bash\nexport DISCORD_BOT_TOKEN=\"your-bot-token\"\n```\n\n## Project config (`.pi/discord.json`)\n\nAll fields optional:\n\n```json\n{\n  \"defaultGuild\": \"123456789012345678\",\n  \"defaultChannel\": \"234567890123456789\",\n  \"messageLimit\": 50\n}\n```\n\n- `defaultGuild` — used by `discord_list_channels` when you don't pass `guild`.\n- `defaultChannel` — informational (shown in `/discord` status).\n- `messageLimit` — default page size for `discord_read_messages` (1-100, default 50).\n\n## Commands\n\n- `/discord` — show token + config status.\n\n## Notes\n\n- IDs are numeric **snowflakes**.\n- The bot only sees servers it's invited to and channels where it has `View Channel` + `Read Message History`.\n- `discord_read_messages` returns newest-first from Discord but is formatted oldest-first; use the returned `oldestId` as `before` to page further back.\n- Attachment URLs are public Discord CDN links — `discord_download_attachment` fetches them without auth.\n","readmeFilename":"README.md","_rev":"1-f5e0204512304a1dea63346769f6f58d"}