Enum Class CooldownScope
- All Implemented Interfaces:
Serializable
,Comparable<CooldownScope>
,Constable
Enum
s used for defining the scope size for a
Interaction
'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 toCHANNEL
.USER_GUILD
defaults toUSER_CHANNEL
.
ShardManager
.
There is no shard magic, and no guarantees for a 100% "global" cooldown, unless all shards of the bot run under the same ShardManager, and/or via some external system unrelated to JDA-Utilities.
- Since:
- 1.3
- Author:
- Kaidan Gustave
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Enum
Enum.EnumDesc<E extends Enum<E>>
-
Enum Constant Summary
Enum ConstantDescriptionApplies the cooldown to theMessageChannel
the command is called in.Applies this cooldown globally.Applies the cooldown to theGuild
the command is called in.Applies the cooldown to the calling Shard the command is called on.Applies the cooldown to the callingUser
across all locations on this instance (IE: TextChannels, PrivateChannels, etc).Applies the cooldown to the callingUser
local to theMessageChannel
the command is called in.Applies the cooldown to the callingUser
local to theGuild
the command is called in.Applies the cooldown to the callingUser
on the Shard the command is called on. -
Method Summary
Modifier and TypeMethodDescriptionstatic CooldownScope
Returns the enum constant of this class with the specified name.static CooldownScope[]
values()
Returns an array containing the constants of this enum class, in the order they are declared.
-
Enum Constant Details
-
USER
Applies the cooldown to the callingUser
across all locations on this instance (IE: TextChannels, PrivateChannels, etc).The key for this is generated in the format
<command-name>|U:<userID>
-
CHANNEL
Applies the cooldown to theMessageChannel
the command is called in.The key for this is generated in the format
<command-name>|C:<channelID>
-
USER_CHANNEL
Applies the cooldown to the callingUser
local to theMessageChannel
the command is called in.The key for this is generated in the format
<command-name>|U:<userID>|C:<channelID>
-
GUILD
Applies the cooldown to theGuild
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 internalNullPointerException
s from being thrown while generating cooldown keys! -
USER_GUILD
Applies the cooldown to the callingUser
local to theGuild
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 internalNullPointerException
s from being thrown while generating cooldown keys! -
SHARD
Applies the cooldown to the calling Shard the command is called on.The key for this is generated in the format
<command-name>|S:<shardID>
NOTE: This will automatically default back to
CooldownScope.GLOBAL
whenJDA#getShardInfo()
returnsnull
. This is done in order to prevent internalNullPointerException
s from being thrown while generating cooldown keys! -
USER_SHARD
Applies the cooldown to the callingUser
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
whenJDA#getShardInfo()
returnsnull
. This is done in order to prevent internalNullPointerException
s from being thrown while generating cooldown keys! -
GLOBAL
Applies this cooldown globally.As this implies: the command will be unusable on the instance of JDA in all types of
MessageChannel
s until the cooldown has ended.The key for this is
<command-name>|globally
-
-
Method Details
-
values
Returns an array containing the constants of this enum class, in the order they are declared.- Returns:
- an array containing the constants of this enum class, in the order they are declared
-
valueOf
Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)- Parameters:
name
- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
IllegalArgumentException
- if this enum class has no constant with the specified nameNullPointerException
- if the argument is null
-