feat: add slash command equivalents for all commands#63
Open
davelindsay84 wants to merge 1 commit into
Open
Conversation
Implement /s, /score, /trending, /leader, and /configdump as Discord slash commands alongside the existing !-prefixed commands, which continue to work. - commands.js: SlashCommandBuilder schema + handleInteraction dispatcher, reusing the same primitives as the message path - deploy-commands.js: registration script (npm run deploy), guild-scoped via GUILD_ID or global; derives the app ID from the bot token - index.js: interactionCreate listener with error handling - config.js: add GuildId (GUILD_ID) - replacer.js: export isBlockedPhrase for the /s blocked-phrase gate - __tests__/commands.test.js: handler coverage for every command - CLAUDE.md: document slash commands, modules, and GUILD_ID Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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
Implements every command as a Discord slash command alongside the existing
!-prefixed commands, which continue to work unchanged. Passive scoring (phrase++,✨phrase✨) is untouched.!s <search>/<replacement>/s search:<text> replacement:<text>(omitreplacementto delete)!score <phrase>/score phrase:<text>!trending/trending!leader <emoji>/leader emoji:<emoji>!configDump/configdump(lowercase — Discord requires it)Changes
commands.js(new) —slashCommandsschema (SlashCommandBuilder) +handleInteractiondispatcher. Handlers reuse the same primitives as the message path (replaceFirstMessage,getScore,getTrending,getLeaderboard,registerProxyMessage,oneBlockedMessage).deploy-commands.js(new) — registration script (npm run deploy). Guild-scoped whenGUILD_IDis set (instant), else global. App ID is derived from the bot token — no extra env var.index.js—interactionCreatelistener with error handling (ephemeral "something broke" fallback).config.js— addsGuildIdfromGUILD_ID.replacer.js— exportsisBlockedPhraseso/scan gate blocked phrases directly.__tests__/commands.test.js(new) — handler coverage for every command.CLAUDE.md— documents slash commands, new modules, andGUILD_ID.Behavior notes
/sdefers (history fetch can exceed Discord's 3s window), routes the quote throughinteraction.editReplyso the bot's reply is the quote, and registers the reaction-credit proxy exactly like!s.!path stays silent (blocked phrases) the slash path must acknowledge, so it replies ephemerally ("nope"); a disabled/configdumplikewise replies ephemerally.Deploying
Set
GUILD_IDin.env, runnpm run deployonce, and ensure the bot was invited with theapplications.commandsOAuth scope.Testing
npm test— 153 passing, coverage thresholds metnpm run lint— clean🤖 Generated with Claude Code