Annotation Interface Subcommand


@Retention(RUNTIME) @Target({}) public @interface Subcommand
Defines a subcommand for slash commands.

Example:

@SlashCommand(
    name = "config",
    description = "Plugin configuration",
    subcommands = {
        @Subcommand(name = "view", description = "View settings"),
        @Subcommand(name = "set", description = "Change setting", options = {
            @CommandOption(name = "key", description = "Setting name", required = true),
            @CommandOption(name = "value", description = "New value", required = true)
        })
    }
)
public void config(SlashCommandInteractionEvent event) {
    String sub = event.getSubcommandName();
    // ...
}
  • Required Element Summary

    Required Elements
    Modifier and Type
    Required Element
    Description
    Returns the description of the subcommand.
    Returns the name of the subcommand.
  • Optional Element Summary

    Optional Elements
    Modifier and Type
    Optional Element
    Description
    Returns the command options associated with this subcommand.
  • Element Details

    • name

      String name
      Returns the name of the subcommand.
      Returns:
      the name of the subcommand as a String
    • description

      String description
      Returns the description of the subcommand.
      Returns:
      the description of the subcommand as a String
    • options

      CommandOption[] options
      Returns the command options associated with this subcommand. These options define the parameters that can be passed to the subcommand.
      Returns:
      an array of CommandOption annotations representing the options for this subcommand, or an empty array if no options are defined
      Default:
      {}