Interface PermissionOverrideAction
- All Superinterfaces:
AuditableRestAction<PermissionOverride>,RestAction<PermissionOverride>
AuditableRestAction specifically
designed to create a PermissionOverride
for a GuildChannel.
This extension allows setting properties before executing the action.- Since:
- 3.0
- See Also:
-
Field Summary
Fields inherited from interface net.dv8tion.jda.api.requests.restaction.AuditableRestAction
MAX_REASON_LENGTH -
Method Summary
Modifier and TypeMethodDescriptionclear(long inheritedBits) Clears the providedPermissionsbits from thePermissionOverride.default PermissionOverrideActionclear(Collection<Permission> permissions) Clears the providedPermissionsbits from thePermissionOverride.default PermissionOverrideActionclear(Permission... permissions) Clears the providedPermissionsbits from thePermissionOverride.deadline(long timestamp) Similar toRestAction.timeout(long, TimeUnit)but schedules a deadline at which the request has to be completed.deny(long denyBits) Denies the specified permissions.default PermissionOverrideActiondeny(Collection<Permission> permissions) Denies the specified permissions.default PermissionOverrideActiondeny(Permission... permissions) Denies the specified permissions.longThe currently set of allowed permission bits.default EnumSet<Permission> Set ofPermissionsthat would be granted by the PermissionOverride that is created by this action.TheIPermissionContainerthis will be created inlongThe currently set of denied permission bits.default EnumSet<Permission> Set ofPermissionsthat would be denied by the PermissionOverride that is created by this action.default GuildgetGuild()TheGuildfor this overridelongThe currently set of inherited permission bits.default EnumSet<Permission> Set ofPermissionsthat would be inherited from other permission holders.TheMemberfor this overridegetRole()TheRolefor this overridegrant(long allowBits) Grants the specified permissions.default PermissionOverrideActiongrant(Collection<Permission> permissions) Grants the specified permissions.default PermissionOverrideActiongrant(Permission... permissions) Grants the specified permissions.booleanisMember()Whether this Action will create aPermissionOverridefor aMemberor notbooleanisRole()Whether this Action will create aPermissionOverridefor aRoleor notdefault PermissionOverrideActionreset()Shortcut forresetAllow().resetDeny().Resets the allowed permissions to the current original value.Resets the denied permissions to the current original value.setAllowed(long allowBits) Sets the value of explicitly granted permissions using the bitwise representation of a set ofPermissions.default PermissionOverrideActionsetAllowed(Collection<Permission> permissions) Sets the value of explicitly granted permissions using a Collection ofPermissions.default PermissionOverrideActionsetAllowed(Permission... permissions) Sets the value of explicitly granted permissions using a set ofPermissions.setCheck(BooleanSupplier checks) Sets the last-second checks before finally executing the http request in the queue.setDenied(long denyBits) Sets the value of explicitly denied permissions using the bitwise representation of a set ofPermissions.default PermissionOverrideActionsetDenied(Collection<Permission> permissions) Sets the value of explicitly denied permissions using a Collection ofPermissions.default PermissionOverrideActionsetDenied(Permission... permissions) Sets the value of explicitly denied permissions using a set ofPermissions.setPermissions(long allowBits, long denyBits) Combination ofsetAllowed(long)andsetDenied(long)
First sets the allow bits and then the deny bits.default PermissionOverrideActionsetPermissions(Collection<Permission> grantPermissions, Collection<Permission> denyPermissions) Combination ofsetAllowed(java.util.Collection)andsetDenied(java.util.Collection)
First sets the granted permissions and then the denied permissions.Timeout for this RestAction instance.Methods inherited from interface net.dv8tion.jda.api.requests.restaction.AuditableRestAction
reasonMethods inherited from interface net.dv8tion.jda.api.requests.RestAction
addCheck, and, and, complete, complete, completeAfter, delay, delay, delay, delay, flatMap, flatMap, getCheck, getJDA, map, mapToResult, onErrorFlatMap, onErrorFlatMap, onErrorMap, onErrorMap, onSuccess, queue, queue, queue, queueAfter, queueAfter, queueAfter, queueAfter, queueAfter, queueAfter, submit, submit, submitAfter, submitAfter, zip
-
Method Details
-
setCheck
Description copied from interface:AuditableRestActionSets the last-second checks before finally executing the http request in the queue.
If the provided supplier evaluates tofalseor 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:
setCheckin interfaceAuditableRestAction<PermissionOverride>- Specified by:
setCheckin interfaceRestAction<PermissionOverride>- Parameters:
checks- The checks to run before executing the request, ornullto run no checks- Returns:
- The current RestAction for chaining convenience
- See Also:
-
timeout
Description copied from interface:AuditableRestActionTimeout for this RestAction instance.
If the request doesn't get executed within the timeout it will fail.When a RestAction times out, it will fail with a
TimeoutException. This is the same asdeadline(System.currentTimeMillis() + unit.toMillis(timeout)).Example
action.timeout(10, TimeUnit.SECONDS) // 10 seconds from now .queueAfter(20, SECONDS); // request will not be executed within deadline and timeout immediately after 20 seconds- Specified by:
timeoutin interfaceAuditableRestAction<PermissionOverride>- Specified by:
timeoutin interfaceRestAction<PermissionOverride>- Parameters:
timeout- The timeout to useunit-Unitfor the timeout value- Returns:
- The same RestAction instance with the applied timeout
- See Also:
-
deadline
Description copied from interface:AuditableRestActionSimilar toRestAction.timeout(long, TimeUnit)but schedules a deadline at which the request has to be completed.
If the deadline is reached, the request will fail with aTimeoutException.This does not mean that the request will immediately timeout when the deadline is reached. JDA will check the deadline right before executing the request or within intervals in a worker thread. This only means the request will timeout if the deadline has passed.
Example
action.deadline(System.currentTimeMillis() + 10000) // 10 seconds from now .queueAfter(20, SECONDS); // request will not be executed within deadline and timeout immediately after 20 seconds- Specified by:
deadlinein interfaceAuditableRestAction<PermissionOverride>- Specified by:
deadlinein interfaceRestAction<PermissionOverride>- Parameters:
timestamp- Millisecond timestamp at which the request will timeout- Returns:
- The same RestAction with the applied deadline
- See Also:
-
reset
Shortcut forresetAllow().resetDeny().
The permission override will be empty after this operation- Returns:
- The current PermissionOverrideAction for chaining convenience
-
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
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
TheIPermissionContainerthis will be created in- Returns:
- The channel
-
getRole
TheRolefor this override- Returns:
- The role, or null if this is a member override
-
getMember
TheMemberfor this override- Returns:
- The member, or null if this is a role override
-
getGuild
TheGuildfor this override- Returns:
- The guild
-
getAllowed
long getAllowed()The currently set of allowed permission bits.
This value represents all granted permissions in the raw bitwise representation.Use
getAllowedPermissions()to retrieve aListwithPermissionsfor this value- Returns:
- long value of granted permissions
-
getAllowedPermissions
Set ofPermissionsthat 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
-
getDenied
long getDenied()The currently set of denied permission bits.
This value represents all denied permissions in the raw bitwise representation.Use
getDeniedPermissions()to retrieve aListwithPermissionsfor this value- Returns:
- long value of denied permissions
-
getDeniedPermissions
Set ofPermissionsthat 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 aListwithPermissionsfor this value- Returns:
- long value of inherited permissions
-
getInheritedPermissions
Set ofPermissionsthat 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:
-
isMember
boolean isMember()Whether this Action will create aPermissionOverridefor aMemberor not -
isRole
boolean isRole()Whether this Action will create aPermissionOverridefor aRoleor not- Returns:
- True, if this is targeting a Role.
If this is
falseit is targeting aMember. (isMember())
-
setAllowed
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:
InsufficientPermissionException- If the currently logged in account does not havePermission.MANAGE_PERMISSIONSon the channel and tries to set permissions it does not have in the channel- See Also:
-
setAllowed
@Nonnull @CheckReturnValue default PermissionOverrideAction setAllowed(@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.VIEW_CHANNEL))- Parameters:
permissions- The Collection of Permissions representing the granted permissions for the new PermissionOverride.
If the provided value isnullthe permissions are reset to the default of none- Returns:
- The current PermissionOverrideAction - for chaining convenience
- Throws:
IllegalArgumentException- If the any of the specified Permissions isnullInsufficientPermissionException- If the currently logged in account does not havePermission.MANAGE_PERMISSIONSon the channel and tries to set permissions it does not have in the channel- See Also:
-
setAllowed
@Nonnull @CheckReturnValue default PermissionOverrideAction setAllowed(@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 isnullthe permissions are reset to the default of none- Returns:
- The current PermissionOverrideAction - for chaining convenience
- Throws:
IllegalArgumentException- If the any of the specified Permissions isnullInsufficientPermissionException- If the currently logged in account does not havePermission.MANAGE_PERMISSIONSon the channel and tries to set permissions it does not have in the channel
-
grant
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
- Throws:
InsufficientPermissionException- If the currently logged in account does not havePermission.MANAGE_PERMISSIONSon the channel and tries to set permissions it does not have in the channel
-
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:
InsufficientPermissionException- If the currently logged in account does not havePermission.MANAGE_PERMISSIONSon the channel and tries to set permissions it does not have in the channelIllegalArgumentException- 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:
InsufficientPermissionException- If the currently logged in account does not havePermission.MANAGE_PERMISSIONSon the channel and tries to set permissions it does not have in the channelIllegalArgumentException- If any provided argument is null
-
setDenied
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:
InsufficientPermissionException- If the currently logged in account does not havePermission.MANAGE_PERMISSIONSon the channel and tries to set permissions it does not have in the channel- See Also:
-
setDenied
@Nonnull @CheckReturnValue default PermissionOverrideAction setDenied(@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_SEND, Permission.MESSAGE_EXT_EMOJI))- Parameters:
permissions- The Collection of Permissions representing the denied permissions for the new PermissionOverride.
If the provided value isnullthe permissions are reset to the default of none- Returns:
- The current PermissionOverrideAction - for chaining convenience
- Throws:
IllegalArgumentException- If the any of the specified Permissions isnullInsufficientPermissionException- If the currently logged in account does not havePermission.MANAGE_PERMISSIONSon the channel and tries to set permissions it does not have in the channel- See Also:
-
setDenied
@Nonnull @CheckReturnValue default PermissionOverrideAction setDenied(@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 isnullthe permissions are reset to the default of none- Returns:
- The current PermissionOverrideAction - for chaining convenience
- Throws:
InsufficientPermissionException- If the currently logged in account does not havePermission.MANAGE_PERMISSIONSon the channel and tries to set permissions it does not have in the channelIllegalArgumentException- If the any of the specified Permissions isnull
-
deny
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
- Throws:
InsufficientPermissionException- If the currently logged in account does not havePermission.MANAGE_PERMISSIONSon the channel and tries to set permissions it does not have in the channel
-
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:
InsufficientPermissionException- If the currently logged in account does not havePermission.MANAGE_PERMISSIONSon the channel and tries to set permissions it does not have in the channelIllegalArgumentException- 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:
InsufficientPermissionException- If the currently logged in account does not havePermission.MANAGE_PERMISSIONSon the channel and tries to set permissions it does not have in the channelIllegalArgumentException- If any provided argument is null
-
clear
Clears the providedPermissionsbits 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
- Throws:
InsufficientPermissionException- If the currently logged in account does not havePermission.MANAGE_PERMISSIONSon the channel and tries to set permissions it does not have in the channel
-
clear
@Nonnull @CheckReturnValue default PermissionOverrideAction clear(@Nonnull Collection<Permission> permissions) Clears the providedPermissionsbits 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:
InsufficientPermissionException- If the currently logged in account does not havePermission.MANAGE_PERMISSIONSon the channel and tries to set permissions it does not have in the channelIllegalArgumentException- If any provided argument is null
-
clear
@Nonnull @CheckReturnValue default PermissionOverrideAction clear(@Nonnull Permission... permissions) Clears the providedPermissionsbits 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:
InsufficientPermissionException- If the currently logged in account does not havePermission.MANAGE_PERMISSIONSon the channel and tries to set permissions it does not have in the channelIllegalArgumentException- If any provided argument is null
-
setPermissions
Combination ofsetAllowed(long)andsetDenied(long)
First sets the allow bits and then the deny bits.- Parameters:
allowBits- An unsigned bitwise representation of granted PermissionsdenyBits- An unsigned bitwise representation of denied Permissions- Returns:
- The current PermissionOverrideAction - for chaining convenience
- Throws:
InsufficientPermissionException- If the currently logged in account does not havePermission.MANAGE_PERMISSIONSon the channel and tries to set permissions it does not have in the channel- See Also:
-
setPermissions
@Nonnull @CheckReturnValue default PermissionOverrideAction setPermissions(@Nullable Collection<Permission> grantPermissions, @Nullable Collection<Permission> denyPermissions) Combination ofsetAllowed(java.util.Collection)andsetDenied(java.util.Collection)
First sets the granted permissions and then the denied permissions.
If a passed collection isnullit resets the represented value to0- no permission specifics.Example:
setPermissions(EnumSet.of(Permission.VIEW_CHANNEL), EnumSet.of(Permission.MESSAGE_SEND, Permission.MESSAGE_EXT_EMOJI))- Parameters:
grantPermissions- A Collection ofPermissionsrepresenting all explicitly granted Permissions for the PermissionOverridedenyPermissions- A Collection ofPermissionsrepresenting all explicitly denied Permissions for the PermissionOverride- Returns:
- The current PermissionOverrideAction - for chaining convenience
- Throws:
IllegalArgumentException- If the any of the specified Permissions isnullInsufficientPermissionException- If the currently logged in account does not havePermission.MANAGE_PERMISSIONSon the channel and tries to set permissions it does not have in the channel- See Also:
-