Class RoleManager
- java.lang.Object
-
- net.dv8tion.jda.core.requests.RestAction<T>
-
- net.dv8tion.jda.core.requests.restaction.AuditableRestAction<java.lang.Void>
-
- net.dv8tion.jda.core.managers.impl.ManagerBase
-
- net.dv8tion.jda.core.managers.RoleManager
-
public class RoleManager extends net.dv8tion.jda.core.managers.impl.ManagerBase
Manager providing functionality to update one or more fields for aRole
.Example
manager.setName("Administrator") .setColor(null) .queue(); manager.reset(RoleManager.PERMISSION | RoleManager.NAME) .setName("Traitor") .setColor(Color.RED) .queue();
- See Also:
Role.getManager()
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class net.dv8tion.jda.core.requests.restaction.AuditableRestAction
AuditableRestAction.EmptyRestAction<T>
-
-
Field Summary
Fields Modifier and Type Field Description static long
COLOR
Used to reset the color fieldstatic long
HOIST
Used to reset the hoisted fieldstatic long
MENTIONABLE
Used to reset the mentionable fieldstatic long
NAME
Used to reset the name fieldstatic long
PERMISSION
Used to reset the permission field-
Fields inherited from class net.dv8tion.jda.core.requests.RestAction
DEFAULT_FAILURE, DEFAULT_SUCCESS, LOG
-
-
Constructor Summary
Constructors Constructor Description RoleManager(Role role)
Creates a new RoleManager instance
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Guild
getGuild()
Role
getRole()
The targetRole
for this managerRoleManager
givePermissions(java.util.Collection<Permission> perms)
Adds the specifiedPermissions
to the selectedRole
.RoleManager
givePermissions(Permission... perms)
Adds the specifiedPermissions
to the selectedRole
.RoleManager
reset()
Resets all fields for this manager.RoleManager
reset(long fields)
Resets the fields specified by the provided bit-flag pattern.RoleManager
reset(long... fields)
Resets the fields specified by the provided bit-flag patterns.RoleManager
revokePermissions(java.util.Collection<Permission> perms)
Revokes the specifiedPermissions
from the selectedRole
.RoleManager
revokePermissions(Permission... perms)
Revokes the specifiedPermissions
from the selectedRole
.RoleManager
setColor(int rgb)
Sets the rgb color of the selectedRole
.RoleManager
setColor(java.awt.Color color)
Sets theColor
of the selectedRole
.RoleManager
setHoisted(boolean hoisted)
Sets the hoist state of the selectedRole
.RoleManager
setMentionable(boolean mentionable)
Sets the mentionable state of the selectedRole
.RoleManager
setName(java.lang.String name)
Sets the name of the selectedRole
.RoleManager
setPermissions(long perms)
Sets thePermissions
of the selectedRole
.RoleManager
setPermissions(java.util.Collection<Permission> permissions)
Sets thePermissions
of the selectedRole
.RoleManager
setPermissions(Permission... permissions)
Sets thePermissions
of the selectedRole
.-
Methods inherited from class net.dv8tion.jda.core.managers.impl.ManagerBase
complete, isPermissionChecksEnabled, queue, setPermissionChecksEnabled
-
Methods inherited from class net.dv8tion.jda.core.requests.restaction.AuditableRestAction
reason, setCheck
-
Methods inherited from class net.dv8tion.jda.core.requests.RestAction
complete, completeAfter, getJDA, isPassContext, queue, queue, queueAfter, queueAfter, queueAfter, queueAfter, queueAfter, queueAfter, setPassContext, submit, submit, submitAfter, submitAfter
-
-
-
-
Field Detail
-
NAME
public static final long NAME
Used to reset the name field- See Also:
- Constant Field Values
-
COLOR
public static final long COLOR
Used to reset the color field- See Also:
- Constant Field Values
-
PERMISSION
public static final long PERMISSION
Used to reset the permission field- See Also:
- Constant Field Values
-
HOIST
public static final long HOIST
Used to reset the hoisted field- See Also:
- Constant Field Values
-
MENTIONABLE
public static final long MENTIONABLE
Used to reset the mentionable field- See Also:
- Constant Field Values
-
-
Method Detail
-
reset
@CheckReturnValue public RoleManager reset(long fields)
Resets the fields specified by the provided bit-flag pattern. You can specify a combination by using a bitwise OR concat of the flag constants.
Example:manager.reset(RoleManager.COLOR | RoleManager.NAME);
Flag Constants:
- Overrides:
reset
in classnet.dv8tion.jda.core.managers.impl.ManagerBase
- Parameters:
fields
- Integer value containing the flags to reset.- Returns:
- RoleManager for chaining convenience
-
reset
@CheckReturnValue public RoleManager reset(long... fields)
Resets the fields specified by the provided bit-flag patterns. You can specify a combination by using a bitwise OR concat of the flag constants.
Example:manager.reset(RoleManager.COLOR, RoleManager.NAME);
Flag Constants:
- Overrides:
reset
in classnet.dv8tion.jda.core.managers.impl.ManagerBase
- Parameters:
fields
- Integer values containing the flags to reset.- Returns:
- RoleManager for chaining convenience
-
reset
@CheckReturnValue public RoleManager reset()
Resets all fields for this manager.- Returns:
- RoleManager for chaining convenience
-
setName
@CheckReturnValue public RoleManager setName(java.lang.String name)
Sets the name of the selectedRole
.A role name must not be
null
nor less than 1 characters or more than 32 characters long!- Parameters:
name
- The new name for the selectedRole
- Returns:
- RoleManager for chaining convenience
- Throws:
java.lang.IllegalArgumentException
- If the provided name isnull
or not between 1-32 characters long
-
setPermissions
@CheckReturnValue public RoleManager setPermissions(long perms)
Sets thePermissions
of the selectedRole
.Permissions may only include already present Permissions for the currently logged in account.
You are unable to give permissions you don't have!- Parameters:
perms
- The new raw permission value for the selectedRole
- Returns:
- RoleManager for chaining convenience
- Throws:
InsufficientPermissionException
- If the currently logged in account does not have permission to apply one of the specified permissions- See Also:
setPermissions(Collection)
,setPermissions(Permission...)
-
setPermissions
@CheckReturnValue public RoleManager setPermissions(Permission... permissions)
Sets thePermissions
of the selectedRole
.Permissions may only include already present Permissions for the currently logged in account.
You are unable to give permissions you don't have!- Parameters:
permissions
- The new permission for the selectedRole
- Returns:
- RoleManager for chaining convenience
- Throws:
InsufficientPermissionException
- If the currently logged in account does not have permission to apply one of the specified permissionsjava.lang.IllegalArgumentException
- If any of the provided values isnull
- See Also:
setPermissions(Collection)
,setPermissions(long)
,Permission.getRaw(Permission...)
-
setPermissions
@CheckReturnValue public RoleManager setPermissions(java.util.Collection<Permission> permissions)
Sets thePermissions
of the selectedRole
.Permissions may only include already present Permissions for the currently logged in account.
You are unable to give permissions you don't have!- Parameters:
permissions
- The new permission for the selectedRole
- Returns:
- RoleManager for chaining convenience
- Throws:
InsufficientPermissionException
- If the currently logged in account does not have permission to apply one of the specified permissionsjava.lang.IllegalArgumentException
- If any of the provided values isnull
- See Also:
setPermissions(Permission...)
,setPermissions(long)
,EnumSet
,Permission.getRaw(Collection)
-
setColor
@CheckReturnValue public RoleManager setColor(java.awt.Color color)
Sets theColor
of the selectedRole
.- Parameters:
color
- The new color for the selectedRole
- Returns:
- RoleManager for chaining convenience
-
setColor
@CheckReturnValue public RoleManager setColor(int rgb)
Sets the rgb color of the selectedRole
.- Parameters:
rgb
- The new color for the selectedRole
- Returns:
- RoleManager for chaining convenience
- See Also:
Role.DEFAULT_COLOR_RAW
-
setHoisted
@CheckReturnValue public RoleManager setHoisted(boolean hoisted)
Sets the hoist state of the selectedRole
.- Parameters:
hoisted
- Whether the selectedRole
should be hoisted- Returns:
- RoleManager for chaining convenience
-
setMentionable
@CheckReturnValue public RoleManager setMentionable(boolean mentionable)
Sets the mentionable state of the selectedRole
.- Parameters:
mentionable
- Whether the selectedRole
should be mentionable- Returns:
- RoleManager for chaining convenience
-
givePermissions
@CheckReturnValue public RoleManager givePermissions(Permission... perms)
Adds the specifiedPermissions
to the selectedRole
.Permissions may only include already present Permissions for the currently logged in account.
You are unable to give permissions you don't have!- Parameters:
perms
- The permission to give to the selectedRole
- Returns:
- RoleManager for chaining convenience
- Throws:
InsufficientPermissionException
- If the currently logged in account does not have permission to apply one of the specified permissions- See Also:
setPermissions(Collection)
,setPermissions(Permission...)
,Permission.getRaw(Permission...)
-
givePermissions
@CheckReturnValue public RoleManager givePermissions(java.util.Collection<Permission> perms)
Adds the specifiedPermissions
to the selectedRole
.Permissions may only include already present Permissions for the currently logged in account.
You are unable to give permissions you don't have!- Parameters:
perms
- The permission to give to the selectedRole
- Returns:
- RoleManager for chaining convenience
- Throws:
InsufficientPermissionException
- If the currently logged in account does not have permission to apply one of the specified permissions- See Also:
setPermissions(Collection)
,setPermissions(Permission...)
,EnumSet
,Permission.getRaw(Collection)
-
revokePermissions
@CheckReturnValue public RoleManager revokePermissions(Permission... perms)
Revokes the specifiedPermissions
from the selectedRole
.Permissions may only include already present Permissions for the currently logged in account.
You are unable to revoke permissions you don't have!- Parameters:
perms
- The permission to give to the selectedRole
- Returns:
- RoleManager for chaining convenience
- Throws:
InsufficientPermissionException
- If the currently logged in account does not have permission to revoke one of the specified permissions- See Also:
setPermissions(Collection)
,setPermissions(Permission...)
,Permission.getRaw(Permission...)
-
revokePermissions
@CheckReturnValue public RoleManager revokePermissions(java.util.Collection<Permission> perms)
Revokes the specifiedPermissions
from the selectedRole
.Permissions may only include already present Permissions for the currently logged in account.
You are unable to revoke permissions you don't have!- Parameters:
perms
- The permission to give to the selectedRole
- Returns:
- RoleManager for chaining convenience
- Throws:
InsufficientPermissionException
- If the currently logged in account does not have permission to revoke one of the specified permissions- See Also:
setPermissions(Collection)
,setPermissions(Permission...)
,EnumSet
,Permission.getRaw(Collection)
-
-