Class PermissionOverrideActionImpl
- All Implemented Interfaces:
RestAction<PermissionOverride>
,AuditableRestAction<PermissionOverride>
,PermissionOverrideAction
-
Field Summary
Fields inherited from class net.dv8tion.jda.internal.requests.RestActionImpl
LOG
Fields inherited from interface net.dv8tion.jda.api.requests.restaction.AuditableRestAction
MAX_REASON_LENGTH
-
Constructor Summary
ConstructorsConstructorDescriptionPermissionOverrideActionImpl
(JDA api, GuildChannel channel, IPermissionHolder permissionHolder) -
Method Summary
Modifier and TypeMethodDescriptionclear
(long inheritedBits) Clears the providedPermissions
bits 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.long
The currently set of allowed permission bits.TheIPermissionContainer
this will be created inlong
The currently set of denied permission bits.long
The currently set of inherited permission bits.TheMember
for this overridegetRole()
TheRole
for this overridegrant
(long allowBits) 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 notResets 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
.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
.setOverride
(boolean override) setPermissions
(long allowBits, long denyBits) Combination ofPermissionOverrideAction.setAllowed(long)
andPermissionOverrideAction.setDenied(long)
First sets the allow bits and then the deny bits.Timeout for this RestAction instance.Methods inherited from class net.dv8tion.jda.internal.requests.restaction.AuditableRestActionImpl
reason
Methods inherited from class net.dv8tion.jda.internal.requests.RestActionImpl
complete, getCheck, getDefaultFailure, getDefaultSuccess, getDefaultTimeout, getJDA, handleResponse, isPassContext, priority, queue, setDefaultFailure, setDefaultSuccess, setDefaultTimeout, setErrorMapper, setPassContext, submit
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface net.dv8tion.jda.api.requests.restaction.AuditableRestAction
reason
Methods inherited from interface net.dv8tion.jda.api.requests.restaction.PermissionOverrideAction
clear, clear, deny, deny, getAllowedPermissions, getDeniedPermissions, getGuild, getInheritedPermissions, grant, grant, reset, setAllowed, setAllowed, setDenied, setDenied, setPermissions
Methods 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
-
Constructor Details
-
PermissionOverrideActionImpl
-
PermissionOverrideActionImpl
public PermissionOverrideActionImpl(JDA api, GuildChannel channel, IPermissionHolder permissionHolder)
-
-
Method Details
-
setOverride
-
setCheck
Description copied from interface:RestAction
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 interfacePermissionOverrideAction
- Specified by:
setCheck
in interfaceRestAction<PermissionOverride>
- Overrides:
setCheck
in classAuditableRestActionImpl<PermissionOverride>
- Parameters:
checks
- The checks to run before executing the request, ornull
to run no checks- Returns:
- The current RestAction for chaining convenience
- See Also:
-
timeout
Description copied from interface:AuditableRestAction
Timeout 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:
timeout
in interfaceAuditableRestAction<PermissionOverride>
- Specified by:
timeout
in interfacePermissionOverrideAction
- Specified by:
timeout
in interfaceRestAction<PermissionOverride>
- Overrides:
timeout
in classAuditableRestActionImpl<PermissionOverride>
- Parameters:
timeout
- The timeout to useunit
-Unit
for the timeout value- Returns:
- The same RestAction instance with the applied timeout
- See Also:
-
deadline
Description copied from interface:RestAction
Similar 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:
deadline
in interfaceAuditableRestAction<PermissionOverride>
- Specified by:
deadline
in interfacePermissionOverrideAction
- Specified by:
deadline
in interfaceRestAction<PermissionOverride>
- Overrides:
deadline
in classAuditableRestActionImpl<PermissionOverride>
- Parameters:
timestamp
- Millisecond timestamp at which the request will timeout- Returns:
- The same RestAction with the applied deadline
- See Also:
-
resetAllow
Description copied from interface:PermissionOverrideAction
Resets the allowed permissions to the current original value.
For a new override this will just be 0.- Specified by:
resetAllow
in interfacePermissionOverrideAction
- Returns:
- The current PermissionOverrideAction for chaining convenience
-
resetDeny
Description copied from interface:PermissionOverrideAction
Resets the denied permissions to the current original value.
For a new override this will just be 0.- Specified by:
resetDeny
in interfacePermissionOverrideAction
- Returns:
- The current PermissionOverrideAction for chaining convenience
-
getChannel
Description copied from interface:PermissionOverrideAction
TheIPermissionContainer
this will be created in- Specified by:
getChannel
in interfacePermissionOverrideAction
- Returns:
- The channel
-
getRole
Description copied from interface:PermissionOverrideAction
TheRole
for this override- Specified by:
getRole
in interfacePermissionOverrideAction
- Returns:
- The role, or null if this is a member override
-
getMember
Description copied from interface:PermissionOverrideAction
TheMember
for this override- Specified by:
getMember
in interfacePermissionOverrideAction
- Returns:
- The member, or null if this is a role override
-
getAllowed
public long getAllowed()Description copied from interface:PermissionOverrideAction
The currently set of allowed permission bits.
This value represents all granted permissions in the raw bitwise representation.Use
PermissionOverrideAction.getAllowedPermissions()
to retrieve aList
withPermissions
for this value- Specified by:
getAllowed
in interfacePermissionOverrideAction
- Returns:
- long value of granted permissions
-
getDenied
public long getDenied()Description copied from interface:PermissionOverrideAction
The currently set of denied permission bits.
This value represents all denied permissions in the raw bitwise representation.Use
PermissionOverrideAction.getDeniedPermissions()
to retrieve aList
withPermissions
for this value- Specified by:
getDenied
in interfacePermissionOverrideAction
- Returns:
- long value of denied permissions
-
getInherited
public long getInherited()Description copied from interface:PermissionOverrideAction
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
PermissionOverrideAction.getInheritedPermissions()
to retrieve aList
withPermissions
for this value- Specified by:
getInherited
in interfacePermissionOverrideAction
- Returns:
- long value of inherited permissions
-
isMember
public boolean isMember()Description copied from interface:PermissionOverrideAction
Whether this Action will create aPermissionOverride
for aMember
or not- Specified by:
isMember
in interfacePermissionOverrideAction
- Returns:
- True, if this is targeting a Member
If this is
false
it is targeting aRole
. (PermissionOverrideAction.isRole()
)
-
isRole
public boolean isRole()Description copied from interface:PermissionOverrideAction
Whether this Action will create aPermissionOverride
for aRole
or not- Specified by:
isRole
in interfacePermissionOverrideAction
- Returns:
- True, if this is targeting a Role.
If this is
false
it is targeting aMember
. (PermissionOverrideAction.isMember()
)
-
setAllowed
Description copied from interface:PermissionOverrideAction
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;
- Specified by:
setAllowed
in interfacePermissionOverrideAction
- Parameters:
allowBits
- The positive bits representing the granted permissions for the new PermissionOverride- Returns:
- The current PermissionOverrideAction - for chaining convenience
- See Also:
-
grant
Description copied from interface:PermissionOverrideAction
Grants the specified permissions.
This does not override already granted permissions.- Specified by:
grant
in interfacePermissionOverrideAction
- Parameters:
allowBits
- The permissions to grant, in addition to already allowed permissions- Returns:
- The current PermissionOverrideAction - for chaining convenience
-
setDenied
Description copied from interface:PermissionOverrideAction
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;
- Specified by:
setDenied
in interfacePermissionOverrideAction
- Parameters:
denyBits
- The positive bits representing the denied permissions for the new PermissionOverride- Returns:
- The current PermissionOverrideAction - for chaining convenience
- See Also:
-
deny
Description copied from interface:PermissionOverrideAction
Denies the specified permissions.
This does not override already denied permissions.- Specified by:
deny
in interfacePermissionOverrideAction
- Parameters:
denyBits
- The permissions to deny, in addition to already denied permissions- Returns:
- The current PermissionOverrideAction - for chaining convenience
-
clear
Description copied from interface:PermissionOverrideAction
Clears the providedPermissions
bits from thePermissionOverride
.
This will cause the provided Permissions to be inherited from other overrides or roles.- Specified by:
clear
in interfacePermissionOverrideAction
- Parameters:
inheritedBits
- The permissions to clear from thePermissionOverride
- Returns:
- The current PermissionOverrideAction - for chaining convenience
-
setPermissions
@Nonnull @CheckReturnValue public PermissionOverrideActionImpl setPermissions(long allowBits, long denyBits) Description copied from interface:PermissionOverrideAction
Combination ofPermissionOverrideAction.setAllowed(long)
andPermissionOverrideAction.setDenied(long)
First sets the allow bits and then the deny bits.- Specified by:
setPermissions
in interfacePermissionOverrideAction
- Parameters:
allowBits
- An unsigned bitwise representation of granted PermissionsdenyBits
- An unsigned bitwise representation of denied Permissions- Returns:
- The current PermissionOverrideAction - for chaining convenience
- See Also:
-