Annotation Interface AutoComplete


@Target(METHOD) @Retention(RUNTIME) public @interface AutoComplete

Methods annotated with AutoComplete will be registered as a handler for AutoCompleteEvents for the given Commands.

The Commands can either be referenced by:

  1. Command Name

    If referenced by the command name the handler will handle any command thats name starts with the given name:

    @SlashCommand("favourite fruit")
    public void fruitCommand(CommandEvent event, String fruit) {
        event.reply("You've chosen: %s", fruit);
    }
    @SlashCommand("favourite vegetable")
    public void vegetableCommand(CommandEvent event, String vegetable) {
        event.reply("You've chosen: %s", vegetable);
    }
    
    @AutoComplete("favourite")
    public void onFavouriteAutoComplete(AutoCompleteEvent event) {
        event.replyChoices(...);
    }
    
  2. Method Name

    If referenced by the method name the handler will only handle the command of the given method:

    @SlashCommand("favourite fruit")
    public void fruitCommand(CommandEvent event, String fruit) {
        event.reply("You've chosen: %s", fruit);
    }
    
    @AutoComplete("fruitCommand")
    public void onFruitAutoComplete(AutoCompleteEvent event) {
        event.replyChoices(...);
    }
    

Be aware that the example above will register every command option with auto complete enabled. If you want to avoid that, you have to explicitly state the command options the handler supports:

@SlashCommand("favourite food")
public void foodCommand(CommandEvent event, String fruit, String vegetable) {
    event.reply("You've chosen: %s and %s", fruit, vegetable);
}

@AutoComplete(vale = "foodCommand", options = "fruit")
public void onFruitAutoComplete(AutoCompleteEvent event) {
    event.replyChoices(...);
}

You can have multiple auto complete handler for the same slash command, but each command option can only have exactly one handler. If an auto complete handler doesn't specify any command options, it will be registered implicitly for every command option of the given slash command(s), unless an explicit auto complete handler exists for that command option.

See Also:
  • Required Element Summary

    Required Elements
    Modifier and Type
    Required Element
    Description
    Returns the name of the slash commands this autocomplete should handle.
  • Optional Element Summary

    Optional Elements
    Modifier and Type
    Optional Element
    Description
    Returns the name of the command options this autocomplete should handle
  • Element Details

    • value

      String[] value
      Returns the name of the slash commands this autocomplete should handle.
      Returns:
      the slash commands
    • options

      String[] options
      Returns the name of the command options this autocomplete should handle
      Returns:
      the command options
      Default:
      {""}