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 protected
RoleJavacord(boolean exact, long roleId)
Constructs a new role restriction for checking the role ID.protected
RoleJavacord(boolean exact, String roleName)
Constructs a new role restriction for checking the role name case-sensitively against a fixed name.protected
RoleJavacord(boolean exact, String roleName, boolean caseSensitive)
Constructs a new role restriction for checking the role name against a fixed name.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.protected
RoleJavacord(long roleId)
Constructs a new role restriction for checking the role ID for an exact role match.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.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.protected
RoleJavacord(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 boolean
allowCommand(CommandContext<? extends Message> commandContext)
Returns whether a command caused by the given command context should be allowed by this restriction or not.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface net.kautler.command.api.restriction.Restriction
getRealClass
-
-
-
-
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(CommandContext<? extends Message> commandContext)
Description copied from interface:Restriction
Returns whether a command caused by the given command context should be allowed by this restriction or not.- Specified by:
allowCommand
in interfaceRestriction<Message>
- Parameters:
commandContext
- the command context, usually fully populated- Returns:
- whether a command caused by the given command context should be allowed by this restriction or not
-
-