Interface Role

    • Method Detail

      • getServer

        Server getServer()
        Gets the server of the role.
        Returns:
        The server of the role.
      • getRoleTags

        java.util.Optional<RoleTags> getRoleTags()
        Gets the role tags of the role.
        Returns:
        The role tags of the role.
      • getPosition

        default int getPosition()
        Gets the real position of the role.

        Will return -1 if the Role got deleted.

        Returns:
        The real position of the role.
      • getRawPosition

        int getRawPosition()
        Gets the raw position of the role.

        This is the position that gets send by discord. It might not be unique and there might be a gap between roles.

        Returns:
        The raw position of the role.
      • getColor

        java.util.Optional<java.awt.Color> getColor()
        Gets the color of the role.
        Returns:
        The color of the role.
      • getIconHash

        java.util.Optional<java.lang.String> getIconHash()
        Gets the hash of the role's icon.
        Returns:
        The hash of the role's icon.
      • getIcon

        java.util.Optional<Icon> getIcon()
        Gets the Icon of the role.
        Returns:
        The role's icon.
      • getIcon

        java.util.Optional<Icon> getIcon​(int size)
        Gets the Icon of the role.
        Parameters:
        size - The size of the image, must be a power of 2 between 16 and 4096.
        Returns:
        The role's icon in the given size.
      • getUnicodeEmojiIcon

        java.util.Optional<java.lang.String> getUnicodeEmojiIcon()
        Gets the unicode emoji role icon.
        Returns:
        The unicode emoji role icon.
      • 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

        java.util.Collection<User> getUsers()
        Gets a collection with all users who have this role.
        Returns:
        A collection with all users who have this role.
      • hasUser

        boolean hasUser​(User user)
        Checks whether the specified user has this role.
        Parameters:
        user - the user to check
        Returns:
        true if the user has this role; false otherwise
      • 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 java.util.concurrent.CompletableFuture<java.lang.Void> updateName​(java.lang.String name)
        Updates the name of the role.

        If you want to update several settings at once, it's recommended to use the RoleUpdater from createUpdater() 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 java.util.concurrent.CompletableFuture<java.lang.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 RoleUpdater from createUpdater() 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 java.util.concurrent.CompletableFuture<java.lang.Void> updateColor​(java.awt.Color color)
        Updates the color of the role.

        If you want to update several settings at once, it's recommended to use the RoleUpdater from createUpdater() 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 java.util.concurrent.CompletableFuture<java.lang.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 RoleUpdater from createUpdater() 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 java.util.concurrent.CompletableFuture<java.lang.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 RoleUpdater from createUpdater() 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 java.util.concurrent.CompletableFuture<java.lang.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 ServerUpdater from Server.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 java.util.concurrent.CompletableFuture<java.lang.Void> addUser​(User user,
                                                                               java.lang.String reason)
        Adds the role to the given user.

        If you want to update several settings at once, it's recommended to use the ServerUpdater from Server.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 java.util.concurrent.CompletableFuture<java.lang.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 ServerUpdater from Server.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 java.util.concurrent.CompletableFuture<java.lang.Void> removeUser​(User user,
                                                                                  java.lang.String reason)
        Removes the role from the given user.

        If you want to update several settings at once, it's recommended to use the ServerUpdater from Server.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

        java.util.concurrent.CompletableFuture<java.lang.Void> delete()
        Deletes the role.
        Returns:
        A future to check if the deletion was successful.
      • getAllowedPermissions

        default java.util.Collection<PermissionType> getAllowedPermissions()
        Gets the allowed permissions of the role.
        Returns:
        The allowed permissions of the role.
      • getUnsetPermissions

        default java.util.Collection<PermissionType> getUnsetPermissions()
        Gets the unset permissions of the role.
        Returns:
        The unset permissions of the role.
      • getMentionTag

        default java.lang.String getMentionTag()
        Description copied from interface: Mentionable
        Gets the tag used to mention the entity.
        Specified by:
        getMentionTag in interface Mentionable
        Returns:
        The tag used to mention the entity.
      • getCurrentCachedInstance

        default java.util.Optional<Role> getCurrentCachedInstance()
        Description copied from interface: UpdatableFromCache
        Gets 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 Optional if the entity is not cached any longer, for example because it was deleted or the message was thrown out of the cache.

        Specified by:
        getCurrentCachedInstance in interface UpdatableFromCache<Role>
        Returns:
        The current cached instance.