Package discord4j.core.object.entity
Class Member
- java.lang.Object
-
- discord4j.core.object.entity.User
-
- discord4j.core.object.entity.Member
-
- All Implemented Interfaces:
DiscordObject
,Entity
public final class Member extends User
A Discord guild member.- See Also:
- Guild Member Object
-
-
Constructor Summary
Constructors Constructor Description Member(GatewayDiscordClient gateway, discord4j.discordjson.json.MemberData data, long guildId)
Constructs aMember
with an associatedGatewayDiscordClient
and Discord data.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Mono<Void>
addRole(Snowflake roleId)
Requests to add a role to this member.Mono<Void>
addRole(Snowflake roleId, String reason)
Requests to add a role to this member while optionally specifying the reason.Mono<Member>
asMember(Snowflake guildId)
Requests to retrieve this user as aMember
.Mono<Void>
ban(Consumer<? super BanQuerySpec> spec)
Requests to ban this user.Mono<Void>
edit(Consumer<? super GuildMemberEditSpec> spec)
Requests to edit this member.Mono<PermissionSet>
getBasePermissions()
Requests to calculate the permissions granted to this member by his roles in the guild.Mono<Color>
getColor()
Requests to determine theColor
this member would be visually represented in the Discord client.String
getDisplayName()
Gets the name that is displayed in client.Mono<Guild>
getGuild()
Requests to retrieve the guild this user is associated to.Mono<Guild>
getGuild(EntityRetrievalStrategy retrievalStrategy)
Requests to retrieve the guild this user is associated to, using the given retrieval strategy.Snowflake
getGuildId()
Gets the ID of the guild this user is associated to.Mono<Role>
getHighestRole()
Requests to retrieve the user's highest guild role.Mono<Role>
getHighestRole(EntityRetrievalStrategy retrievalStrategy)
Requests to retrieve the user's highest guild role, using the given retrieval strategy.Instant
getJoinTime()
Gets when the user joined the guild, if present.discord4j.discordjson.json.MemberData
getMemberData()
Gets the data of the member.Optional<String>
getNickname()
Gets the user's guild nickname (if one is set).String
getNicknameMention()
Gets the raw nickname mention.Optional<Instant>
getPremiumTime()
Gets when the user started boosting the server, if present.Mono<Presence>
getPresence()
Requests to retrieve the presence for this user for this guild.Set<Snowflake>
getRoleIds()
Gets the user's guild roles' IDs.Flux<Role>
getRoles()
Requests to retrieve the user's guild roles.Flux<Role>
getRoles(EntityRetrievalStrategy retrievalStrategy)
Requests to retrieve the user's guild roles, using the given retrieval strategy.Mono<VoiceState>
getVoiceState()
Requests to retrieve this user's voice state for this guild.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.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.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.boolean
isPending()
Gets whether the user has not yet passed the guild's Membership Screening requirements.Mono<Void>
kick()
Requests to kick this member.Mono<Void>
kick(String reason)
Requests to kick this member while optionally specifying the reason.Mono<Void>
removeRole(Snowflake roleId)
Requests to remove a role from this member.Mono<Void>
removeRole(Snowflake roleId, String reason)
Requests to remove a role from this member while optionally specifying the reason.String
toString()
Mono<Void>
unban()
Requests to unban this user.Mono<Void>
unban(String reason)
Requests to unban this user while optionally specifying the reason.-
Methods inherited from class discord4j.core.object.entity.User
asMember, equals, getAvatar, getAvatar, getAvatarUrl, getAvatarUrl, getClient, getDefaultAvatarUrl, getDiscriminator, getId, getMention, getPrivateChannel, getPublicFlags, getTag, getUserData, getUsername, hasAnimatedAvatar, hashCode, isBot
-
-
-
-
Constructor Detail
-
Member
public Member(GatewayDiscordClient gateway, discord4j.discordjson.json.MemberData data, long guildId)
Constructs aMember
with an associatedGatewayDiscordClient
and Discord data.- Parameters:
gateway
- TheGatewayDiscordClient
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 aMember
.
-
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. UseOrderUtil.orderRoles(Flux)
to consistently order roles.
-
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. UseOrderUtil.orderRoles(Flux)
to consistently order roles.
-
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.
-
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.
-
getJoinTime
@Nullable public Instant getJoinTime()
Gets when the user joined the guild, if present. Can benull
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(EntityRetrievalStrategy retrievalStrategy)
Requests to retrieve the guild this user is associated to, using the given retrieval strategy.
-
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 avoice state
for this user for this guild. If an error is received, it is emitted through theMono
.
-
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 emittedMono
will always be empty.
-
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 theMono
.
-
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 theMono
.
-
ban
public Mono<Void> ban(Consumer<? super BanQuerySpec> spec)
Requests to ban this user.- Parameters:
spec
- AConsumer
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 theMono
.
-
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 theMono
.
-
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 theMono
.
-
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 theMono
.
-
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 theMono
.
-
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 theMono
.
-
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 theMono
.
-
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, emitstrue
if this member is higher in the role hierarchy than the provided member,false
otherwise. If an error is received, it is emitted through theMono
.
-
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, emitstrue
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 theMono
.
-
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, emitstrue
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 theMono
.
-
getColor
public Mono<Color> getColor()
Requests to determine theColor
this member would be visually represented in the Discord client.- Returns:
- A
Mono
where, upon successful completion, emits theColor
this member would be visually represented in the Discord client. If an error is received, it is emitted through theMono
.
-
edit
public Mono<Void> edit(Consumer<? super GuildMemberEditSpec> spec)
Requests to edit this member.- Parameters:
spec
- AConsumer
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 theMono
.
-
-