Application Command Rejection Handler
Processes application command rejections returned by application command filters.
Requirements
Register your instance as a service with @BService.
Implement either handle (Java) or handleSuspend (Kotlin).
Acknowledge the interaction when it is rejected.
Example - Replying the error string returned by the ApplicationCommandFilter example
@BService
class MyApplicationCommandRejectionHandler : ApplicationCommandRejectionHandler<String> {
override suspend fun handleSuspend(event: GenericCommandInteractionEvent, commandInfo: ApplicationCommandInfo, userData: String) {
event.reply_(userData, ephemeral = true).await()
}
}
Content copied to clipboard
@BService
public class MyApplicationCommandRejectionHandler implements ApplicationCommandRejectionHandler<String> {
@Override
public void handle(@NotNull GenericCommandInteractionEvent event, @NotNull ApplicationCommandInfo commandInfo, @NotNull String userData) {
event.reply(userData).setEphemeral(true).queue();
}
}
Content copied to clipboard
Parameters
T
Type of the error object returned by ApplicationCommandFilter
See also
Functions
Link copied to clipboard
open fun handle(event: GenericCommandInteractionEvent, commandInfo: ApplicationCommandInfo, userData: T)
Link copied to clipboard
open suspend fun handleSuspend(event: GenericCommandInteractionEvent, commandInfo: ApplicationCommandInfo, userData: T)