Class Role

    • Field Detail

      • DEFAULT_COLOR

        public static final Color DEFAULT_COLOR
        The default Color of a Role.
    • Constructor Detail

      • Role

        public Role​(GatewayDiscordClient gateway,
                    discord4j.discordjson.json.RoleData data,
                    long guildId)
        Constructs a Role with an associated GatewayDiscordClient and Discord data.
        Parameters:
        gateway - The GatewayDiscordClient associated to this object, must be non-null.
        data - The raw data as represented by Discord, must be non-null.
        guildId - The ID of the guild this role is associated to.
    • Method Detail

      • getData

        public discord4j.discordjson.json.RoleData getData()
        Gets the data of the role.
        Returns:
        The data of the role.
      • getRawPosition

        public int getRawPosition()
        Gets the sorting position of the role.
        Returns:
        The sorting position of the role.
      • getPosition

        public Mono<Integer> getPosition()
        Requests to retrieve the position of the role relative to other roles in the guild.

        This is determined by the index of this role in the sorted list of roles of the guild.

        Warning: Because this method must sort the guild roles, it is inefficient to make repeated invocations for the same set of roles (meaning that roles haven't been added or removed). For example, instead of writing:

         
         guild.getRoles()
           .flatMap(r -> r.getPosition().map(pos -> r.getName() + " : " + pos))
         
         
        It would be much more efficient to write:
         
         guild.getRoles()
           .transform(OrderUtil::orderRoles)
           .index((pos, r) -> r.getName() + " : " + pos)
         
         
        Returns:
        A Mono where, upon successful completion, emits the position of the role. If an error is received, it is emitted through the Mono.
      • getPosition

        public Mono<Integer> getPosition​(EntityRetrievalStrategy retrievalStrategy)
        Requests to retrieve the position of the role relative to other roles in the guild, using the given retrieval strategy.

        This is determined by the index of this role in the sorted list of roles of the guild.

        Warning: Because this method must sort the guild roles, it is inefficient to make repeated invocations for the same set of roles (meaning that roles haven't been added or removed). For example, instead of writing:

         
         guild.getRoles()
           .flatMap(r -> r.getPosition().map(pos -> r.getName() + " : " + pos))
         
         
        It would be much more efficient to write:
         
         guild.getRoles()
           .transform(OrderUtil::orderRoles)
           .index((pos, r) -> r.getName() + " : " + pos)
         
         
        Parameters:
        retrievalStrategy - the strategy to use to get the guild and the other roles
        Returns:
        A Mono where, upon successful completion, emits the position of the role. If an error is received, it is emitted through the Mono.
      • getName

        public String getName()
        Gets the role name.
        Returns:
        The role name.
      • getColor

        public Color getColor()
        Gets the color assigned to this role.
        Returns:
        The color assigned to this role.
      • isHoisted

        public boolean isHoisted()
        Gets whether if this role is pinned in the user listing.
        Returns:
        true if this role is pinned in the user listing, false otherwise.
      • getPermissions

        public PermissionSet getPermissions()
        Gets the permissions assigned to this role.
        Returns:
        The permissions assigned to this role.
      • isManaged

        public boolean isManaged()
        Gets whether this role is managed by an integration.
        Returns:
        true if this role is managed by an integration, false otherwise.
      • isMentionable

        public boolean isMentionable()
        Gets whether this role is mentionable.
        Returns:
        true if this role is mentionable, false otherwise.
      • isEveryone

        public boolean isEveryone()
        Gets whether this role corresponds to the @everyone role.
        Returns:
        true if this role represents the @everyone role, false otherwise.
      • getGuildId

        public Snowflake getGuildId()
        Gets the ID of the guild this role is associated to.
        Returns:
        The ID of the guild this role is associated to.
      • getGuild

        public Mono<Guild> getGuild()
        Requests to retrieve the guild this role is associated to.
        Returns:
        A Mono where, upon successful completion, emits the guild this role is associated to. If an error is received, it is emitted through the Mono.
      • getGuild

        public Mono<Guild> getGuild​(EntityRetrievalStrategy retrievalStrategy)
        Requests to retrieve the guild this role is associated to, using the given retrieval strategy.
        Parameters:
        retrievalStrategy - the strategy to use to get the guild
        Returns:
        A Mono where, upon successful completion, emits the guild this role is associated to. If an error is received, it is emitted through the Mono.
      • getMention

        public String getMention()
        Gets the raw mention. This is the format utilized to directly mention another role (assuming the role exists in context of the mention).
        Returns:
        The raw mention.
      • getTags

        public Optional<RoleTags> getTags()
        Gets the tags this role has, if present.
        Returns:
        The tags this role has, if present.
      • getId

        public Snowflake getId()
        Description copied from interface: Entity
        Gets the Snowflake that uniquely identifies this entity.
        Specified by:
        getId in interface Entity
        Returns:
        The Snowflake that uniquely identifies this entity.
      • edit

        public discord4j.core.spec.RoleEditMono edit()
        Requests to edit this role. Properties specifying how to edit this role can be set via the withXxx methods of the returned RoleEditMono.
        Returns:
        A RoleEditMono where, upon successful completion, emits the edited Role. If an error is received, it is emitted through the RoleEditMono.
      • edit

        public Mono<Role> edit​(discord4j.core.spec.RoleEditSpec spec)
        Requests to edit this role.
        Parameters:
        spec - an immutable object that specifies how to edit this role
        Returns:
        A Mono where, upon successful completion, emits the edited Role. If an error is received, it is emitted through the Mono.
      • delete

        public Mono<Void> delete()
        Requests to delete this role.
        Returns:
        A Mono where, upon successful completion, emits nothing; indicating the role has been deleted. If an error is received, it is emitted through the Mono.
      • delete

        public Mono<Void> delete​(@Nullable
                                 String reason)
        Requests to delete this role while optionally specifying the reason.
        Parameters:
        reason - The reason, if present.
        Returns:
        A Mono where, upon successful completion, emits nothing; indicating the role has been deleted. If an error is received, it is emitted through the Mono.
      • changePosition

        public Flux<Role> changePosition​(int position)
        Requests to change this role's position.
        Parameters:
        position - The position to change for this role.
        Returns:
        A Flux that continually emits all the roles associated to this role's guild. If an error is received, it is emitted through the Flux.
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object