Repository navigation
Description
Context
Split out of #207, which tracks the ApplicationCommand structure itself. This issue tracks the managers that create, fetch and edit application commands and their permissions, ported from discord.js (main):
ApplicationCommandManagerApplicationCommandPermissionsManagerGuildApplicationCommandManager, a thin subclass of the first one bound to a guild (guild.commands).
None of them exists in @wolfstar/plugin-gateway. They depend on client.application (#208) for the application ID and on the ApplicationCommand structure (#207).
Proposal
ApplicationCommandManager (client.application.commands)
A cached manager of ApplicationCommands, global by default, with an optional guildId on every method:
fetch(options?): one command by ID (cache,force,guildId), or every command (guildId,localesent asX-Discord-Locale,withLocalizations).create(command, guildId?):POSTto the commands route.set(commands, guildId?): bulk overwrite withPUT, returning the new collection.edit(command, data, guildId?)anddelete(command, guildId?).permissions: the permissions manager below.commandPath({ id, guildId })picks amongapplicationCommands,applicationCommand,applicationGuildCommandsandapplicationGuildCommand.static transformCommand(command): camel-casedApplicationCommandDatato the API payload (localizations, options,default_member_permissions,integration_types,contexts,handler). It also accepts a builder throughtoJSON().- Types:
ApplicationCommandResolvable,ApplicationCommandDataResolvable,FetchApplicationCommandOptions.
GuildApplicationCommandManager (guild.commands)
The same manager with the guild fixed, and its own permissions manager.
ApplicationCommandPermissionsManager
Reachable from three places, which decide which of guild and command the options must carry: application.commands.permissions, guild.commands.permissions and command.permissions.
fetch({ guild, command }): the permissions of one command, or of every command of the guild as a collection keyed by command ID.set({ guild, command, permissions, token }): replaces them.add({ guild, command, permissions, token }): merges into the existing ones.remove({ guild, command, users, roles, channels, token }).has({ guild, command, permissionId, permissionType }).permissionsPath(guildId, commandId?)picks betweenapplicationCommandPermissionsandguildApplicationCommandsPermissions.- Types:
ApplicationCommandPermissions, the edit/remove/has option types,RolePermissionConstantandChannelPermissionConstant(the@everyoneand "all channels" IDs derived from the guild ID).
The writes (set, add, remove) need a bearer token: discord.js sends them with auth: false and an Authorization: Bearer <token> header, because Discord refuses the bot token there. fetch and has use the bot token.
Errors
New GatewayError codes for the cases discord.js throws: ApplicationCommandPermissionsTokenMissing, GlobalCommandPermissions (permissions need a guild), GuildUncachedEntityResolve (resolving a role or channel without the guild), and the InvalidType/InvalidElement type errors for bad resolvables.
Events
APPLICATION_COMMAND_PERMISSIONS_UPDATE is the only gateway event in this area. Check whether plugin-gateway already emits applicationCommandPermissionsUpdate, and with which payload.
Questions
- Cache. discord.js caches commands in the manager, but no gateway event keeps that cache in sync (commands have no create/update/delete dispatch). Cached through
@wolfstar/plugin-cache(new entity type), or fetch-only? - Framework overlap.
@wolfstar/http-frameworkregisters commands on its own.set()is a bulk overwrite, so it would delete whatever the framework registered. Decide whether the manager is read-mostly here, or documented as an alternative to the framework's registration. - Resolving roles and channels.
removeandhasresolve roles and channels through the guild's caches in discord.js. With an asynchronous cache this cannot be synchronous: accept IDs and structures only, or fetch through the managers? - Bearer token. Is the permissions write path worth porting at all, given it needs an OAuth2 token with
applications.commands.permissions.updatethat a bot process normally does not have?
Out of scope
The ApplicationCommand structure and ApplicationEmoji (#207), ClientApplication (#208), and interaction structures.
Activity
pullfrog commentedon Oct 5, 2026
This run croaked 😵
The workflow encountered an error before any progress could be reported. Please check the link below for details.