Skip to main content

npm

Source

See the Plugins guide for how plugins from wolfstar-project/plugins fit alongside the core framework.
WolfStar

@wolfstar/plugin-subcommands-advanced

Modular slash subcommands for @wolfstar/http-framework.version downloads license

Description

Plugin for @wolfstar/http-framework that lets you split slash subcommands (and subcommand groups) into separate command classes, instead of putting every handler method on the parent. Adapted from @kaname-png/plugin-subcommands-advanced for WolfStar’s HTTP interaction framework.

Installation

Requires Node.js >=22.0.0.

Usage

Import the register entrypoint before creating the client:

Activating with modules

On framework 6.1 and later, list the ./module entry in modules in stars.config instead of importing register. It needs the optional @wolfstar/kit peer dependency, at ^0.2.0 || ^0.3.0.
The module takes no options. It reserves the subcommandsAdvanced key of stars.config for future options, so no other module can claim it. Configure the package through ClientOptions.subcommandsAdvanced, as shown above. Without the stars CLI, pass the ./plugin definePlugin factory to the plugins client option:
Use only one of the module, the ./plugin factory, and register. Combining them installs the plugin’s hooks twice. Recommended layout:

Parent command

Direct subcommand

Grouped subcommand

Constructor options (no decorators)

Typed options

Command.OptionsOf<'path'> and Subcommand.OptionsOf<'path'> type a handler’s options from the CommandOptionsRegistry that stars codegen generates. They re-export the framework’s Command.OptionsOf, so you can use them without importing Command from @wolfstar/http-framework. Key the type by the full command path, including the parent and group names:
These types require @wolfstar/http-framework 6.2.0 or later. On an older framework, the type fails to resolve when you type-check with skipLibCheck off.
See Typed command options for how to enable codegen.commands and generate the registry.

How it works

@wolfstar/http-framework routes subcommands to methods on the parent command instance. This plugin:
  1. Lets child command classes register themselves into in-memory registries (by parent name).
  2. After all command pieces are constructed, rebuilds the parent’s chat-input resolver and CommandRouter, installing thin delegate methods that call each child’s chatInputRun.
You do not need to call the optional hooks.subcommands / hooks.groups helpers unless you are registering the parent imperatively and want to attach builders yourself.

Notes

  • HTTP-only: there is no message-command support (unlike the Sapphire original).
  • Child classes should not use @RegisterCommand — only the parent registers the top-level slash command.
  • Subcommand groups must still be declared on the parent (via @RegisterCommand builder or registerApplicationCommands).