Class RoleImpl
- All Implemented Interfaces:
Comparable<Role>
,Formattable
,IDetachableEntity
,IMentionable
,IPermissionHolder
,ISnowflake
,Role
,IDetachableEntityMixin
,RoleMixin<RoleImpl>
-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from interface net.dv8tion.jda.api.entities.Role
Role.RoleTags
-
Field Summary
Fields inherited from interface net.dv8tion.jda.api.entities.Role
DEFAULT_COLOR_RAW
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionboolean
canInteract
(Role role) Whether this Role can interact with the specified Role.boolean
canSync
(IPermissionContainer channel) Whether the permissions of this PermissionHolder are good enough to sync the target channel with any other channel.boolean
canSync
(IPermissionContainer targetChannel, IPermissionContainer syncSource) Whether the permissions of this PermissionHolder are good enough to sync the target channel with the sync source.delete()
Deletes this Role.boolean
void
Retrieve a Mention for this Entity.getColor()
The color thisRole
is displayed in.int
The raw color RGB value used for this role
Defaults toRole.DEFAULT_COLOR_RAW
if this role has no set colorgetGuild()
Returns theGuild
this Role exists ingetIcon()
TheIcon
of this role ornull
if no custom image or emoji is set.long
The Snowflake id of this entity.getJDA()
Returns theJDA
instance of this RoleTheRoleManager
for this Role.getName()
The Name of thisRole
.The Guild-Wide Permissions this PermissionHolder holds.getPermissions
(GuildChannel channel) The Permissions this PermissionHolder holds in the specifiedGuildChannel
.The explicitly granted permissions for this permission holder in the guild.getPermissionsExplicit
(GuildChannel channel) The explicitly granted permissions for this permission holder in the guild.long
Thelong
representation of the literal permissions that thisRole
has.int
int
The actual position of theRole
as stored and given by Discord.getTags()
The tags of this role.int
hashCode()
boolean
hasPermission
(GuildChannel channel, Permission... permissions) Checks whether or not this PermissionHolder has the givenPermissions
in the specified GuildChannel.boolean
hasPermission
(Permission... permissions) Checks whether or not this PermissionHolder has the givenPermissions
in the Guild.boolean
Whether this entity is detached.boolean
Whether thisRole
is hoisted
Members in a hoisted role are displayed in their own grouping on the user-listboolean
Whether thisRole
is managed by an integrationboolean
Whether or not this Role is mentionableboolean
setColor
(int color) setHoisted
(boolean hoisted) setManaged
(boolean managed) setMentionable
(boolean mentionable) setRawPermissions
(long rawPermissions) setRawPosition
(int rawPosition) setTags
(DataObject tags) toString()
Methods inherited from interface net.dv8tion.jda.internal.entities.detached.mixin.IDetachableEntityMixin
checkAttached, detachedException, detachedRequiresChannelException
Methods inherited from interface net.dv8tion.jda.api.entities.IMentionable
formatTo
Methods inherited from interface net.dv8tion.jda.api.entities.IPermissionHolder
hasAccess, hasPermission, hasPermission
Methods inherited from interface net.dv8tion.jda.api.entities.ISnowflake
getId, getTimeCreated
Methods inherited from interface net.dv8tion.jda.api.entities.Role
createCopy
Methods inherited from interface net.dv8tion.jda.internal.entities.mixin.RoleMixin
compareTo, createCopy
-
Constructor Details
-
RoleImpl
-
-
Method Details
-
isDetached
public boolean isDetached()Description copied from interface:IDetachableEntity
Whether this entity is detached.If this returns
true
, this entity cannot be retrieved, will never be updated, and most methods that would otherwise return aRestAction
will throw aDetachedEntityException
instead.- Specified by:
isDetached
in interfaceIDetachableEntity
- Returns:
True
, if the entity is detached
-
getPosition
public int getPosition()Description copied from interface:Role
The hierarchical position of thisRole
in theGuild
hierarchy. (higher value means higher role).
TheGuild.getPublicRole()
's getPosition() always returns -1.- Specified by:
getPosition
in interfaceRole
- Returns:
- The position of this
Role
as integer.
-
getPositionRaw
public int getPositionRaw()Description copied from interface:Role
The actual position of theRole
as stored and given by Discord.
Role positions are actually based on a pairing of the creation time (as stored in the snowflake id) and the position. If 2 or more roles share the same position then they are sorted based on their creation date.
The more recent a role was created, the lower it is in the hierarchy. This is handled byRole.getPosition()
and it is most likely the method you want. If, for some reason, you want the actual position of the Role then this method will give you that value.- Specified by:
getPositionRaw
in interfaceRole
- Returns:
- The true, Discord stored, position of the
Role
.
-
getName
Description copied from interface:Role
The Name of thisRole
. -
isManaged
public boolean isManaged()Description copied from interface:Role
Whether thisRole
is managed by an integration -
isHoisted
public boolean isHoisted()Description copied from interface:Role
Whether thisRole
is hoisted
Members in a hoisted role are displayed in their own grouping on the user-list -
isMentionable
public boolean isMentionable()Description copied from interface:Role
Whether or not this Role is mentionable- Specified by:
isMentionable
in interfaceRole
- Returns:
- True, if Role is mentionable.
-
getPermissionsRaw
public long getPermissionsRaw()Description copied from interface:Role
Thelong
representation of the literal permissions that thisRole
has.
NOTE: these do not necessarily represent the permissions this role will have in aGuildChannel
.- Specified by:
getPermissionsRaw
in interfaceRole
- Returns:
- Never-negative long containing offset permissions of this role.
-
getPermissions
Description copied from interface:IPermissionHolder
The Guild-Wide Permissions this PermissionHolder holds.
Changes to the returned set do not affect this entity directly.- Specified by:
getPermissions
in interfaceIPermissionHolder
- Returns:
- An EnumSet of Permissions granted to this PermissionHolder.
-
getPermissions
Description copied from interface:IPermissionHolder
The Permissions this PermissionHolder holds in the specifiedGuildChannel
.
Permissions returned by this may be different fromIPermissionHolder.getPermissions()
due to the GuildChannel'sPermissionOverrides
.
Changes to the returned set do not affect this entity directly.- Specified by:
getPermissions
in interfaceIPermissionHolder
- Parameters:
channel
- TheGuildChannel
of which to get Permissions for- Returns:
- Set of Permissions granted to this Permission Holder in the specified channel.
-
getPermissionsExplicit
Description copied from interface:IPermissionHolder
The explicitly granted permissions for this permission holder in the guild.
This disregards owner and administrator privileges. For a role this is identical toIPermissionHolder.getPermissions()
and members have all their roles taken into consideration.
Changes to the returned set do not affect this entity directly.- Specified by:
getPermissionsExplicit
in interfaceIPermissionHolder
- Returns:
- EnumSet of the explicitly granted permissions
-
getPermissionsExplicit
Description copied from interface:IPermissionHolder
The explicitly granted permissions for this permission holder in the guild.
This disregards owner and administrator privileges.
Permissions returned by this may be different fromIPermissionHolder.getPermissionsExplicit()
due to the GuildChannel'sPermissionOverrides
.
Changes to the returned set do not affect this entity directly.- Specified by:
getPermissionsExplicit
in interfaceIPermissionHolder
- Parameters:
channel
- TheGuildChannel
of which to get Permissions for- Returns:
- EnumSet of the explicitly granted permissions in the specified channel
-
getColor
Description copied from interface:Role
The color thisRole
is displayed in. -
getColorRaw
public int getColorRaw()Description copied from interface:Role
The raw color RGB value used for this role
Defaults toRole.DEFAULT_COLOR_RAW
if this role has no set color- Specified by:
getColorRaw
in interfaceRole
- Returns:
- The raw RGB color value or default
-
isPublicRole
public boolean isPublicRole()Description copied from interface:Role
Whether this role is the @everyone role for itsGuild
, which is assigned to everyone who joins theGuild
.- Specified by:
isPublicRole
in interfaceRole
- Returns:
- True, if and only if this
Role
is the public role for theGuild
provided byRole.getGuild()
. - See Also:
-
hasPermission
Description copied from interface:IPermissionHolder
Checks whether or not this PermissionHolder has the givenPermissions
in the Guild.- Specified by:
hasPermission
in interfaceIPermissionHolder
- Parameters:
permissions
- Permissions to check for.- Returns:
- True, if all of the specified Permissions are granted to this PermissionHolder.
-
hasPermission
Description copied from interface:IPermissionHolder
Checks whether or not this PermissionHolder has the givenPermissions
in the specified GuildChannel.- Specified by:
hasPermission
in interfaceIPermissionHolder
- Parameters:
channel
- TheGuildChannel
in which to check.permissions
- Permissions to check for.- Returns:
- True, if all of the specified Permissions are granted to this PermissionHolder in the provided GuildChannel.
- See Also:
-
canSync
public boolean canSync(@Nonnull IPermissionContainer targetChannel, @Nonnull IPermissionContainer syncSource) Description copied from interface:IPermissionHolder
Whether the permissions of this PermissionHolder are good enough to sync the target channel with the sync source.
This checks what permissions would be changed by the overrides of the sync source and whether the permission holder is able to set them on the target channel.If the permission holder had
Permission.MANAGE_PERMISSIONS
in an override on the target channel orPermission.ADMINISTRATOR
on one of its roles, then it can set any permission on the target channel. Otherwise, the permission holder can only set permissions it also has in the channel.- Specified by:
canSync
in interfaceIPermissionHolder
- Parameters:
targetChannel
- The target channel to checksyncSource
- The sync source, for example the parent category (seeICategorizableChannel.getParentCategory()
)- Returns:
- True, if the channels can be synced
-
canSync
Description copied from interface:IPermissionHolder
Whether the permissions of this PermissionHolder are good enough to sync the target channel with any other channel.
This checks whether the permission holder has local administrator.If the permission holder had
Permission.MANAGE_PERMISSIONS
in an override on the target channel orPermission.ADMINISTRATOR
on one of its roles, then it can set any permission on the target channel.- Specified by:
canSync
in interfaceIPermissionHolder
- Parameters:
channel
- The target channel to check- Returns:
- True, if the channel can be synced
-
canInteract
Description copied from interface:Role
Whether this Role can interact with the specified Role. (move/manage/etc.)- Specified by:
canInteract
in interfaceRole
- Parameters:
role
- The not-null role to compare to- Returns:
- True, if this role can interact with the specified role
-
getGuild
Description copied from interface:Role
Returns theGuild
this Role exists in- Specified by:
getGuild
in interfaceIPermissionHolder
- Specified by:
getGuild
in interfaceRole
- Returns:
- the Guild containing this Role
-
getManager
Description copied from interface:Role
TheRoleManager
for this Role. In the RoleManager, you can modify all its values.
You modify multiple fields in one request by chaining setters before callingRestAction.queue()
.- Specified by:
getManager
in interfaceRole
- Returns:
- The RoleManager of this Role
-
delete
Description copied from interface:Role
Deletes this Role.Possible ErrorResponses include:
ErrorResponse.UNKNOWN_ROLE
If the the role was already deleted.MISSING_PERMISSIONS
The send request was attempted after the account lostPermission.MANAGE_ROLES
in the channel.MISSING_ACCESS
If we were removed from the Guild
- Specified by:
delete
in interfaceRole
- Returns:
RestAction
-
getJDA
Description copied from interface:Role
Returns theJDA
instance of this Role -
getTags
Description copied from interface:Role
The tags of this role.
This is useful to determine the purpose of a managed role.This requires
CacheFlag.ROLE_TAGS
to be enabled. SeeJDABuilder.enableCache(...)
.- Specified by:
getTags
in interfaceRole
- Returns:
Role.RoleTags
-
getIcon
Description copied from interface:Role
TheIcon
of this role ornull
if no custom image or emoji is set. This icon will be displayed next to the role's name in the members tab and in chat. -
getAsMention
Description copied from interface:IMentionable
Retrieve a Mention for this Entity. For the publicRole
(@everyone), this will return the literal string"@everyone"
.- Specified by:
getAsMention
in interfaceIMentionable
- Returns:
- A resolvable mention.
-
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.
-
equals
-
hashCode
public int hashCode() -
toString
-
setName
-
setColor
-
setManaged
- Specified by:
setManaged
in interfaceRoleMixin<RoleImpl>
-
setHoisted
- Specified by:
setHoisted
in interfaceRoleMixin<RoleImpl>
-
setMentionable
- Specified by:
setMentionable
in interfaceRoleMixin<RoleImpl>
-
setRawPermissions
- Specified by:
setRawPermissions
in interfaceRoleMixin<RoleImpl>
-
setRawPosition
- Specified by:
setRawPosition
in interfaceRoleMixin<RoleImpl>
-
setTags
-
setIcon
-
freezePosition
public void freezePosition()
-