Skip to content

feat(messaging): add Discord bot as a messaging channel - #960

Open
roccoren wants to merge 15 commits into
craft-ai-agents:mainfrom
roccoren:feat/discord-messaging-channel
Open

feat(messaging): add Discord bot as a messaging channel#960
roccoren wants to merge 15 commits into
craft-ai-agents:mainfrom
roccoren:feat/discord-messaging-channel

Conversation

@roccoren

@roccoren roccoren commented Jul 9, 2026

Copy link
Copy Markdown

Summary

Adds Discord as a first-class messaging channel alongside Telegram, WhatsApp, and Lark. A user connects a Discord bot token; sessions can then be bound to Discord DMs and server (guild) text channels with the full PlatformAdapter capability set (text, message editing, inline buttons, file uploads, typing).

Implements the high-priority Discord ask from #584.

Architecture

Mirrors the WhatsApp isolation model: a new @craft-agent/messaging-discord-worker package runs discord.js v14 in a Node subprocess, speaking NDJSON over stdio to a DiscordAdapter in messaging-gateway. Router, bindings, access-control, commands, and pending-senders are all platform-agnostic and reused unchanged.

What's included

  • New worker package @craft-agent/messaging-discord-worker: NDJSON protocol (with round-trip tests) + discord.js worker (login, DM/@mention detection, attachment download, button interactions, send/edit/typing) + esbuild self-contained bundle.
  • Gateway adapter DiscordAdapter (editing/buttons/files/typing; 2000-char max) + formatForDiscord + Router guild-trigger gate honoring a per-binding discordGuildTrigger ('mention' | 'all'; DMs always route).
  • Registry full lifecycle: token validation (GET /users/@me), connect/disconnect/forget, runtime state transitions.
  • Protocol/server-core: TEST_DISCORD / SAVE_DISCORD RPC channels + handlers.
  • Electron UI: DiscordConnectDialog (bot token + Message Content Intent hint), icon, settings card, and 'telegram'|'whatsapp'|'lark' union extensions.
  • Build: dev / packaged / headless pipelines build and ship the Discord worker; electron-builder extraResources (mac/win/linux).
  • i18n/docs: settings.messaging.discord.* keys across all 7 locales (sorted, parity-clean) + doc-links.
  • Design docs: spec + implementation plan under docs/superpowers/.

Setup (for reviewers testing)

  1. Discord Developer Portal → create Application + Bot → copy Bot Token.
  2. Bot → Privileged Gateway Intents → enable Message Content Intent.
  3. Invite the bot (bot scope + Send Messages) to a server.
  4. Settings → Messaging → Discord → Connect → paste token → Test → Save.
  5. DM the bot or @mention it in a channel, then /new / /bind.

Verification

  • discord-worker (4), messaging-gateway (248), routing, ipc-channels, channel-map-parity tests pass.
  • tsc --noEmit clean across worker/gateway/server-core/server/shared/electron.
  • i18n parity + sorted pass; worker bundles and passes node --check.
  • Read-only code review found no high-confidence bugs.

Out of scope (v1)

Threads/forum channels, slash-command registration, reactions/voice.

roccoren added 11 commits July 9, 2026 02:05
New @craft-agent/messaging-discord-worker package: stdio protocol with
round-trip tests and a discord.js-backed worker runtime supporting text,
edit, buttons, files, typing, and inbound message/interaction relay.
…ger config

- PlatformType, AdapterCapabilities.markdown, MessagingConfig.platforms += discord
- BindingConfig.discordGuildTrigger ('mention' | 'all', default 'mention')
- DiscordAdapter spawns the discord worker; real editMessage/sendButtons/
  clearButtons/typing; incoming + button_press translation with bot drop
- formatForDiscord (heading downgrade, fence-aware)
- IncomingMessage.isDM/mentionedBot; Router guild-trigger gate honoring
  BindingConfig.discordGuildTrigger
- adapter + format + router trigger tests
- registry options.discord (workerEntry/nodeBin); WorkspaceState.discord
- testDiscordCredentials (GET /users/@me), saveDiscordCredentials,
  tryConnectDiscord, onDiscordEvent runtime transitions
- discord added to init/updateConfig/disconnect/runtime iteration + isKnownPlatform
- export DiscordAdapter/parseDiscordCredentials from package index
- channels.ts + routing.ts classification
- IMessagingGatewayRegistry test/saveDiscordCredentials
- server-core RPC handlers mirroring Lark
- update ipc-channels wire-format snapshot test
…pipeline

- channel-map + ElectronAPI: test/saveDiscordCredentials
- electron main + headless server pass discord.workerEntry
- bootstrap forwards optional discord config
- dev/packaged/server build pipelines build + ship messaging-discord-worker
- electron-builder extraResources (mac/win/linux)
- DiscordConnectDialog (bot token + Message Content Intent hint)
- discord.svg icon + MessagingPlatformIcon registration
- Discord platform card in MessagingSettingsPage
- extend 'telegram|whatsapp|lark' unions with 'discord' across renderer
- settings.messaging.discord.* keys across all 7 locales (sorted, parity-clean)
- doc-links messaging summary lists Discord
@roccoren
roccoren force-pushed the feat/discord-messaging-channel branch from 6c947da to f2eeb72 Compare July 10, 2026 04:20
roccoren and others added 4 commits July 11, 2026 09:50
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: b2433dd5-b479-4f5f-82cd-67ec49f3b7e0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant