Class RoleJavacord
- java.lang.Object
-
- net.kautler.command.api.restriction.javacord.RoleJavacord
-
- All Implemented Interfaces:
Restriction<Message>
public abstract class RoleJavacord extends Object implements Restriction<Message>
A restriction that allows a command for certain roles and is evaluated by the Javacord command handler. To use it, create a trivial subclass of this class and make it a discoverable CDI bean, for example by annotating it with@ApplicationScoped.
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedRoleJavacord(boolean exact, long roleId)Constructs a new role restriction for checking the role ID.protectedRoleJavacord(boolean exact, String roleName)Constructs a new role restriction for checking the role name case-sensitively against a fixed name.protectedRoleJavacord(boolean exact, String roleName, boolean caseSensitive)Constructs a new role restriction for checking the role name against a fixed name.protectedRoleJavacord(boolean exact, Pattern rolePattern)Constructs a new role restriction for checking the role name against a regular expression for an exact role match.protectedRoleJavacord(long roleId)Constructs a new role restriction for checking the role ID for an exact role match.protectedRoleJavacord(String roleName)Constructs a new role restriction for checking the role name case-sensitively against a fixed name for an exact role match.protectedRoleJavacord(String roleName, boolean caseSensitive)Constructs a new role restriction for checking the role name against a fixed name for an exact role match.protectedRoleJavacord(Pattern rolePattern)Constructs a new role restriction for checking the role name against a regular expression for an exact role match.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanallowCommand(Message message)Returns whether a command caused by the given message should be allowed by this restriction or not.
-
-
-
Constructor Detail
-
RoleJavacord
protected RoleJavacord(long roleId)
Constructs a new role restriction for checking the role ID for an exact role match.- Parameters:
roleId- the ID of the role for which a command should be allowed
-
RoleJavacord
protected RoleJavacord(String roleName)
Constructs a new role restriction for checking the role name case-sensitively against a fixed name for an exact role match.- Parameters:
roleName- the case-sensitive name of the role for which a command should be allowed
-
RoleJavacord
protected RoleJavacord(String roleName, boolean caseSensitive)
Constructs a new role restriction for checking the role name against a fixed name for an exact role match.- Parameters:
roleName- the name of the role for which a command should be allowedcaseSensitive- whether the name should be matched case-sensitively or not
-
RoleJavacord
protected RoleJavacord(Pattern rolePattern)
Constructs a new role restriction for checking the role name against a regular expression for an exact role match.- Parameters:
rolePattern- the pattern against which the role name is matched to determine for whom a command should be allowed
-
RoleJavacord
protected RoleJavacord(boolean exact, long roleId)Constructs a new role restriction for checking the role ID.- Parameters:
exact- whether the role needs to be matched exactly or whether a higher role would also be sufficientroleId- the ID of the role for which a command should be allowed
-
RoleJavacord
protected RoleJavacord(boolean exact, String roleName)Constructs a new role restriction for checking the role name case-sensitively against a fixed name.- Parameters:
exact- whether the role needs to be matched exactly or whether a higher role would also be sufficientroleName- the case-sensitive name of the role for which a command should be allowed
-
RoleJavacord
protected RoleJavacord(boolean exact, String roleName, boolean caseSensitive)Constructs a new role restriction for checking the role name against a fixed name.- Parameters:
exact- whether the role needs to be matched exactly or whether a higher role would also be sufficientroleName- the name of the role for which a command should be allowedcaseSensitive- whether the name should be matched case-sensitively or not
-
RoleJavacord
protected RoleJavacord(boolean exact, Pattern rolePattern)Constructs a new role restriction for checking the role name against a regular expression for an exact role match.- Parameters:
exact- whether the role needs to be matched exactly or whether a higher role would also be sufficientrolePattern- the pattern against which the role name is matched to determine for whom a command should be allowed
-
-
Method Detail
-
allowCommand
public boolean allowCommand(Message message)
Description copied from interface:RestrictionReturns whether a command caused by the given message should be allowed by this restriction or not.- Specified by:
allowCommandin interfaceRestriction<Message>- Parameters:
message- the message that caused the command to check allowance for- Returns:
- whether a command caused by the given message should be allowed by this restriction or not
-
-