Interface Role
-
- All Superinterfaces:
Comparable<Role>,DiscordEntity,Formattable,Mentionable,Nameable,Permissionable,RoleAttachableListenerManager,Updatable<Role>,UpdatableFromCache<Role>
public interface Role extends DiscordEntity, Mentionable, Nameable, Permissionable, Comparable<Role>, UpdatableFromCache<Role>, RoleAttachableListenerManager
This class represents a Discord role, e.g. "moderator".
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default CompletableFuture<Void>addUser(User user)Adds the role to the given user.default CompletableFuture<Void>addUser(User user, String reason)Adds the role to the given user.default RoleUpdatercreateUpdater()Gets the updater for this role.CompletableFuture<Void>delete()Deletes the role.default Collection<PermissionType>getAllowedPermissions()Gets the allowed permissions of the role.Optional<Color>getColor()Gets the color of the role.default Optional<Role>getCurrentCachedInstance()Gets an updated instance of this entity from the cache.default StringgetMentionTag()Gets the tag used to mention the entity.PermissionsgetPermissions()Gets the permissions of the role.intgetPosition()Gets the position of the role.ServergetServer()Gets the server of the role.default Collection<PermissionType>getUnsetPermissions()Gets the unset permissions of the role.Collection<User>getUsers()Gets a collection with all users who have this role.booleanisDisplayedSeparately()Check if this role is pinned in the user listing (sometimes called "hoist").default booleanisEveryoneRole()Checks if the role is the @everyone role.booleanisManaged()Checks if this role is managed by an integration.booleanisMentionable()Check if this role is mentionable.default CompletableFuture<Void>removeUser(User user)Removes the role from the given user.default CompletableFuture<Void>removeUser(User user, String reason)Removes the role from the given user.default CompletableFuture<Void>updateColor(Color color)Updates the color of the role.default CompletableFuture<Void>updateDisplaySeparatelyFlag(boolean displaySeparately)Updates the display separately flag of the role.default CompletableFuture<Void>updateMentionableFlag(boolean mentionable)Updates the mentionable flag of the role.default CompletableFuture<Void>updateName(String name)Updates the name of the role.default CompletableFuture<Void>updatePermissions(Permissions permissions)Updates the permissions of the role.-
Methods inherited from interface java.lang.Comparable
compareTo
-
Methods inherited from interface org.javacord.api.entity.DiscordEntity
getApi, getCreationTimestamp, getCreationTimestamp, getId, getIdAsString
-
Methods inherited from interface org.javacord.api.listener.server.role.RoleAttachableListenerManager
addRoleAttachableListener, addRoleChangeColorListener, addRoleChangeHoistListener, addRoleChangeMentionableListener, addRoleChangeNameListener, addRoleChangePermissionsListener, addRoleChangePositionListener, addRoleDeleteListener, addServerChannelChangeOverwrittenPermissionsListener, addUserRoleAddListener, addUserRoleRemoveListener, getRoleAttachableListeners, getRoleChangeColorListeners, getRoleChangeHoistListeners, getRoleChangeMentionableListeners, getRoleChangeNameListeners, getRoleChangePermissionsListeners, getRoleChangePositionListeners, getRoleDeleteListeners, getServerChannelChangeOverwrittenPermissionsListeners, getUserRoleAddListeners, getUserRoleRemoveListeners, removeListener, removeRoleAttachableListener
-
Methods inherited from interface org.javacord.api.entity.UpdatableFromCache
getLatestInstance
-
-
-
-
Method Detail
-
getServer
Server getServer()
Gets the server of the role.- Returns:
- The server of the role.
-
getPosition
int getPosition()
Gets the position of the role.- Returns:
- The position of the role.
-
isMentionable
boolean isMentionable()
Check if this role is mentionable.- Returns:
- Whether this role is mentionable or not.
-
isDisplayedSeparately
boolean isDisplayedSeparately()
Check if this role is pinned in the user listing (sometimes called "hoist").- Returns:
- Whether this role is pinned in the user listing or not.
-
getUsers
Collection<User> getUsers()
Gets a collection with all users who have this role.- Returns:
- A collection with all users who have this role.
-
getPermissions
Permissions getPermissions()
Gets the permissions of the role.- Returns:
- The permissions of the role.
-
isManaged
boolean isManaged()
Checks if this role is managed by an integration.- Returns:
- Whether this role is managed by an integration or not.
-
isEveryoneRole
default boolean isEveryoneRole()
Checks if the role is the @everyone role.- Returns:
- Whether the role is the @everyone role or not.
-
createUpdater
default RoleUpdater createUpdater()
Gets the updater for this role.- Returns:
- The updater for this role.
-
updateName
default CompletableFuture<Void> updateName(String name)
Updates the name of the role.If you want to update several settings at once, it's recommended to use the
RoleUpdaterfromcreateUpdater()which provides a better performance!- Parameters:
name- The new name of the role.- Returns:
- A future to check if the update was successful.
-
updatePermissions
default CompletableFuture<Void> updatePermissions(Permissions permissions)
Updates the permissions of the role.If you want to update several settings at once, it's recommended to use the
RoleUpdaterfromcreateUpdater()which provides a better performance!- Parameters:
permissions- The new permissions of the role.- Returns:
- A future to check if the update was successful.
-
updateColor
default CompletableFuture<Void> updateColor(Color color)
Updates the color of the role.If you want to update several settings at once, it's recommended to use the
RoleUpdaterfromcreateUpdater()which provides a better performance!- Parameters:
color- The new color of the role.- Returns:
- A future to check if the update was successful.
-
updateDisplaySeparatelyFlag
default CompletableFuture<Void> updateDisplaySeparatelyFlag(boolean displaySeparately)
Updates the display separately flag of the role.If you want to update several settings at once, it's recommended to use the
RoleUpdaterfromcreateUpdater()which provides a better performance!- Parameters:
displaySeparately- The new display separately flag of the role.- Returns:
- A future to check if the update was successful.
-
updateMentionableFlag
default CompletableFuture<Void> updateMentionableFlag(boolean mentionable)
Updates the mentionable flag of the role.If you want to update several settings at once, it's recommended to use the
RoleUpdaterfromcreateUpdater()which provides a better performance!- Parameters:
mentionable- The new mentionable flag of the role.- Returns:
- A future to check if the update was successful.
-
addUser
default CompletableFuture<Void> addUser(User user)
Adds the role to the given user.If you want to update several settings at once, it's recommended to use the
ServerUpdaterfromServer.createUpdater()which provides a better performance!- Parameters:
user- The user the role should be added to.- Returns:
- A future to check if the update was successful.
- See Also:
Server.addRoleToUser(User, Role)
-
addUser
default CompletableFuture<Void> addUser(User user, String reason)
Adds the role to the given user.If you want to update several settings at once, it's recommended to use the
ServerUpdaterfromServer.createUpdater()which provides a better performance!- Parameters:
user- The user the role should be added to.reason- The audit log reason for this update.- Returns:
- A future to check if the update was successful.
- See Also:
Server.addRoleToUser(User, Role, String)
-
removeUser
default CompletableFuture<Void> removeUser(User user)
Removes the role from the given user.If you want to update several settings at once, it's recommended to use the
ServerUpdaterfromServer.createUpdater()which provides a better performance!- Parameters:
user- The user the role should be removed from.- Returns:
- A future to check if the update was successful.
- See Also:
Server.removeRoleFromUser(User, Role)
-
removeUser
default CompletableFuture<Void> removeUser(User user, String reason)
Removes the role from the given user.If you want to update several settings at once, it's recommended to use the
ServerUpdaterfromServer.createUpdater()which provides a better performance!- Parameters:
user- The user the role should be removed from.reason- The audit log reason for this update.- Returns:
- A future to check if the update was successful.
- See Also:
Server.removeRoleFromUser(User, Role, String)
-
delete
CompletableFuture<Void> delete()
Deletes the role.- Returns:
- A future to check if the deletion was successful.
-
getAllowedPermissions
default Collection<PermissionType> getAllowedPermissions()
Gets the allowed permissions of the role.- Returns:
- The allowed permissions of the role.
-
getUnsetPermissions
default Collection<PermissionType> getUnsetPermissions()
Gets the unset permissions of the role.- Returns:
- The unset permissions of the role.
-
getMentionTag
default String getMentionTag()
Description copied from interface:MentionableGets the tag used to mention the entity.- Specified by:
getMentionTagin interfaceMentionable- Returns:
- The tag used to mention the entity.
-
getCurrentCachedInstance
default Optional<Role> getCurrentCachedInstance()
Description copied from interface:UpdatableFromCacheGets an updated instance of this entity from the cache. This is for example necessary if an instance got invalid by a reconnect to Discord which invalidates all existing instances which means they do not get any further updates from Discord applied. Due to that, references to instances should usually not be held for an extended period of time. If they are, this method can be used to retrieve the current instance from the cache, that gets updates from Discord, in case this one was invalidated.This method returns the currently cached entity, or an empty
Optionalif the entity is not cached any longer, for example because it was deleted or the message was thrown out of the cache.- Specified by:
getCurrentCachedInstancein interfaceUpdatableFromCache<Role>- Returns:
- The current cached instance.
-
-