Skip to content

Channel: Discord Adapter #9

Open

Description

@ggondim

Summary

Implement the Discord channel adapter using Vercel Chat SDK. Discord validates another thread model (Discord threads / forum channels) and message components.

Tasks

  • Register Discord bot (token, gateway intents)
  • Inbound: message create, slash commands, mentions
  • Outbound: text, embeds, message components (buttons, select menus)
  • Thread support: Discord threads / forum channels (1:1 mapping)
  • A2H inline (method 1): Discord buttons and select menus as message components
  • Response capture (method 2): component interactions, thread replies
  • Report capabilities: { threads: true, buttons: true, selectMenus: true, replyMessages: false, dms: true, fileUpload: true }
  • Integration tests with Discord test server (manual/CI-optional)

Acceptance Criteria

  • Adapter implements full ChannelAdapter interface
  • Inbound messages from Discord are correctly parsed
  • Discord threads map 1:1 with OpenThreads threads
  • A2H intents render correctly with Discord components
  • Passes shared adapter conformance test suite

Dependencies

References

Activity

  1. claude commented on Apr 10, 2026

    @claude

    @claude Implement this issue. Follow these steps precisely:

    1. Checkout the base branch and create your working branch:
      git fetch origin meta/17 && git checkout meta/17 && git checkout -b claude/17-9-discord-adapter
    2. Implement all tasks listed in this issue
    3. Commit and push your branch:
      git push -u origin claude/17-9-discord-adapter
    4. Create a PR targeting meta/17:
      gh pr create --base meta/17 --head claude/17-9-discord-adapter --title "Channel: Discord Adapter" --body "fixes Channel: Discord Adapter #9"
  2. claude commented on Apr 10, 2026

    @claude

    Claude finished @claude[bot]'s task in 8m 48s —— View job • claude/issue-9-20260410-2205 • Create PR ➔


    Implementing Discord Channel Adapter

    • Read CLAUDE.md and gather repo context (read VISION.md for architecture)
    • Branch setup — working on claude/issue-9-20260410-2205 (cannot fetch/checkout meta/17 in sandbox; implemented on current branch targeting meta/17 in PR)
    • Implement Discord adapter package
      • Package scaffolding (package.json, tsconfig.json)
      • Core types and ChannelAdapter interface (src/types.ts)
      • Inbound: message create, slash commands, @mentions (src/inbound/)
      • Outbound: text, embeds, message components (src/outbound/)
      • Thread support: Discord threads / forum channels (src/threads/)
      • A2H inline rendering — buttons (AUTHORIZE) + select menus (COLLECT w/ options)
      • Response capture — awaitResponse() resolves on component interaction or thread reply
      • Capabilities reporting: { threads, buttons, selectMenus, dms, fileUpload: true; replyMessages: false }
      • Unit tests + conformance tests (src/__tests__/)
    • Commit and push (claude/issue-9-20260410-2205)
    • PR created (see link below)

    Implementation summary

    packages/channels/discord/ — 15 new files, ~700 lines of TypeScript

    File Purpose
    src/types.ts All types incl. ChannelAdapter, DiscordAdapterConfig, A2H types
    src/adapter.ts DiscordAdapter class — main entry point
    src/inbound/messages.ts parseMessage — Discord messages → IncomingMessage
    src/inbound/commands.ts parseSlashCommand — slash command interactions
    src/outbound/text.ts Plain text message sending
    src/outbound/embeds.ts Styled embeds for each A2H intent
    src/outbound/components.ts buildA2HComponents, approve/deny buttons, select menus
    src/threads/index.ts getThread, createThread, ensureThreadActive
    src/__tests__/adapter.test.ts Unit tests for parsing + components + embeds
    src/__tests__/conformance.test.ts ChannelAdapter interface conformance tests

    Note: gh pr create requires approval in the current sandbox. Please create the PR using the link below, or approve the gh pr create command.

    |

  3. claude commented on Apr 10, 2026

    @claude

    @claude Implement this issue.

    • Base branch: meta/17
    • Target your PR to meta/17
    • Include fixes #9 in the PR body
  4. claude commented on Apr 10, 2026

    @claude

    Claude finished @claude[bot]'s task in 10m 18s —— View job • claude/17-issue-9-20260410-2220 • Create PR ➔


    Implementing Discord Channel Adapter

    • Read CLAUDE.md and gather repo context
    • Explore existing adapter patterns (Slack adapter studied as reference)
    • Implement Discord adapter package
      • Package scaffolding (package.json, tsconfig.json)
      • utils/components.ts — Discord embed + component builders for A2H intents
      • utils/normalize.ts — message extraction, replyTo URL, thread key helpers
      • DiscordAdapter.ts — main class: initialize/shutdown/onMessage/send/sendA2H
      • index.ts — exports
      • __tests__/DiscordAdapter.test.ts — unit + integration tests with mocks
      • __tests__/conformance.test.ts — ChannelAdapter interface conformance
    • Commit and push (claude/17-issue-9-20260410-2220)
    • Create PR targeting meta/17

    Implementation summary

    packages/channels/discord/ — 8 new files, ~1,784 lines of TypeScript

    File Purpose
    src/DiscordAdapter.ts DiscordAdapter class — main entry point (~300 lines)
    src/utils/components.ts Discord embed + component builders for A2H intents (AUTHORIZE, COLLECT, INFORM)
    src/utils/normalize.ts extractText, isBot, buildReplyToUrl, collectThreadKey helpers
    src/index.ts Package exports
    src/__tests__/DiscordAdapter.test.ts Integration tests: capabilities, send(), sendA2H INFORM/AUTHORIZE/COLLECT, inbound, slash commands, lifecycle
    src/__tests__/conformance.test.ts ChannelAdapter interface conformance + Discord capability assertions
    package.json Package manifest (@openthreads/channels-discord, deps: discord.js ^14)
    tsconfig.json TypeScript config (extends tsconfig.base.json)

    Key design:

    • All interactions routed through a single interactionCreate handler, dispatching by customId prefix: a2h_approve_<id>, a2h_deny_<id>, a2h_collect_select_<id>
    • Thread COLLECT tracked by thread:<parentChannelId>:<threadId> key — identical pattern to Slack adapter
    • Discord thread channel IDs map 1:1 to OpenThreads threadIds
    • DiscordClientLike interface allows test doubles without a real Discord connection
    • Capabilities: { threads, buttons, selectMenus, dms, fileUpload: true; replyMessages: false }

    • claude/17-issue-9-20260410-2220

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions