Run slash commands from mentions - #10
Merged
Merged
Conversation
@-ing the bot now behaves as a slash command when the first word matches a registered command (e.g. `@lynn ping`), falling back to the AI agent otherwise. Commands bypass the lynn-ai-agent flag. Decouples Command.execute from APIInteraction by introducing CommandContext/CommandResult, so the gateway and the interactions handler share one command contract.
Preview DeployedURL: https://dbaa77a3-lynn-lynn-pr-10-lme3gt3xx5pglzfy.amitavnott.workers.dev Built from commit a9f63cf This comment updates automatically with each push. |
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
@-ing the bot now behaves as a slash command when the first word after the mention matches a registered command name, falling back to the AI agent otherwise.
@lynn ping(also@lynn /ping) → runs the/pingcommand, replies "Pong!"@lynn what is a duck?→ no matching command, so the question goes to the agentChanges
src/discord/types.ts— decoupleCommand.executefromAPIInteractionby introducingCommandContext(channelId?,userId?,args) andCommandResult(content,ephemeral?), so the gateway and interactions handler share one contract.src/discord/commands/ping.ts— updated to the newexecutesignature.src/discord/interactions.ts— maps the interaction to aCommandContextand wraps the result in aChannelMessageWithSourceresponse. Slash command behavior unchanged.src/discord/gateway.ts—parseMentionCommandmatches the first token (optional leading/, case-insensitive) against registered commands; on a match it runs the command and posts the reply via the channel API, otherwise falls through to the existing flagship-gated agent path.README.md— documents mention-dispatch behavior.Behavior notes
lynn-ai-agentfeature flag; only the agent fallback is gated.args(available to commands, currently unused byping).Verification
pnpm exec tsc --noEmitpassespnpm lint(oxlint) passesNeed help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.