Class ChannelJda
- java.lang.Object
-
- net.kautler.command.api.restriction.jda.ChannelJda
-
- All Implemented Interfaces:
Restriction<Message>
public abstract class ChannelJda extends Object implements Restriction<Message>
A restriction that allows a command in certain channels and is evaluated by the JDA 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
ChannelJda(long channelId)
Constructs a new channel restriction for checking the channel ID.protected
ChannelJda(String channelName)
Constructs a new channel restriction for checking the channel name case-sensitively against a fixed name.protected
ChannelJda(String channelName, boolean caseSensitive)
Constructs a new channel restriction for checking the channel name against a fixed name.protected
ChannelJda(Pattern channelPattern)
Constructs a new channel restriction for checking the channel name against a regular expression.
-
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
-
ChannelJda
protected ChannelJda(long channelId)
Constructs a new channel restriction for checking the channel ID.- Parameters:
channelId
- the ID of the channel where a command should be allowed
-
ChannelJda
protected ChannelJda(String channelName)
Constructs a new channel restriction for checking the channel name case-sensitively against a fixed name.- Parameters:
channelName
- the case-sensitive name of the channel where a command should be allowed
-
ChannelJda
protected ChannelJda(String channelName, boolean caseSensitive)
Constructs a new channel restriction for checking the channel name against a fixed name.- Parameters:
channelName
- the name of the channel where a command should be allowedcaseSensitive
- whether the name should be matched case-sensitively or not
-
ChannelJda
protected ChannelJda(Pattern channelPattern)
Constructs a new channel restriction for checking the channel name against a regular expression.- Parameters:
channelPattern
- the pattern against which the channel name is matched to determine where 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
-
-