-
Notifications
You must be signed in to change notification settings - Fork 12
Filters
You can create filters, that can cancel the command execution:
public class ExampleFilter implements Filter {
@Override
public void apply(@NotNull CommandContext context) {
if (condition) {
context.setCancelled(true);
context.setErrorMessage(new MessageBuilder().append("Error Message").build());
return;
}
}
}
Register your filter at the jda-commands instance and specify the filter position:
jdaCommands.getFilterRegistry().register(new ExampleFilter(), FilterRegistry.FilterPosition.BEFORE_ROUTING);
The following positions are available:
-
BEFORE_ROUTING
- Filter will be executed before command routing. The command will not be present in the CommandContext -
BEFORE_ADAPTING
- Filter will be executed before type adapting. The command will be present in the CommandContext but not the type adapted input. -
BEFORE_EXECUTION
- Filter will be executed just before the command execution.
This wiki is the documentation for V3
(text commands)! If you're using V4
(interactions) please refer to the new documentation
Important
This wiki is the documentation for V3
(text commands)! If you're using V4
(interactions) please refer to the new documentation