-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Labels
priority: normalnormal prioritynormal prioritytype: experimentaladdition of an experimental featureaddition of an experimental feature
Description
Create the @Option.Bind annotation that can be placed before a method parameter (of a @Slash.Handler) and that binds the option to the parameter. This allows the option to be passed as typed parameter to shortcut the traditional JDA way of getting the options.
Note: In case the options cannot be mapped to the parameter type, the method would not be called.
Note: In case an option is a union type (as for the
MENTIONABLE), it would be possible to create multiple@Slash.Handlermethods with different parameter types for the option. The api would then call the most appropriate method.
Note: A default value (for non-required options only) should be added to the
@Option.Bind.
Example
For a simple kick command, the current way of writing it
@Slash.Handler()
public void kick(SlashCommandEvent event) {
final User user = Objects.requireNonNull(event.getOption("user")).getAsUser();
final String reason = Objects.requireNonNull(event.getOption("reason")).getAsString();
...
}would become
@Slash.Handler()
public void kick(SlashCommandEvent event, @Option.Bind("user") User user, @Option.Bind("reason") String reason) {
...
}Metadata
Metadata
Assignees
Labels
priority: normalnormal prioritynormal prioritytype: experimentaladdition of an experimental featureaddition of an experimental feature