Annotation 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:
-
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(...); } -
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 -
Optional Element Summary
Optional Elements