Discord inbound slash commands (Ed25519-verified) - #7
Merged
Conversation
Completes the bot's Discord story (was outbound-only) by reusing the entire command router — only a new transport. - apps/bot/src/discord.ts: Ed25519 signature verification (wraps Discord's raw 32-byte hex public key in the SPKI DER prefix for node:crypto), interaction parsing (PING, application commands — text from the first string option or the command name; user id from member.user or top-level user), and response builders (PONG, ephemeral message, deferred). 8 unit tests. - apps/bot/src/index.ts: POST /discord/interactions — verify, answer PING, route commands through handleCommand. With DISCORD_APP_ID set, defers (acks then edits the reply) so slow LLM commands stay within Discord's 3s window. - env/compose/.env-example: DISCORD_PUBLIC_KEY, DISCORD_APP_ID. - docs/bot.md: Discord now documented as inbound + outbound. Verification: 107 tests pass (87 core + 20 bot incl. 8 new); typecheck + lint clean; bot bundle builds. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
Bugbot is not enabled for this team, so this pull request was not reviewed. Enable Bugbot in the Cursor dashboard to get automatic reviews on future PRs. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Completes the bot's Discord story — it was outbound-only (webhook digests/alerts). Inbound reuses the entire command router; this is just a new transport.
apps/bot/src/discord.ts— Ed25519 signature verification (wraps Discord's raw 32-byte hex public key in the fixed SPKI DER prefix sonode:cryptoaccepts it), interaction parsing (PING handshake; application commands — text from the first string option so/pointbot query:<text>works, or the command name so per-action/portfolioworks; user id frommember.useror top-leveluserfor DMs), and response builders (PONG, ephemeral message, deferred). 8 unit tests.POST /discord/interactions— verify → answer PING → route throughhandleCommand. WithDISCORD_APP_IDset it defers (ack now, edit the reply via the webhook) so a slow LLM command stays within Discord's 3-second window; otherwise replies inline.DISCORD_PUBLIC_KEY,DISCORD_APP_IDin env / compose /.env-example.docs/bot.mdnow documents Discord inbound + outbound.Verification
🤖 Generated with Claude Code