Class PartialMember

  • All Implemented Interfaces:
    DiscordObject, Entity
    Direct Known Subclasses:
    Member

    public class PartialMember
    extends User
    A partial Discord guild member.
    • Constructor Detail

      • PartialMember

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

      • getMemberData

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

        public Mono<Member> asFullMember()
        Requests to retrieve the full Member instance corresponding to this partial member.
        Returns:
        A Mono where, upon successful completion, emits the member this user is associated to. If an error is received, it is emitted through the Mono.
      • 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

        public Optional<Instant> getJoinTime()
        Gets when the user joined the guild, if present. Can be absent 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.
      • hasAnimatedGuildAvatar

        public final boolean hasAnimatedGuildAvatar()
        Gets if the member's guild avatar is animated.
        Returns:
        true if the user's avatar is animated, false otherwise.
      • getGuildAvatarUrl

        public final Optional<String> getGuildAvatarUrl​(Image.Format format)
        Gets the member's guild avatar URL, if present.
        Parameters:
        format - the format for the URL.
        Returns:
        The member's guild avatar URL, if present.
      • getEffectiveAvatarUrl

        public final String getEffectiveAvatarUrl()
        Gets the member's effective avatar URL. If the member does not have a guild avatar, this defaults to the user's global avatar.
        Returns:
        The member's effective avatar URL.
      • getGuildAvatar

        public Mono<Image> getGuildAvatar​(Image.Format format)
        Gets the member's guild avatar. This is the avatar at the url given by getGuildAvatarUrl(Image.Format).

        If the member does not have a guild avatar, this method emits Mono.empty().
        Parameters:
        format - The format for the avatar.
        Returns:
        a Mono where, upon successful completion, emotes the guild avatar of the member. If an error is received, it is emitted through the Mono.
      • getEffectiveAvatar

        public final Mono<Image> getEffectiveAvatar()
        Gets the member's effective avatar. This is the avatar at the url given by getEffectiveAvatarUrl().
        Returns:
        A Mono where, upon successful completion, emits the avatar of the user. If an error is received, it is emitted through the Mono.
      • 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.
      • 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.
      • 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.
      • ban

        public discord4j.core.spec.MemberBanQueryMono ban()
        Requests to ban this user. Properties specifying how to ban this user can be set via the withXxx methods of the returned MemberBanQueryMono.
        Returns:
        A MemberBanQueryMono where, upon successful completion, emits nothing; indicating the specified user was banned. If an error is received, it is emitted through the MemberBanQueryMono.
      • ban

        public Mono<Void> ban​(discord4j.core.spec.BanQuerySpec spec)
        Requests to ban this user.
        Parameters:
        spec - an immutable object that specifies how to ban this user
        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.
      • edit

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

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