Interface PermissionOverrideAction
-
- All Superinterfaces:
AuditableRestAction<PermissionOverride>
,RestAction<PermissionOverride>
public interface PermissionOverrideAction extends AuditableRestAction<PermissionOverride>
Extension ofAuditableRestAction
specifically designed to create aPermissionOverride
for aGuildChannel
. This extension allows setting properties before executing the action.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default PermissionOverrideAction
clear(long inheritedBits)
Clears the providedPermissions
bits from thePermissionOverride
.default PermissionOverrideAction
clear(Collection<Permission> permissions)
Clears the providedPermissions
bits from thePermissionOverride
.default PermissionOverrideAction
clear(Permission... permissions)
Clears the providedPermissions
bits from thePermissionOverride
.default PermissionOverrideAction
deny(long denyBits)
Denies the specified permissions.default PermissionOverrideAction
deny(Collection<Permission> permissions)
Denies the specified permissions.default PermissionOverrideAction
deny(Permission... permissions)
Denies the specified permissions.long
getAllow()
The currently set of allowed permission bits.default EnumSet<Permission>
getAllowedPermissions()
Set ofPermissions
that would be granted by the PermissionOverride that is created by this action.GuildChannel
getChannel()
TheGuildChannel
this will be created indefault EnumSet<Permission>
getDeniedPermissions()
Set ofPermissions
that would be denied by the PermissionOverride that is created by this action.long
getDeny()
The currently set of denied permission bits.default Guild
getGuild()
TheGuild
for this overridelong
getInherited()
The currently set of inherited permission bits.default EnumSet<Permission>
getInheritedPermissions()
Set ofPermissions
that would be inherited from other permission holders.Member
getMember()
TheMember
for this overrideRole
getRole()
TheRole
for this overridedefault PermissionOverrideAction
grant(long allowBits)
Grants the specified permissions.default PermissionOverrideAction
grant(Collection<Permission> permissions)
Grants the specified permissions.default PermissionOverrideAction
grant(Permission... permissions)
Grants the specified permissions.boolean
isMember()
Whether this Action will create aPermissionOverride
for aMember
or notboolean
isRole()
Whether this Action will create aPermissionOverride
for aRole
or notdefault PermissionOverrideAction
reset()
Shortcut forresetAllow().resetDeny()
.PermissionOverrideAction
resetAllow()
Resets the allowed permissions to the current original value.PermissionOverrideAction
resetDeny()
Resets the denied permissions to the current original value.PermissionOverrideAction
setAllow(long allowBits)
Sets the value of explicitly granted permissions using the bitwise representation of a set ofPermissions
.default PermissionOverrideAction
setAllow(Collection<Permission> permissions)
Sets the value of explicitly granted permissions using a Collection ofPermissions
.default PermissionOverrideAction
setAllow(Permission... permissions)
Sets the value of explicitly granted permissions using a set ofPermissions
.PermissionOverrideAction
setCheck(BooleanSupplier checks)
Sets the last-second checks before finally executing the http request in the queue.PermissionOverrideAction
setDeny(long denyBits)
Sets the value of explicitly denied permissions using the bitwise representation of a set ofPermissions
.default PermissionOverrideAction
setDeny(Collection<Permission> permissions)
Sets the value of explicitly denied permissions using a Collection ofPermissions
.default PermissionOverrideAction
setDeny(Permission... permissions)
Sets the value of explicitly denied permissions using a set ofPermissions
.PermissionOverrideAction
setPermissions(long allowBits, long denyBits)
default PermissionOverrideAction
setPermissions(Collection<Permission> grantPermissions, Collection<Permission> denyPermissions)
Combination ofsetAllow(java.util.Collection)
andsetDeny(java.util.Collection)
First sets the granted permissions and then the denied permissions.-
Methods inherited from interface net.dv8tion.jda.api.requests.restaction.AuditableRestAction
reason
-
Methods inherited from interface net.dv8tion.jda.api.requests.RestAction
complete, complete, completeAfter, getJDA, queue, queue, queue, queueAfter, queueAfter, queueAfter, queueAfter, queueAfter, queueAfter, submit, submit, submitAfter, submitAfter
-
-
-
-
Method Detail
-
setCheck
@Nonnull PermissionOverrideAction setCheck(@Nullable BooleanSupplier checks)
Description copied from interface:AuditableRestAction
Sets the last-second checks before finally executing the http request in the queue.
If the provided supplier evaluates tofalse
or throws an exception this will not be finished. When an exception is thrown from the supplier it will be provided to the failure callback.- Specified by:
setCheck
in interfaceAuditableRestAction<PermissionOverride>
- Specified by:
setCheck
in interfaceRestAction<PermissionOverride>
- Parameters:
checks
- The checks to run before executing the request, ornull
to run no checks- Returns:
- The current RestAction for chaining convenience
-
reset
@Nonnull default PermissionOverrideAction reset()
Shortcut forresetAllow().resetDeny()
.
The permission override will be empty after this operation- Returns:
- The current PermissionOverrideAction for chaining convenience
-
resetAllow
@Nonnull PermissionOverrideAction resetAllow()
Resets the allowed permissions to the current original value.
For a new override this will just be 0.- Returns:
- The current PermissionOverrideAction for chaining convenience
-
resetDeny
@Nonnull PermissionOverrideAction resetDeny()
Resets the denied permissions to the current original value.
For a new override this will just be 0.- Returns:
- The current PermissionOverrideAction for chaining convenience
-
getChannel
@Nonnull GuildChannel getChannel()
TheGuildChannel
this will be created in- Returns:
- The channel
-
getRole
@Nullable Role getRole()
TheRole
for this override- Returns:
- The role, or null if this is a member override
-
getMember
@Nullable Member getMember()
TheMember
for this override- Returns:
- The member, or null if this is a role override
-
getAllow
long getAllow()
The currently set of allowed permission bits.
This value represents all granted permissions in the raw bitwise representation.Use
getAllowedPermissions()
to retrieve aList
withPermissions
for this value- Returns:
- long value of granted permissions
-
getAllowedPermissions
@Nonnull default EnumSet<Permission> getAllowedPermissions()
Set ofPermissions
that would be granted by the PermissionOverride that is created by this action.
Changes to the returned set do not affect this entity directly.- Returns:
- set of granted
Permissions
-
getDeny
long getDeny()
The currently set of denied permission bits.
This value represents all denied permissions in the raw bitwise representation.Use
getDeniedPermissions()
to retrieve aList
withPermissions
for this value- Returns:
- long value of denied permissions
-
getDeniedPermissions
@Nonnull default EnumSet<Permission> getDeniedPermissions()
Set ofPermissions
that would be denied by the PermissionOverride that is created by this action.
Changes to the returned set do not affect this entity directly.- Returns:
- set of denied
Permissions
-
getInherited
long getInherited()
The currently set of inherited permission bits.
This value represents all permissions that are not explicitly allowed or denied in their raw bitwise representation.
Inherited Permissions are permissions that are defined by other rules from maybe other PermissionOverrides or a Role.Use
getInheritedPermissions()
to retrieve aList
withPermissions
for this value- Returns:
- long value of inherited permissions
-
getInheritedPermissions
@Nonnull default EnumSet<Permission> getInheritedPermissions()
Set ofPermissions
that would be inherited from other permission holders.
Permissions returned are not explicitly granted or denied!
Changes to the returned set do not affect this entity directly.- Returns:
- set of inherited
Permissions
- See Also:
getInherited()
-
isMember
boolean isMember()
Whether this Action will create aPermissionOverride
for aMember
or not
-
isRole
boolean isRole()
Whether this Action will create aPermissionOverride
for aRole
or not- Returns:
- True, if this is targeting a Role.
If this is
false
it is targeting aMember
. (isMember()
)
-
setAllow
@Nonnull @CheckReturnValue PermissionOverrideAction setAllow(long allowBits)
Sets the value of explicitly granted permissions using the bitwise representation of a set ofPermissions
.
This value can be retrieved throughPermissions.getRaw(Permission...)
!
Note: Permissions not marked asisChannel()
will have no affect!All newly granted permissions will be removed from the currently set denied permissions.
allow = allowBits; deny = deny & ~allowBits;
- Parameters:
allowBits
- The positive bits representing the granted permissions for the new PermissionOverride- Returns:
- The current PermissionOverrideAction - for chaining convenience
- Throws:
IllegalArgumentException
- If the provided bits are negative or higher thanPermission.ALL_PERMISSIONS
- See Also:
setAllow(Collection)
,setAllow(Permission...)
-
setAllow
@Nonnull @CheckReturnValue default PermissionOverrideAction setAllow(@Nullable Collection<Permission> permissions)
Sets the value of explicitly granted permissions using a Collection ofPermissions
.
Note: Permissions not marked asisChannel()
will have no affect!Example:
setAllow(EnumSet.of(Permission.MESSAGE_READ))
- Parameters:
permissions
- The Collection of Permissions representing the granted permissions for the new PermissionOverride.
If the provided value isnull
the permissions are reset to the default of none- Returns:
- The current PermissionOverrideAction - for chaining convenience
- Throws:
IllegalArgumentException
- If the any of the specified Permissions isnull
- See Also:
EnumSet
,setAllow(Permission...)
-
setAllow
@Nonnull @CheckReturnValue default PermissionOverrideAction setAllow(@Nullable Permission... permissions)
Sets the value of explicitly granted permissions using a set ofPermissions
.
Note: Permissions not marked asisChannel()
will have no affect!- Parameters:
permissions
- The Permissions representing the granted permissions for the new PermissionOverride.
If the provided value isnull
the permissions are reset to the default of none- Returns:
- The current PermissionOverrideAction - for chaining convenience
- Throws:
IllegalArgumentException
- If the any of the specified Permissions isnull
-
grant
@Nonnull @CheckReturnValue default PermissionOverrideAction grant(long allowBits)
Grants the specified permissions.
This does not override already granted permissions.- Parameters:
allowBits
- The permissions to grant, in addition to already allowed permissions- Returns:
- The current PermissionOverrideAction - for chaining convenience
-
grant
@Nonnull @CheckReturnValue default PermissionOverrideAction grant(@Nonnull Collection<Permission> permissions)
Grants the specified permissions.
This does not override already granted permissions.- Parameters:
permissions
- The permissions to grant, in addition to already allowed permissions- Returns:
- The current PermissionOverrideAction - for chaining convenience
- Throws:
IllegalArgumentException
- If any provided argument is null
-
grant
@Nonnull @CheckReturnValue default PermissionOverrideAction grant(@Nonnull Permission... permissions)
Grants the specified permissions.
This does not override already granted permissions.- Parameters:
permissions
- The permissions to grant, in addition to already allowed permissions- Returns:
- The current PermissionOverrideAction - for chaining convenience
- Throws:
IllegalArgumentException
- If any provided argument is null
-
setDeny
@Nonnull @CheckReturnValue PermissionOverrideAction setDeny(long denyBits)
Sets the value of explicitly denied permissions using the bitwise representation of a set ofPermissions
.
This value can be retrieved throughPermissions.getRaw(Permission...)
!
Note: Permissions not marked asisChannel()
will have no affect!All newly denied permissions will be removed from the currently set allowed permissions.
deny = denyBits; allow = allow & ~denyBits;
- Parameters:
denyBits
- The positive bits representing the denied permissions for the new PermissionOverride- Returns:
- The current PermissionOverrideAction - for chaining convenience
- Throws:
IllegalArgumentException
- If the provided bits are negative or higher thanPermission.ALL_PERMISSIONS
- See Also:
setDeny(Collection)
,setDeny(Permission...)
-
setDeny
@Nonnull @CheckReturnValue default PermissionOverrideAction setDeny(@Nullable Collection<Permission> permissions)
Sets the value of explicitly denied permissions using a Collection ofPermissions
.
Note: Permissions not marked asisChannel()
will have no affect!Example:
setDeny(EnumSet.of(Permission.MESSAGE_WRITE, Permission.MESSAGE_EXT_EMOJI))
- Parameters:
permissions
- The Collection of Permissions representing the denied permissions for the new PermissionOverride.
If the provided value isnull
the permissions are reset to the default of none- Returns:
- The current PermissionOverrideAction - for chaining convenience
- Throws:
IllegalArgumentException
- If the any of the specified Permissions isnull
- See Also:
EnumSet
,setDeny(Permission...)
-
setDeny
@Nonnull @CheckReturnValue default PermissionOverrideAction setDeny(@Nullable Permission... permissions)
Sets the value of explicitly denied permissions using a set ofPermissions
.
Note: Permissions not marked asisChannel()
will have no affect!- Parameters:
permissions
- The Permissions representing the denied permissions for the new PermissionOverride.
If the provided value isnull
the permissions are reset to the default of none- Returns:
- The current PermissionOverrideAction - for chaining convenience
- Throws:
IllegalArgumentException
- If the any of the specified Permissions isnull
-
deny
@Nonnull @CheckReturnValue default PermissionOverrideAction deny(long denyBits)
Denies the specified permissions.
This does not override already denied permissions.- Parameters:
denyBits
- The permissions to deny, in addition to already denied permissions- Returns:
- The current PermissionOverrideAction - for chaining convenience
-
deny
@Nonnull @CheckReturnValue default PermissionOverrideAction deny(@Nonnull Collection<Permission> permissions)
Denies the specified permissions.
This does not override already denied permissions.- Parameters:
permissions
- The permissions to deny, in addition to already denied permissions- Returns:
- The current PermissionOverrideAction - for chaining convenience
- Throws:
IllegalArgumentException
- If any provided argument is null
-
deny
@Nonnull @CheckReturnValue default PermissionOverrideAction deny(@Nonnull Permission... permissions)
Denies the specified permissions.
This does not override already denied permissions.- Parameters:
permissions
- The permissions to deny, in addition to already denied permissions- Returns:
- The current PermissionOverrideAction - for chaining convenience
- Throws:
IllegalArgumentException
- If any provided argument is null
-
clear
@Nonnull @CheckReturnValue default PermissionOverrideAction clear(long inheritedBits)
Clears the providedPermissions
bits from thePermissionOverride
.
This will cause the provided Permissions to be inherited from other overrides or roles.- Parameters:
inheritedBits
- The permissions to clear from thePermissionOverride
- Returns:
- The current PermissionOverrideAction - for chaining convenience
-
clear
@Nonnull @CheckReturnValue default PermissionOverrideAction clear(@Nonnull Collection<Permission> permissions)
Clears the providedPermissions
bits from thePermissionOverride
.
This will cause the provided Permissions to be inherited- Parameters:
permissions
- The permissions to clear from thePermissionOverride
- Returns:
- The current PermissionOverrideAction - for chaining convenience
- Throws:
IllegalArgumentException
- If any provided argument is null
-
clear
@Nonnull @CheckReturnValue default PermissionOverrideAction clear(@Nonnull Permission... permissions)
Clears the providedPermissions
bits from thePermissionOverride
.
This will cause the provided Permissions to be inherited- Parameters:
permissions
- The permissions to clear from thePermissionOverride
- Returns:
- The current PermissionOverrideAction - for chaining convenience
- Throws:
IllegalArgumentException
- If any provided argument is null
-
setPermissions
@Nonnull @CheckReturnValue PermissionOverrideAction setPermissions(long allowBits, long denyBits)
- Parameters:
allowBits
- An unsigned bitwise representation of granted PermissionsdenyBits
- An unsigned bitwise representation of denied Permissions- Returns:
- The current PermissionOverrideAction - for chaining convenience
- Throws:
IllegalArgumentException
- If any of the provided bits are negative or higher thanPermission.ALL_PERMISSIONS
- See Also:
setPermissions(java.util.Collection, java.util.Collection)
,Permission.getRaw(Permission...)
,Permission.getRaw(Collection)
-
setPermissions
@Nonnull @CheckReturnValue default PermissionOverrideAction setPermissions(@Nullable Collection<Permission> grantPermissions, @Nullable Collection<Permission> denyPermissions)
Combination ofsetAllow(java.util.Collection)
andsetDeny(java.util.Collection)
First sets the granted permissions and then the denied permissions.
If a passed collection isnull
it resets the represented value to0
- no permission specifics.Example:
setPermissions(EnumSet.of(Permission.MESSAGE_READ), EnumSet.of(Permission.MESSAGE_WRITE, Permission.MESSAGE_EXT_EMOJI))
- Parameters:
grantPermissions
- A Collection ofPermissions
representing all explicitly granted Permissions for the PermissionOverridedenyPermissions
- A Collection ofPermissions
representing all explicitly denied Permissions for the PermissionOverride- Returns:
- The current PermissionOverrideAction - for chaining convenience
- Throws:
IllegalArgumentException
- If the any of the specified Permissions isnull
- See Also:
EnumSet
,Permission.getRaw(Collection)
-
-