Package net.dv8tion.jda.api.entities
Interface IPermissionHolder
- All Superinterfaces:
ISnowflake
Marker for entities that hold Permissions within JDA
-
Method Summary
Modifier and TypeMethodDescriptionbooleancanSync(IPermissionContainer channel) Whether the permissions of this PermissionHolder are good enough to sync the target channel with any other channel.booleancanSync(IPermissionContainer targetChannel, IPermissionContainer syncSource) Whether the permissions of this PermissionHolder are good enough to sync the target channel with the sync source.getGuild()The Guild to which this PermissionHolder is relatedThe 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.default booleanhasAccess(GuildChannel channel) Checks whether or not this PermissionHolder hasVIEW_CHANNELandVOICE_CONNECTpermissions in theGuildChannel.default booleanhasPermission(Collection<Permission> permissions) Checks whether or not this PermissionHolder has thePermissionsin the providedCollection<Permission>in the Guild.default booleanhasPermission(GuildChannel channel, Collection<Permission> permissions) Checks whether or not this PermissionHolder has thePermissionsin the providedCollection<Permission>in the specified GuildChannel.booleanhasPermission(GuildChannel channel, Permission... permissions) Checks whether or not this PermissionHolder has the givenPermissionsin the specified GuildChannel.booleanhasPermission(Permission... permissions) Checks whether or not this PermissionHolder has the givenPermissionsin the Guild.Methods inherited from interface net.dv8tion.jda.api.entities.ISnowflake
getId, getIdLong, getTimeCreated
-
Method Details
-
getGuild
The Guild to which this PermissionHolder is related- Returns:
- A never-null Guild to which this PermissionHolder is linked
-
getPermissions
The Guild-Wide Permissions this PermissionHolder holds.
Changes to the returned set do not affect this entity directly.- Returns:
- An EnumSet of Permissions granted to this PermissionHolder.
- Throws:
DetachedEntityException- If this is adetachedmember
-
getPermissions
The Permissions this PermissionHolder holds in the specifiedGuildChannel.
Permissions returned by this may be different fromgetPermissions()due to the GuildChannel'sPermissionOverrides.
Changes to the returned set do not affect this entity directly.- Parameters:
channel- TheGuildChannelof which to get Permissions for- Returns:
- Set of Permissions granted to this Permission Holder in the specified channel.
- Throws:
IllegalArgumentException- If the channel is nullDetachedEntityException- If this is adetachedroleMissingEntityInteractionPermissionsException- If this is adetachedmember, and the combination of Member and GuildChannel doesn't have permission data, seeMissingEntityInteractionPermissionsException
-
getPermissionsExplicit
The explicitly granted permissions for this permission holder in the guild.
This disregards owner and administrator privileges. For a role this is identical togetPermissions()and members have all their roles taken into consideration.
Changes to the returned set do not affect this entity directly.- Returns:
- EnumSet of the explicitly granted permissions
- Throws:
DetachedEntityException- If this is adetachedmember
-
getPermissionsExplicit
The explicitly granted permissions for this permission holder in the guild.
This disregards owner and administrator privileges.
Permissions returned by this may be different fromgetPermissionsExplicit()due to the GuildChannel'sPermissionOverrides.
Changes to the returned set do not affect this entity directly.- Parameters:
channel- TheGuildChannelof which to get Permissions for- Returns:
- EnumSet of the explicitly granted permissions in the specified channel
- Throws:
IllegalArgumentException- If the channel is nullDetachedEntityException- If this is adetachedroleMissingEntityInteractionPermissionsException- If this is adetachedmember, and the combination of Member and GuildChannel doesn't have permission data, seeMissingEntityInteractionPermissionsException
-
hasPermission
Checks whether or not this PermissionHolder has the givenPermissionsin the Guild.- Parameters:
permissions- Permissions to check for.- Returns:
- True, if all of the specified Permissions are granted to this PermissionHolder.
- Throws:
IllegalArgumentException- If null is providedDetachedEntityException- If this is adetachedmember.
-
hasPermission
Checks whether or not this PermissionHolder has thePermissionsin the providedCollection<Permission>in the Guild.- Parameters:
permissions- Permissions to check for.- Returns:
- True, if all of the specified Permissions are granted to this PermissionHolder.
- Throws:
IllegalArgumentException- If null is providedDetachedEntityException- If this is adetachedmember.- See Also:
-
hasPermission
Checks whether or not this PermissionHolder has the givenPermissionsin the specified GuildChannel.- Parameters:
channel- TheGuildChannelin 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.
- Throws:
IllegalArgumentException- If null is providedDetachedEntityException- If this is adetachedroleMissingEntityInteractionPermissionsException- If this is adetachedmember, and the combination of Member and GuildChannel doesn't have permission data, seeMissingEntityInteractionPermissionsException- See Also:
-
hasPermission
default boolean hasPermission(@Nonnull GuildChannel channel, @Nonnull Collection<Permission> permissions) Checks whether or not this PermissionHolder has thePermissionsin the providedCollection<Permission>in the specified GuildChannel.- Parameters:
channel- TheGuildChannelin 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.
- Throws:
IllegalArgumentException- If null is providedDetachedEntityException- If this is adetachedroleMissingEntityInteractionPermissionsException- If this is adetachedmember, and the combination of Member and GuildChannel doesn't have permission data, seeMissingEntityInteractionPermissionsException
-
hasAccess
Checks whether or not this PermissionHolder hasVIEW_CHANNELandVOICE_CONNECTpermissions in theGuildChannel.- Parameters:
channel- The channel to check access for- Returns:
- True, if the PermissionHolder has access
- Throws:
IllegalArgumentException- If null is providedDetachedEntityException- If this is adetachedroleMissingEntityInteractionPermissionsException- If this is adetachedmember, and the combination of Member and GuildChannel doesn't have permission data, seeMissingEntityInteractionPermissionsException
-
canSync
boolean canSync(@Nonnull IPermissionContainer targetChannel, @Nonnull IPermissionContainer syncSource) 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_PERMISSIONSin an override on the target channel orPermission.ADMINISTRATORon 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.- 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
- Throws:
IllegalArgumentException- If either of the channels is null or not from the same guild as this permission holderDetachedEntityException- If this entity isdetached
-
canSync
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_PERMISSIONSin an override on the target channel orPermission.ADMINISTRATORon one of its roles, then it can set any permission on the target channel.- Parameters:
channel- The target channel to check- Returns:
- True, if the channel can be synced
- Throws:
IllegalArgumentException- If the channel is null or not from the same guild as this permission holderDetachedEntityException- If this entity isdetached
-