Class Member

    • Constructor Detail

      • Member

        public Member​(GatewayDiscordClient gateway,
                      discord4j.discordjson.json.MemberData data,
                      long guildId)
        Constructs a Member 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 user is associated to.
    • Method Detail

      • asMember

        public Mono<Member> asMember​(Snowflake guildId)
        Description copied from class: User
        Requests to retrieve this user as a Member.
        Overrides:
        asMember in class User
        Parameters:
        guildId - The ID of the guild to associate this user as a Member.
        Returns:
        A Mono where, upon successful completion, emits this user as a member. If an error is received, it is emitted through the Mono.
      • getMemberData

        public discord4j.discordjson.json.MemberData getMemberData()
        Gets the data of the member.
        Returns:
        The data of the member.
      • getRoleIds

        public Set<Snowflake> getRoleIds()
        Gets the user's guild roles' IDs.
        Returns:
        The user's guild roles' IDs.
      • getRoles

        public Flux<Role> getRoles()
        Requests to retrieve the user's guild roles.

        The order of items emitted by the returned Flux is unspecified. Use OrderUtil.orderRoles(Flux) to consistently order roles.

        Returns:
        A Flux that continually emits the user's guild roles. If an error is received, it is emitted through the Flux.
      • getRoles

        public Flux<Role> getRoles​(EntityRetrievalStrategy retrievalStrategy)
        Requests to retrieve the user's guild roles, using the given retrieval strategy.

        The order of items emitted by the returned Flux is unspecified. Use OrderUtil.orderRoles(Flux) to consistently order roles.

        Parameters:
        retrievalStrategy - the strategy to use to get the roles
        Returns:
        A Flux that continually emits the user's guild roles. If an error is received, it is emitted through the Flux.
      • getHighestRole

        public Mono<Role> getHighestRole()
        Requests to retrieve the user's highest guild role.

        The highest role is defined to be the role with the highest position, based on Discord's ordering. This is the role that appears at the top in Discord's UI.

        Returns:
        A Mono where, upon successful completion, emits the user's highest role. If an error is received, it is emitted through the Mono.
      • getHighestRole

        public Mono<Role> getHighestRole​(EntityRetrievalStrategy retrievalStrategy)
        Requests to retrieve the user's highest guild role, using the given retrieval strategy.

        The highest role is defined to be the role with the highest position, based on Discord's ordering. This is the role that appears at the top in Discord's UI.

        Parameters:
        retrievalStrategy - the strategy to use to get the highest role
        Returns:
        A Mono where, upon successful completion, emits the user's highest role. If an error is received, it is emitted through the Mono.
      • getJoinTime

        @Nullable
        public Instant getJoinTime()
        Gets when the user joined the guild, if present. Can be null if it's a lurking stage channel member.
        Returns:
        When the user joined the guild, if present.
      • getPremiumTime

        public Optional<Instant> getPremiumTime()
        Gets when the user started boosting the server, if present.
        Returns:
        When the user started boosting the server, if present.
      • getGuildId

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

        public Mono<Guild> getGuild()
        Requests to retrieve the guild this user is associated to.
        Returns:
        A Mono where, upon successful completion, emits the guild this user 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 user 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 user is associated to. If an error is received, it is emitted through the Mono.
      • getDisplayName

        public String getDisplayName()
        Gets the name that is displayed in client.
        Returns:
        The name that is displayed in client.
      • getNickname

        public Optional<String> getNickname()
        Gets the user's guild nickname (if one is set).
        Returns:
        The user's guild nickname (if one is set).
      • getNicknameMention

        public String getNicknameMention()
        Gets the raw nickname mention. This is the format utilized to directly mention another user (assuming the user exists in context of the mention).
        Returns:
        The raw nickname mention.
      • getVoiceState

        public Mono<VoiceState> getVoiceState()
        Requests to retrieve this user's voice state for this guild.
        Returns:
        A Mono where, upon successful completion, emits a voice state for this user for this guild. If an error is received, it is emitted through the Mono.
      • getPresence

        public Mono<Presence> getPresence()
        Requests to retrieve the presence for this user for this guild. Intent.GUILD_PRESENCES is required to get the presence of the bot, otherwise the emitted Mono will always be empty.
        Returns:
        A Mono where, upon successful completion, emits a presence for this user for this guild. If an error is received, it is emitted through the Mono.
      • isPending

        public boolean isPending()
        Gets whether the user has not yet passed the guild's Membership Screening requirements.
        Returns:
        Whether the user has not yet passed the guild's Membership Screening requirements.
      • kick

        public Mono<Void> kick()
        Requests to kick this member.
        Returns:
        A Mono where, upon successful completion, emits nothing; indicating the member was kicked. If an error is received, it is emitted through the Mono.
      • kick

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

        public Mono<Void> ban​(Consumer<? super BanQuerySpec> spec)
        Requests to ban this user.
        Parameters:
        spec - A Consumer that provides a "blank" BanQuerySpec to be operated on.
        Returns:
        A Mono where, upon successful completion, emits nothing; indicating this user was banned. If an error is received, it is emitted through the Mono.
      • unban

        public Mono<Void> unban()
        Requests to unban this user.
        Returns:
        A Mono where, upon successful completion, emits nothing; indicating this user was unbanned. If an error is received, it is emitted through the Mono.
      • unban

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

        public Mono<Void> addRole​(Snowflake roleId)
        Requests to add a role to this member.
        Parameters:
        roleId - The ID of the role to add to this member.
        Returns:
        A Mono where, upon successful completion, emits nothing; indicating the role was added to this member. If an error is received, it is emitted through the Mono.
      • addRole

        public Mono<Void> addRole​(Snowflake roleId,
                                  @Nullable
                                  String reason)
        Requests to add a role to this member while optionally specifying the reason.
        Parameters:
        roleId - The ID of the role to add to this member.
        reason - The reason, if present.
        Returns:
        A Mono where, upon successful completion, emits nothing; indicating the role was added to this member. If an error is received, it is emitted through the Mono.
      • removeRole

        public Mono<Void> removeRole​(Snowflake roleId)
        Requests to remove a role from this member.
        Parameters:
        roleId - The ID of the role to remove from this member.
        Returns:
        A Mono where, upon successful completion, emits nothing; indicating the role was removed from this member. If an error is received, it is emitted through the Mono.
      • removeRole

        public Mono<Void> removeRole​(Snowflake roleId,
                                     @Nullable
                                     String reason)
        Requests to remove a role from this member while optionally specifying the reason.
        Parameters:
        roleId - The ID of the role to remove from this member.
        reason - The reason, if present.
        Returns:
        A Mono where, upon successful completion, emits nothing; indicating the role was removed from this member. If an error is received, it is emitted through the Mono.
      • getBasePermissions

        public Mono<PermissionSet> getBasePermissions()
        Requests to calculate the permissions granted to this member by his roles in the guild.
        Returns:
        The permissions granted to this member by his roles in the guild.
      • isHigher

        public Mono<Boolean> isHigher​(Member otherMember)
        Requests to determine if this member is higher in the role hierarchy than the provided member or signal IllegalArgumentException if the provided member is in a different guild than this member. This is determined by the positions of each of the members' highest roles.
        Parameters:
        otherMember - The member to compare in the role hierarchy with this member.
        Returns:
        A Mono where, upon successful completion, emits true if this member is higher in the role hierarchy than the provided member, false otherwise. If an error is received, it is emitted through the Mono.
      • isHigher

        public Mono<Boolean> isHigher​(Snowflake id)
        Requests to determine if this member is higher in the role hierarchy than the member as represented by the supplied ID or signal IllegalArgumentException if the member as represented by the supplied ID is in a different guild than this member. This is determined by the positions of each of the members' highest roles.
        Parameters:
        id - The ID of the member to compare in the role hierarchy with this member.
        Returns:
        A Mono where, upon successful completion, emits true if this member is higher in the role hierarchy than the member as represented by the supplied ID, false otherwise. If an error is received, it is emitted through the Mono.
      • hasHigherRoles

        public Mono<Boolean> hasHigherRoles​(Set<Snowflake> otherRoles)
        Requests to determine if the position of this member's highest role is greater than the highest position of the provided roles.

        The behavior of this operation is undefined if a given role is from a different guild.

        Parameters:
        otherRoles - The set of roles to compare in the role hierarchy with this member's roles.
        Returns:
        A Mono where, upon successful completion, emits true if the position of this member's highest role is greater than the highest position of the provided roles, false otherwise. If an error is received it is emitted through the Mono.
      • getColor

        public Mono<Color> getColor()
        Requests to determine the Color this member would be visually represented in the Discord client.
        Returns:
        A Mono where, upon successful completion, emits the Color this member would be visually represented in the Discord client. If an error is received, it is emitted through the Mono.
      • edit

        public Mono<Void> edit​(Consumer<? super GuildMemberEditSpec> spec)
        Requests to edit this member.
        Parameters:
        spec - A Consumer that provides a "blank" GuildMemberEditSpec to be operated on.
        Returns:
        A Mono where, upon successful completion, emits nothing; indicating the member has been edited. If an error is received, it is emitted through the Mono.