Class PermissionOverrideAction
- java.lang.Object
-
- net.dv8tion.jda.core.requests.RestAction<T>
-
- net.dv8tion.jda.core.requests.restaction.AuditableRestAction<PermissionOverride>
-
- net.dv8tion.jda.core.requests.restaction.PermissionOverrideAction
-
public class PermissionOverrideAction extends AuditableRestAction<PermissionOverride>
Extension ofRestAction
specifically designed to create aPermissionOverride
for aChannel
. This extension allows setting properties before executing the action.- Since:
- 3.0
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class net.dv8tion.jda.core.requests.restaction.AuditableRestAction
AuditableRestAction.EmptyRestAction<T>
-
-
Field Summary
-
Fields inherited from class net.dv8tion.jda.core.requests.RestAction
DEFAULT_FAILURE, DEFAULT_SUCCESS, LOG
-
-
Constructor Summary
Constructors Constructor Description PermissionOverrideAction(JDA api, net.dv8tion.jda.core.requests.Route.CompiledRoute route, Channel channel, Member member)
Creates a new PermissionOverrideAction instancePermissionOverrideAction(JDA api, net.dv8tion.jda.core.requests.Route.CompiledRoute route, Channel channel, Role role)
Creates a new PermissionOverrideAction instance
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description long
getAllow()
The currently set of allowed permission bits.java.util.List<Permission>
getAllowedPermissions()
Immutable list ofPermissions
that would be granted by the PermissionOverride that is created by this action.java.util.List<Permission>
getDeniedPermissions()
Immutable list ofPermissions
that would be denied by the PermissionOverride that is created by this action.long
getDeny()
The currently set of denied permission bits.long
getInherited()
The currently set of inherited permission bits.java.util.List<Permission>
getInheritedPermissions()
Immutable list ofPermissions
that would be inherited from other permission holders.boolean
isMember()
Whether this Action will create aPermissionOverride
for aMember
or notboolean
isRole()
Whether this Action will create aPermissionOverride
for aRole
or notPermissionOverrideAction
setAllow(long allowBits)
Sets the value of explicitly granted permissions using the bitwise representation of a set ofPermissions
.PermissionOverrideAction
setAllow(java.util.Collection<Permission> permissions)
Sets the value of explicitly granted permissions using a Collection ofPermissions
.PermissionOverrideAction
setAllow(Permission... permissions)
Sets the value of explicitly granted permissions using a set ofPermissions
.PermissionOverrideAction
setCheck(java.util.function.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
.PermissionOverrideAction
setDeny(java.util.Collection<Permission> permissions)
Sets the value of explicitly denied permissions using a Collection ofPermissions
.PermissionOverrideAction
setDeny(Permission... permissions)
Sets the value of explicitly denied permissions using a set ofPermissions
.PermissionOverrideAction
setPermissions(long allowBits, long denyBits)
Combination ofsetAllow(long)
andsetDeny(long)
PermissionOverrideAction
setPermissions(java.util.Collection<Permission> grantPermissions, java.util.Collection<Permission> denyPermissions)
Combination ofsetAllow(java.util.Collection)
andsetDeny(java.util.Collection)
If a passed collection isnull
it resets the represented value to0
- no permission specifics.-
Methods inherited from class net.dv8tion.jda.core.requests.restaction.AuditableRestAction
reason
-
Methods inherited from class net.dv8tion.jda.core.requests.RestAction
complete, complete, completeAfter, getJDA, isPassContext, queue, queue, queue, queueAfter, queueAfter, queueAfter, queueAfter, queueAfter, queueAfter, setPassContext, submit, submit, submitAfter, submitAfter
-
-
-
-
Constructor Detail
-
PermissionOverrideAction
public PermissionOverrideAction(JDA api, net.dv8tion.jda.core.requests.Route.CompiledRoute route, Channel channel, Member member)
Creates a new PermissionOverrideAction instance
-
-
Method Detail
-
setCheck
public PermissionOverrideAction setCheck(java.util.function.BooleanSupplier checks)
Description copied from class: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.- Overrides:
setCheck
in classAuditableRestAction<PermissionOverride>
- Parameters:
checks
- The checks to run before executing the request, ornull
to run no checks- Returns:
- The current RestAction for chaining convenience
-
getAllow
public 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
public java.util.List<Permission> getAllowedPermissions()
Immutable list ofPermissions
that would be granted by the PermissionOverride that is created by this action.- Returns:
- immutable list of granted
Permissions
-
getDeny
public 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
public java.util.List<Permission> getDeniedPermissions()
Immutable list ofPermissions
that would be denied by the PermissionOverride that is created by this action.- Returns:
- immutable list of denied
Permissions
-
getInherited
public 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
public java.util.List<Permission> getInheritedPermissions()
Immutable list ofPermissions
that would be inherited from other permission holders.
Permissions returned are not explicitly granted or denied!- Returns:
- immutable list of inherited
Permissions
- See Also:
getInherited()
-
isMember
public boolean isMember()
Whether this Action will create aPermissionOverride
for aMember
or not
-
isRole
public 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
@CheckReturnValue public 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!- Parameters:
allowBits
- The positive bits representing the granted permissions for the new PermissionOverride- Returns:
- The current PermissionOverrideAction - for chaining convenience
- Throws:
java.lang.IllegalArgumentException
- If the provided bits are negative or higher thanPermission.ALL_PERMISSIONS
- See Also:
setAllow(Collection)
,setAllow(Permission...)
-
setAllow
@CheckReturnValue public PermissionOverrideAction setAllow(java.util.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:
java.lang.IllegalArgumentException
- If the any of the specified Permissions isnull
- See Also:
EnumSet
,setAllow(Permission...)
-
setAllow
@CheckReturnValue public PermissionOverrideAction setAllow(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:
java.lang.IllegalArgumentException
- If the any of the specified Permissions isnull
-
setDeny
@CheckReturnValue public 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!- Parameters:
denyBits
- The positive bits representing the denied permissions for the new PermissionOverride- Returns:
- The current PermissionOverrideAction - for chaining convenience
- Throws:
java.lang.IllegalArgumentException
- If the provided bits are negative or higher thanPermission.ALL_PERMISSIONS
- See Also:
setDeny(Collection)
,setDeny(Permission...)
-
setDeny
@CheckReturnValue public PermissionOverrideAction setDeny(java.util.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:
java.lang.IllegalArgumentException
- If the any of the specified Permissions isnull
- See Also:
EnumSet
,setDeny(Permission...)
-
setDeny
@CheckReturnValue public PermissionOverrideAction setDeny(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:
java.lang.IllegalArgumentException
- If the any of the specified Permissions isnull
-
setPermissions
@CheckReturnValue public PermissionOverrideAction setPermissions(long allowBits, long denyBits)
Combination ofsetAllow(long)
andsetDeny(long)
- Parameters:
allowBits
- A non-negative bitwise representation of granted PermissionsdenyBits
- A non-negative bitwise representation of denied Permissions- Returns:
- The current PermissionOverrideAction - for chaining convenience
- Throws:
java.lang.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
@CheckReturnValue public PermissionOverrideAction setPermissions(java.util.Collection<Permission> grantPermissions, java.util.Collection<Permission> denyPermissions)
Combination ofsetAllow(java.util.Collection)
andsetDeny(java.util.Collection)
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:
java.lang.IllegalArgumentException
- If the any of the specified Permissions isnull
- See Also:
EnumSet
,Permission.getRaw(Collection)
-
-