Class CommandPrivilege
java.lang.Object
net.dv8tion.jda.api.interactions.commands.privileges.CommandPrivilege
- All Implemented Interfaces:
ISnowflake
,SerializableData
Privilege used to restrict access to a command within a
Guild
.
If the command is enabled by default
, these can be used to blacklist users or roles from using the command.
On the other hand if it is disabled by default, this can be used to whitelist users or roles instead.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic enum
The target type this privilege applies to. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic CommandPrivilege
Creates a privilege that denies access to the command for the provided role.static CommandPrivilege
Creates a privilege that denies access to the command for the provided user.static CommandPrivilege
disableRole
(long roleId) Creates a privilege that denies access to the command for the provided role.static CommandPrivilege
disableRole
(String roleId) Creates a privilege that denies access to the command for the provided role.static CommandPrivilege
disableUser
(long userId) Creates a privilege that denies access to the command for the provided user.static CommandPrivilege
disableUser
(String userId) Creates a privilege that denies access to the command for the provided user.static CommandPrivilege
Creates a privilege that grants access to the command for the provided role.static CommandPrivilege
Creates a privilege that grants access to the command for the provided user.static CommandPrivilege
enableRole
(long roleId) Creates a privilege that grants access to the command for the provided role.static CommandPrivilege
enableRole
(String roleId) Creates a privilege that grants access to the command for the provided role.static CommandPrivilege
enableUser
(long userId) Creates a privilege that grants access to the command for the provided user.static CommandPrivilege
enableUser
(String userId) Creates a privilege that grants access to the command for the provided user.boolean
long
The Snowflake id of this entity.getType()
TheCommandPrivilege.Type
of entity this privilege is applied to.int
hashCode()
boolean
True if this privilege is denying access to the commandboolean
True if this privilege is granting access to the commandtoData()
SerializedDataObject
for this object.Methods inherited from class java.lang.Object
getClass, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface net.dv8tion.jda.api.entities.ISnowflake
getId, getTimeCreated
-
Constructor Details
-
CommandPrivilege
-
-
Method Details
-
enable
Creates a privilege that grants access to the command for the provided role.- Parameters:
role
- The role to grant access to- Returns:
- CommandPrivilege instance
-
enable
Creates a privilege that grants access to the command for the provided user.- Parameters:
user
- The user to grant access to- Returns:
- CommandPrivilege instance
-
enableUser
Creates a privilege that grants access to the command for the provided user.- Parameters:
userId
- The user to grant access to- Returns:
- CommandPrivilege instance
-
enableUser
Creates a privilege that grants access to the command for the provided user.- Parameters:
userId
- The user to grant access to- Returns:
- CommandPrivilege instance
-
enableRole
Creates a privilege that grants access to the command for the provided role.- Parameters:
roleId
- The role to grant access to- Returns:
- CommandPrivilege instance
-
enableRole
Creates a privilege that grants access to the command for the provided role.- Parameters:
roleId
- The role to grant access to- Returns:
- CommandPrivilege instance
-
disable
Creates a privilege that denies access to the command for the provided role.- Parameters:
role
- The role to deny access for- Returns:
- CommandPrivilege instance
-
disable
Creates a privilege that denies access to the command for the provided user.- Parameters:
user
- The user to grant denies for- Returns:
- CommandPrivilege instance
-
disableUser
Creates a privilege that denies access to the command for the provided user.- Parameters:
userId
- The user to grant access for- Returns:
- CommandPrivilege instance
-
disableUser
Creates a privilege that denies access to the command for the provided user.- Parameters:
userId
- The user to grant access for- Returns:
- CommandPrivilege instance
-
disableRole
Creates a privilege that denies access to the command for the provided role.- Parameters:
roleId
- The role to deny access for- Returns:
- CommandPrivilege instance
-
disableRole
Creates a privilege that denies access to the command for the provided role.- Parameters:
roleId
- The role to deny access for- Returns:
- CommandPrivilege instance
-
getIdLong
public long getIdLong()Description copied from interface:ISnowflake
The Snowflake id of this entity. This is unique to every entity and will never change.- Specified by:
getIdLong
in interfaceISnowflake
- Returns:
- Long containing the Id.
-
getType
TheCommandPrivilege.Type
of entity this privilege is applied to.- Returns:
- The target
CommandPrivilege.Type
-
isEnabled
public boolean isEnabled()True if this privilege is granting access to the command- Returns:
- Whether this privilege grants access
-
isDisabled
public boolean isDisabled()True if this privilege is denying access to the command- Returns:
- Whether this privilege denies access
-
hashCode
public int hashCode() -
equals
-
toData
Description copied from interface:SerializableData
SerializedDataObject
for this object.- Specified by:
toData
in interfaceSerializableData
- Returns:
DataObject
-