Class RestrictedCommand
java.lang.Object
xyz.dynxsty.dih4jda.interactions.commands.RestrictedCommand
- Direct Known Subclasses:
ApplicationCommand
Represents a basic command.
- Since:
- v1.6
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classModel class which represents a single command cooldown. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidapplyCooldown(long userId, Instant nextUse) Manually applies a cooldown for the specified user id.
Command Cooldowns DO NOT persist between sessions!Returns theDurationthe user has to wait between command executions.Long[]The required guilds the command can be executed in.final net.dv8tion.jda.api.Permission[]The requiredPermissiontheUserneeds to execute the command.final Long[]TheRoles that are required to execute the command.final Long[]The user ids from theUserthat are allowed to execute the command.booleanhasCooldown(long userId) Returns whether the command can be used by the specified user.
Command Cooldowns DO NOT persist between sessions!retrieveCooldown(long userId) Gets thetimethe specified user can execute this command again.voidsetCommandCooldown(Duration commandCooldown) Allows to set a cooldown for this command.final voidsetRequiredGuilds(Long... guilds) Allows to require a set ofGuilds only in which the command can get executed.final voidsetRequiredPermissions(net.dv8tion.jda.api.Permission... permissions) Allows to require a set ofPermissions which are needed to execute the corresponding command.final voidsetRequiredRoles(Long... roles) Allows to require a set ofLongs (role Ids) which are able to execute the corresponding command.final voidsetRequiredUsers(Long... users) Allows to require a set ofLongs (user Ids) which are able to execute the corresponding command.
-
Constructor Details
-
RestrictedCommand
public RestrictedCommand()Creates a default instance.
-
-
Method Details
-
setRequiredGuilds
Allows to require a set ofGuilds only in which the command can get executed.- Parameters:
guilds- ALongarray, containting the guild ids.
-
getRequiredGuilds
The required guilds the command can be executed in.- Returns:
- The
Longarray containing the guild ids.
-
getRequiredPermissions
@Nonnull public final net.dv8tion.jda.api.Permission[] getRequiredPermissions()The requiredPermissiontheUserneeds to execute the command.- Returns:
- the
Permission.
-
setRequiredPermissions
public final void setRequiredPermissions(@Nonnull net.dv8tion.jda.api.Permission... permissions) Allows to require a set ofPermissions which are needed to execute the corresponding command.- Parameters:
permissions- The set ofPermissions.
-
getRequiredUsers
The user ids from theUserthat are allowed to execute the command.- Returns:
- The
Longarray containing the user ids.
-
setRequiredUsers
Allows to require a set ofLongs (user Ids) which are able to execute the corresponding command.- Parameters:
users- TheUserids as anLongarray.
-
getRequiredRoles
TheRoles that are required to execute the command.- Returns:
- The
Longarray containing the role ids.
-
setRequiredRoles
Allows to require a set ofLongs (role Ids) which are able to execute the corresponding command.- Parameters:
roles- TheRoleids as anLongarray.
-
setCommandCooldown
Allows to set a cooldown for this command. The user has to wait the providedDurationuntil they can execute this command again. If the user executes the command while they're on cooldown, theCommandCooldownEventis fired.
Command Cooldowns DO NOT persist between sessions!- Parameters:
commandCooldown- TheDurationthe user has to wait between command executions.
-
getCommandCooldown
Returns theDurationthe user has to wait between command executions.- Returns:
- The
Duration. - See Also:
-
applyCooldown
Manually applies a cooldown for the specified user id.
Command Cooldowns DO NOT persist between sessions!- Parameters:
userId- The targets' user id.nextUse- TheInstantthat marks the time the command can be used again.
-
retrieveCooldown
Gets thetimethe specified user can execute this command again. If the user has not executed the command yet, this will return aRestrictedCommand.Cooldownwith both the nextUse and the lastUse ofInstant.EPOCHinstead.- Parameters:
userId- The targets' user id.- Returns:
- The
Instantthat marks the time the command can be used again.
-
hasCooldown
public boolean hasCooldown(long userId) Returns whether the command can be used by the specified user.
Command Cooldowns DO NOT persist between sessions!- Parameters:
userId- The targets' user id.- Returns:
- Whether the command can be executed.
-