-
Notifications
You must be signed in to change notification settings - Fork 0
Decorators
Decorators allow for you to call another method, before invoking the action using the decorator pattern. In doing so, you can restrict, or modify how the action is called. It's also possible to add multiple decorators to one action, allowing you to extensively enhance the functionality of an action with very little work.
Halpbot currently has 3 built-in decorators that can be used on any public method annotated with: @ButtonAction, @Command, @CustomParameter:
This decorator allows you to specify a period of time that a user must wait before being able to invoke an action again. If the user is still cooling down it will temporarily display a MessageEmbed telling you how many seconds you have to wait before you can use the action again.
Example usages:
@Cooldown(duration = @Duration(30))
@Command(description = "Tests the @Cooldown decorator")
public String cooldown() {
return "This command has a 30 second cooldown!";
}@Cooldown(duration = @Duration(value = 1, unit = ChronoUnit.MINUTES))
@Command(description = "Tests the @Cooldown decorator")
public String cooldown() {
return "This command has a 1 minute cooldown!";
}The @Permission decorator allows you to specify which permissions a user must have if they want to invoke an action. If the user does not have all the specified permissions, then the action won't be invoked and a MessageEmbed will be temporarily displayed informing you that you lack the permissions to use the action.
Permissions allow for role-based restrictions on who can invoke actions. For more information on how they work, refer to this documentation.
@Permission(HalpbotPermissions.GUILD_OWNER)
@Command(description = "Tests the @Permission decorator")
public String permission() {
return "This command is restricted to people with the *halpbot.owner.guild* permission";
}@Permission({"halpbot.example.a", "halpbot.example.b"})
@Command(description = "Tests the @Permission decorator")
public String permission() {
return "This command is restricted to people with the *halpbot.example.a* and *halpbot.example.b* permissions";
}- Built-in Commands
- @Command Parameters
- Arguments
- Annotations
- Custom Objects
- Custom TypeParsers
- Slash Commands - W.I.P.
- Pagination - W.I.P