public static enum Command.CooldownScope extends java.lang.Enum<Command.CooldownScope>
Enums used for defining the scope size for a
Command's cooldown.
The purpose for these values is to allow easy, refined, and generally convenient keys
for cooldown scopes, allowing a command to remain on cooldown for more than just the user
calling it, with no unnecessary abstraction or developer input.
Cooldown keys are generated via Command#getCooldownKey(CommandEvent) using 1-2 Snowflake ID's corresponding to the name
(IE: USER_CHANNEL uses the ID's of the User and the Channel from the CommandEvent).
However, the issue with generalizing and generating like this is that the command may
be called in a non-guild environment, causing errors internally.
To prevent this, all of the values that contain "GUILD" in their name default
to their "CHANNEL" counterparts when commands using them are called outside of a
Guild environment.
GUILD defaults to
CHANNEL.USER_GUILD defaults to
USER_CHANNEL.ShardManager.
Command.cooldownScope| Enum Constant and Description |
|---|
CHANNEL
Applies the cooldown to the
MessageChannel the
command is called in. |
GLOBAL
Applies this cooldown globally.
|
GUILD
Applies the cooldown to the
Guild the command is called in. |
SHARD
Applies the cooldown to the calling Shard the command is called on.
|
USER
Applies the cooldown to the calling
User across all
locations on this instance (IE: TextChannels, PrivateChannels, etc). |
USER_CHANNEL
Applies the cooldown to the calling
User local to the
MessageChannel the command is called in. |
USER_GUILD
Applies the cooldown to the calling
User local to the
Guild the command is called in. |
USER_SHARD
Applies the cooldown to the calling
User on the Shard
the command is called on. |
| Modifier and Type | Method and Description |
|---|---|
static Command.CooldownScope |
valueOf(java.lang.String name)
Returns the enum constant of this type with the specified name.
|
static Command.CooldownScope[] |
values()
Returns an array containing the constants of this enum type, in
the order they are declared.
|
public static final Command.CooldownScope USER
User across all
locations on this instance (IE: TextChannels, PrivateChannels, etc).
The key for this is generated in the format
<command-name>|U:<userID>
public static final Command.CooldownScope CHANNEL
MessageChannel the
command is called in.
The key for this is generated in the format
<command-name>|C:<channelID>
public static final Command.CooldownScope USER_CHANNEL
User local to the
MessageChannel the command is called in.
The key for this is generated in the format
<command-name>|U:<userID>|C:<channelID>
public static final Command.CooldownScope GUILD
Guild the command is called in.
The key for this is generated in the format
<command-name>|G:<guildID>
NOTE: This will automatically default back to CooldownScope.CHANNEL
when called in a private channel. This is done in order to prevent internal
NullPointerExceptions from being thrown while generating cooldown keys!
public static final Command.CooldownScope USER_GUILD
User local to the
Guild the command is called in.
The key for this is generated in the format
<command-name>|U:<userID>|G:<guildID>
NOTE: This will automatically default back to CooldownScope.CHANNEL
when called in a private channel. This is done in order to prevent internal
NullPointerExceptions from being thrown while generating cooldown keys!
public static final Command.CooldownScope SHARD
The key for this is generated in the format
<command-name>|S:<shardID>
NOTE: This will automatically default back to CooldownScope.GLOBAL
when JDA#getShardInfo() returns null.
This is done in order to prevent internal NullPointerExceptions
from being thrown while generating cooldown keys!
public static final Command.CooldownScope USER_SHARD
User on the Shard
the command is called on.
The key for this is generated in the format
<command-name>|U:<userID>|S:<shardID>
NOTE: This will automatically default back to CooldownScope.USER
when JDA#getShardInfo() returns null.
This is done in order to prevent internal NullPointerExceptions
from being thrown while generating cooldown keys!
public static final Command.CooldownScope GLOBAL
As this implies: the command will be unusable on the instance of JDA in all types of
MessageChannels until the cooldown has ended.
The key for this is <command-name>|globally
public static Command.CooldownScope[] values()
for (Command.CooldownScope c : Command.CooldownScope.values()) System.out.println(c);
public static Command.CooldownScope valueOf(java.lang.String name)
name - the name of the enum constant to be returned.java.lang.IllegalArgumentException - if this enum type has no constant with the specified namejava.lang.NullPointerException - if the argument is null