Package net.dv8tion.jda.api
Enum Permission
- java.lang.Object
-
- java.lang.Enum<Permission>
-
- net.dv8tion.jda.api.Permission
-
- All Implemented Interfaces:
java.io.Serializable
,java.lang.Comparable<Permission>
public enum Permission extends java.lang.Enum<Permission>
Represents the bit offsets used by Discord for Permissions.
-
-
Enum Constant Summary
-
Field Summary
Fields Modifier and Type Field Description static long
ALL_CHANNEL_PERMISSIONS
All permissions that apply to a channelstatic long
ALL_GUILD_PERMISSIONS
All Guild specific permissions which are only available to rolesstatic long
ALL_PERMISSIONS
Represents a raw set of all permissionsstatic long
ALL_TEXT_PERMISSIONS
All text channel specific permissions which are only available in text channel permission overridesstatic long
ALL_VOICE_PERMISSIONS
All voice channel specific permissions which are only available in voice channel permission overridesstatic Permission[]
EMPTY_PERMISSIONS
Empty array of Permission enum, useful for optimized use inCollection.toArray(Object[])
.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static Permission
getFromOffset(int offset)
Gets the firstPermission
relating to the provided offset.java.lang.String
getName()
The readable name as used in the Discord client.int
getOffset()
The binary offset of the permission.static java.util.EnumSet<Permission>
getPermissions(long permissions)
A set of allPermissions
that are specified by this raw long representation of permissions.static long
getRaw(java.util.Collection<Permission> permissions)
This is effectively the opposite ofgetPermissions(long)
, this takes a Collection ofPermissions
and returns the raw offsetlong
representation of the permissions.static long
getRaw(Permission... permissions)
This is effectively the opposite ofgetPermissions(long)
, this takes 1 or morePermissions
and returns the raw offsetlong
representation of the permissions.long
getRawValue()
The value of this permission when viewed as a raw value.boolean
isChannel()
Returns whether or not this Permission is present Channel level (configurable viaPermissionsOverrides
)boolean
isGuild()
Returns whether or not this Permission is present at the Guild level (configurable viaRoles
)boolean
isText()
Whether this permission is specifically forTextChannels
boolean
isVoice()
Whether this permission is specifically forVoiceChannels
static Permission
valueOf(java.lang.String name)
Returns the enum constant of this type with the specified name.static Permission[]
values()
Returns an array containing the constants of this enum type, in the order they are declared.
-
-
-
Enum Constant Detail
-
CREATE_INSTANT_INVITE
public static final Permission CREATE_INSTANT_INVITE
-
KICK_MEMBERS
public static final Permission KICK_MEMBERS
-
BAN_MEMBERS
public static final Permission BAN_MEMBERS
-
ADMINISTRATOR
public static final Permission ADMINISTRATOR
-
MANAGE_CHANNEL
public static final Permission MANAGE_CHANNEL
-
MANAGE_SERVER
public static final Permission MANAGE_SERVER
-
MESSAGE_ADD_REACTION
public static final Permission MESSAGE_ADD_REACTION
-
VIEW_AUDIT_LOGS
public static final Permission VIEW_AUDIT_LOGS
-
PRIORITY_SPEAKER
public static final Permission PRIORITY_SPEAKER
-
VIEW_GUILD_INSIGHTS
public static final Permission VIEW_GUILD_INSIGHTS
-
VIEW_CHANNEL
public static final Permission VIEW_CHANNEL
-
MESSAGE_READ
public static final Permission MESSAGE_READ
-
MESSAGE_WRITE
public static final Permission MESSAGE_WRITE
-
MESSAGE_TTS
public static final Permission MESSAGE_TTS
-
MESSAGE_MANAGE
public static final Permission MESSAGE_MANAGE
-
MESSAGE_EMBED_LINKS
public static final Permission MESSAGE_EMBED_LINKS
-
MESSAGE_ATTACH_FILES
public static final Permission MESSAGE_ATTACH_FILES
-
MESSAGE_HISTORY
public static final Permission MESSAGE_HISTORY
-
MESSAGE_MENTION_EVERYONE
public static final Permission MESSAGE_MENTION_EVERYONE
-
MESSAGE_EXT_EMOJI
public static final Permission MESSAGE_EXT_EMOJI
-
MESSAGE_EXT_STICKER
public static final Permission MESSAGE_EXT_STICKER
-
USE_SLASH_COMMANDS
public static final Permission USE_SLASH_COMMANDS
-
MANAGE_THREADS
public static final Permission MANAGE_THREADS
-
USE_PUBLIC_THREADS
public static final Permission USE_PUBLIC_THREADS
-
USE_PRIVATE_THREADS
public static final Permission USE_PRIVATE_THREADS
-
VOICE_STREAM
public static final Permission VOICE_STREAM
-
VOICE_CONNECT
public static final Permission VOICE_CONNECT
-
VOICE_SPEAK
public static final Permission VOICE_SPEAK
-
VOICE_MUTE_OTHERS
public static final Permission VOICE_MUTE_OTHERS
-
VOICE_DEAF_OTHERS
public static final Permission VOICE_DEAF_OTHERS
-
VOICE_MOVE_OTHERS
public static final Permission VOICE_MOVE_OTHERS
-
VOICE_USE_VAD
public static final Permission VOICE_USE_VAD
-
VOICE_START_ACTIVITIES
public static final Permission VOICE_START_ACTIVITIES
-
NICKNAME_CHANGE
public static final Permission NICKNAME_CHANGE
-
NICKNAME_MANAGE
public static final Permission NICKNAME_MANAGE
-
MANAGE_ROLES
public static final Permission MANAGE_ROLES
-
MANAGE_PERMISSIONS
public static final Permission MANAGE_PERMISSIONS
-
MANAGE_WEBHOOKS
public static final Permission MANAGE_WEBHOOKS
-
MANAGE_EMOTES
public static final Permission MANAGE_EMOTES
-
REQUEST_TO_SPEAK
public static final Permission REQUEST_TO_SPEAK
-
UNKNOWN
public static final Permission UNKNOWN
-
-
Field Detail
-
EMPTY_PERMISSIONS
public static final Permission[] EMPTY_PERMISSIONS
Empty array of Permission enum, useful for optimized use inCollection.toArray(Object[])
.
-
ALL_PERMISSIONS
public static final long ALL_PERMISSIONS
Represents a raw set of all permissions
-
ALL_CHANNEL_PERMISSIONS
public static final long ALL_CHANNEL_PERMISSIONS
All permissions that apply to a channel
-
ALL_GUILD_PERMISSIONS
public static final long ALL_GUILD_PERMISSIONS
All Guild specific permissions which are only available to roles
-
ALL_TEXT_PERMISSIONS
public static final long ALL_TEXT_PERMISSIONS
All text channel specific permissions which are only available in text channel permission overrides
-
ALL_VOICE_PERMISSIONS
public static final long ALL_VOICE_PERMISSIONS
All voice channel specific permissions which are only available in voice channel permission overrides
-
-
Method Detail
-
values
public static Permission[] values()
Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:for (Permission c : Permission.values()) System.out.println(c);
- Returns:
- an array containing the constants of this enum type, in the order they are declared
-
valueOf
public static Permission valueOf(java.lang.String name)
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (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:
java.lang.IllegalArgumentException
- if this enum type has no constant with the specified namejava.lang.NullPointerException
- if the argument is null
-
getName
@Nonnull public java.lang.String getName()
The readable name as used in the Discord client.- Returns:
- The readable name of this
Permission
.
-
getOffset
public int getOffset()
The binary offset of the permission.
For more information about Discord's offset system refer to Discord Permissions.- Returns:
- The offset that represents this
Permission
.
-
getRawValue
public long getRawValue()
The value of this permission when viewed as a raw value.
This is equivalent to:1 <<
getOffset()
- Returns:
- The raw value of this specific permission.
-
isGuild
public boolean isGuild()
Returns whether or not this Permission is present at the Guild level (configurable viaRoles
)- Returns:
- True if this permission is present at the Guild level.
-
isChannel
public boolean isChannel()
Returns whether or not this Permission is present Channel level (configurable viaPermissionsOverrides
)- Returns:
- True if this permission is present at the Channel level.
-
isText
public boolean isText()
Whether this permission is specifically forTextChannels
- Returns:
- True, if and only if this permission can only be applied to text channels
-
isVoice
public boolean isVoice()
Whether this permission is specifically forVoiceChannels
- Returns:
- True, if and only if this permission can only be applied to voice channels
-
getFromOffset
@Nonnull public static Permission getFromOffset(int offset)
Gets the firstPermission
relating to the provided offset.
If there is noPermssions
that matches the provided offset,Permission.UNKNOWN
is returned.- Parameters:
offset
- The offset to match aPermission
to.- Returns:
Permission
relating to the provided offset.
-
getPermissions
@Nonnull public static java.util.EnumSet<Permission> getPermissions(long permissions)
A set of allPermissions
that are specified by this raw long representation of permissions. The is best used with the getRaw methods inRole
orPermissionOverride
.Example:
Role.getPermissionsRaw()
- Parameters:
permissions
- The rawlong
representation of permissions.- Returns:
- Possibly-empty EnumSet of
Permissions
.
-
getRaw
public static long getRaw(@Nonnull Permission... permissions)
This is effectively the opposite ofgetPermissions(long)
, this takes 1 or morePermissions
and returns the raw offsetlong
representation of the permissions.- Parameters:
permissions
- The array of permissions of which to form into the raw long representation.- Returns:
- Unsigned long representing the provided permissions.
-
getRaw
public static long getRaw(@Nonnull java.util.Collection<Permission> permissions)
This is effectively the opposite ofgetPermissions(long)
, this takes a Collection ofPermissions
and returns the raw offsetlong
representation of the permissions.
Example:getRaw(EnumSet.of(Permission.MESSAGE_READ, Permission.MESSAGE_WRITE))
- Parameters:
permissions
- The Collection of permissions of which to form into the raw long representation.- Returns:
- Unsigned long representing the provided permissions.
- See Also:
EnumSet
-
-