Class CommandRegistrar

java.lang.Object
net.dv8tion.jda.api.hooks.ListenerAdapter
com.dianxin.tori.api.commands.slash.v2.controller.CommandRegistrar
All Implemented Interfaces:
EventListener

@ReleasedSince("26.8.301") public class CommandRegistrar extends ListenerAdapter
Manages registration, synchronization, and interaction routing for annotation-driven slash commands in the Tori framework.

For practical implementation patterns, refer to the reference examples:

  • ExampleCommand - Basic flat slash command declaration with optional parameters.
  • WarnCommand - Advanced structure using nested static subcommands with permission restrictions.
See Also:
  • Constructor Details

    • CommandRegistrar

      public CommandRegistrar(JavaDiscordBot bot)
      Initializes the registrar and hooks it into the bot's JDA event pipeline.
      Parameters:
      bot - the bot instance owning this registrar
  • Method Details

    • registerSlash

      public void registerSlash(Class<?>... commandClasses)
      Registers one or more command classes annotated with Command.
      Parameters:
      commandClasses - the command classes to register
    • commitAllCommands

      public void commitAllCommands(@Nullable @Nullable Guild... targetGuilds)
      Commits all registered commands to Discord.

      If target guilds are specified, updates commands exclusively for those guilds (immediate update, ideal for development/testing). If empty or null, commands are published globally.

      Parameters:
      targetGuilds - optional guild(s) for guild-scoped updates; pass empty or null for global
    • onSlashCommandInteraction

      public void onSlashCommandInteraction(@NotNull @NotNull SlashCommandInteractionEvent event)
      Overrides:
      onSlashCommandInteraction in class ListenerAdapter