Repository navigation
feat(plugin-gateway): add ApplicationCommand and its managers - #252
Conversation
Architecture Inside the changed components — 1 viewComponent view — Application Commands Internal managers, structures, and external REST interactions for application commands and permissions. Data flow The other flows — 1 sequence
Review ✨ Nothing flagged · reviewed Tip The CLI's 🪧 More tips
Thanks for using PR Lens! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out on X, Bluesky, Mastodon, Reddit or LinkedIn |
There was a problem hiding this comment.
ℹ️ No critical issues — two minor suggestions inline.
Reviewed changes
Reviewed the full single-commit diff of the fetch-only ApplicationCommand structure and its managers in @wolfstar/plugin-gateway.
ApplicationCommandstructure: camel-cased getters, in-placeedit()/set*(),delete(),permissions,equals(),optionsEqual()andtransformOption().ApplicationCommandManager/GuildApplicationCommandManager:fetch,create,set,edit,delete,commandPathandtransformCommand, going throughclient.api.applicationCommands(withclient.restonly for the localized fetch).ApplicationCommandPermissionsManager: cache-awarefetch/has, and token-gatedset/add/remove.- Wiring:
client.application.commands,guild.commands,client.guilds.commands(id), the widened resolvable types, two new error codes, exports, README and changeset. - Tests: 47 mocked-REST tests and a type-level consumption test.
claude-sonnet-5-5 | 𝕏
Adds the fetch-only ApplicationCommandManager (client.application.commands), the GuildApplicationCommandManager (guild.commands), the ApplicationCommand structure with equals() and optionsEqual(), and the ApplicationCommandPermissionsManager, whose writes take an explicit bearer token and whose reads use the applicationCommandPermissions cache.
…e the command helpers
0b761e3 to
b785711
Compare
@wolfstar/plugin-api
@wolfstar/plugin-broker
@wolfstar/plugin-cache
@wolfstar/plugin-gateway
@wolfstar/plugin-i18next
@wolfstar/plugin-logger
@wolfstar/plugin-scheduled-tasks
@wolfstar/plugin-sharder
@wolfstar/plugin-subcommands-advanced
commit: |
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
Reviewed what changed since the prior pullfrog review (0b761e3): one follow-up commit that addresses both earlier suggestions, plus a rebase onto main.
- Raw guild commands routed correctly:
ApplicationCommandManager#edit()and#delete()now use a sharedcommandGuildId()that readsguildId ?? guild_id, so a rawAPIApplicationCommandwithguild_idhits the guild endpoint. A new test covers both methods. - Shared helpers:
Loose,firstDefinedandcompactmoved intoutil/applicationCommands.tsand are imported by bothApplicationCommand.tsandApplicationCommandManager.ts. - Rebase onto
main:ClientApplication,managers/index.tsandtypes.tsnow sit alongside the entitlement and subscription managers from #253; the imports and exports are consistent.
claude-sonnet-5-5 | 𝕏

🔗 Linked issue
Closes #209
Refs #207 (the
ApplicationCommandhalf;ApplicationEmojiis #250)🧭 Context
@wolfstar/plugin-gatewayhas no counterpart of discord.js'sApplicationCommand,ApplicationCommandManager,GuildApplicationCommandManagerandApplicationCommandPermissionsManager, so a process can neither read nor manage its application commands, andApplicationCommand#equals()could not be ported with the rest of #203. They hang offclient.application(#208, merged in #238). The structure and its managers ship together because the structure'sedit()/delete()go through the manager and the manager returns the structure.📚 Description
Everything follows Pullfrog's plan on #207 and the decisions taken on it:
plugin-cacheentity type. The existingapplicationCommandPermissionsstore is the only cached piece, andfetch/hasof the permissions manager read it for one command (unlessforce), while fetches and writes keep it up to date.set()is kept (bulk overwrite) and documented in the TSDoc and the README as replacing whatever@wolfstar/http-frameworkregistered. Nothing calls it automatically.token(the OAuth2 bearer token), passed toeditGuildCommandPermissions(userToken, ...). There is no OAuth handling; without a token they throwGatewayErrorApplicationCommandPermissionsTokenMissing. Roles and channels are IDs or structures only, nothing is resolved through the guild.@discordjs/core'sApplicationCommandsAPI, with one exception:fetch({ locale })sendsX-Discord-Locale, which the core API cannot carry, so that call usesclient.restdirectly.Where I departed from the plan or from discord.js:
fetchtakes nocache/forceoptions, since there is no cache to skip.GuildUncachedEntityResolvewas not added: with IDs/structures only there is no code path that could throw it.InvalidType/InvalidElementalready exist. The new codes areApplicationCommandPermissionsTokenMissingandGlobalCommandPermissions.nulllocalizations are sent asnull(they remove localizations). discord.js'snameLocalizations ?? name_localizationsdrops them.defaultMemberPermissions: undefinedleaves the permissions alone in an edit, where discord.js would send"0".ApplicationCommand#edit()patches the structure in place (likeGuildEmoji#edit) and clears the optional fields the API no longer returns.delete()of the manager resolves tovoidsince nothing is cached.equals()andoptionsEqual()returnfalsefor a foreign argument instead of throwing.ApplicationCommandResolvablenow also accepts theApplicationCommandstructure, andApplicationCommandDataResolvablecamel-casedApplicationCommandData(both were declared intypes.tsalready).plugin-gatewaydoes not emit anapplicationCommandPermissionsUpdateevent today (the dispatch only updates the cache); this PR does not add one.Key changes
structures/applications/ApplicationCommand.tsApplicationCommandwith the command fields,edit(),set*(),delete(),permissions,equals(), staticoptionsEqual()andtransformOption(), plus the option/data typesmanagers/ApplicationCommandManager.tsfetch,create,set,edit,delete,commandPath, statictransformCommand(camel-cased data, raw payloads, builders throughtoJSON())managers/GuildApplicationCommandManager.tsmanagers/ApplicationCommandPermissionsManager.tsfetch,has,set,add,remove,permissionsPathClientApplication,Guild,GuildManagerclient.application.commands,guild.commands,client.guilds.commands(guildId)(a new instance on every access)errors/Messages.ts,types.ts, indexestests/application-commands.test.ts,tests/types/application-commands.ts@wolfstar/plugin-gatewayType of Change
Pre-flight Checklist
pnpm changeset(orpnpm changeset add --emptyif no release is needed). See .changeset/README.md.Verification (run locally in this order):
pnpm lint(exit 0, format check clean),pnpm build(9/9 tasks),pnpm typecheck(exit 0),pnpm test(122 files, 1759 tests passed).