Class CommandPrivilege
- java.lang.Object
-
- net.dv8tion.jda.api.interactions.commands.privileges.CommandPrivilege
-
- All Implemented Interfaces:
ISnowflake,SerializableData
public class CommandPrivilege extends java.lang.Object implements ISnowflake, SerializableData
Privilege used to restrict access to a command within aGuild.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
Nested Classes Modifier and Type Class Description static classCommandPrivilege.TypeThe target type this privilege applies to.
-
Constructor Summary
Constructors Constructor Description CommandPrivilege(CommandPrivilege.Type type, boolean enabled, long id)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static CommandPrivilegedisable(Role role)Creates a privilege that denies access to the command for the provided role.static CommandPrivilegedisable(User user)Creates a privilege that denies access to the command for the provided user.static CommandPrivilegedisableRole(long roleId)Creates a privilege that denies access to the command for the provided role.static CommandPrivilegedisableRole(java.lang.String roleId)Creates a privilege that denies access to the command for the provided role.static CommandPrivilegedisableUser(long userId)Creates a privilege that denies access to the command for the provided user.static CommandPrivilegedisableUser(java.lang.String userId)Creates a privilege that denies access to the command for the provided user.static CommandPrivilegeenable(Role role)Creates a privilege that grants access to the command for the provided role.static CommandPrivilegeenable(User user)Creates a privilege that grants access to the command for the provided user.static CommandPrivilegeenableRole(long roleId)Creates a privilege that grants access to the command for the provided role.static CommandPrivilegeenableRole(java.lang.String roleId)Creates a privilege that grants access to the command for the provided role.static CommandPrivilegeenableUser(long userId)Creates a privilege that grants access to the command for the provided user.static CommandPrivilegeenableUser(java.lang.String userId)Creates a privilege that grants access to the command for the provided user.booleanequals(java.lang.Object obj)longgetIdLong()The Snowflake id of this entity.CommandPrivilege.TypegetType()TheCommandPrivilege.Typeof entity this privilege is applied to.inthashCode()booleanisDisabled()True if this privilege is denying access to the commandbooleanisEnabled()True if this privilege is granting access to the commandDataObjecttoData()SerializedDataObjectfor 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 Detail
-
CommandPrivilege
public CommandPrivilege(@Nonnull CommandPrivilege.Type type, boolean enabled, long id)
-
-
Method Detail
-
enable
@Nonnull public static CommandPrivilege enable(@Nonnull Role role)
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
@Nonnull public static CommandPrivilege enable(@Nonnull User user)
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
@Nonnull public static CommandPrivilege enableUser(@Nonnull java.lang.String userId)
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
@Nonnull public static CommandPrivilege enableUser(long userId)
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
@Nonnull public static CommandPrivilege enableRole(@Nonnull java.lang.String roleId)
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
@Nonnull public static CommandPrivilege enableRole(long roleId)
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
@Nonnull public static CommandPrivilege disable(@Nonnull Role role)
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
@Nonnull public static CommandPrivilege disable(@Nonnull User user)
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
@Nonnull public static CommandPrivilege disableUser(@Nonnull java.lang.String userId)
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
@Nonnull public static CommandPrivilege disableUser(long userId)
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
@Nonnull public static CommandPrivilege disableRole(@Nonnull java.lang.String roleId)
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
@Nonnull public static CommandPrivilege disableRole(long roleId)
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:ISnowflakeThe Snowflake id of this entity. This is unique to every entity and will never change.- Specified by:
getIdLongin interfaceISnowflake- Returns:
- Long containing the Id.
-
getType
@Nonnull public CommandPrivilege.Type getType()
TheCommandPrivilege.Typeof 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()
- Overrides:
hashCodein classjava.lang.Object
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equalsin classjava.lang.Object
-
toData
@Nonnull public DataObject toData()
Description copied from interface:SerializableDataSerializedDataObjectfor this object.- Specified by:
toDatain interfaceSerializableData- Returns:
DataObject
-
-