Interface Member
- All Superinterfaces:
Formattable,IMentionable,IPermissionHolder,ISnowflake,UserSnowflake
Contains all guild-specific information about a User. (Roles, Nickname, VoiceStatus etc.)
- Since:
- 3.0
- See Also:
-
Guild.getMember(UserSnowflake)Guild.getMemberCache()Guild.getMemberById(long)Guild.getMemberByTag(String)Guild.getMemberByTag(String, String)Guild.getMembersByEffectiveName(String, boolean)Guild.getMembersByName(String, boolean)Guild.getMembersByNickname(String, boolean)Guild.getMembersWithRoles(Role...)Guild.getMembers()
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic enumMember flags indicating information about the membership state. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringTemplate forgetAvatarUrl().static final intMaximum number of days a Member can be timed out for -
Method Summary
Modifier and TypeMethodDescriptiondefault AuditableRestAction<Void>Bans this Member and deletes messages sent by the user based on the amount of delDays.booleancanInteract(RichCustomEmoji emoji) Whether this Member can interact with the providedRichCustomEmoji(use in a message)booleancanInteract(Member member) Whether this Member can interact with the provided Member (kick/ban/etc.)booleancanInteract(Role role) Whether this Member can interact with the providedRole(kick/ban/move/modify/delete/etc.)default AuditableRestAction<Void>deafen(boolean deafen) Sets the Guild Deafened state state of this Member based on the provided boolean.A Set of all activeClientTypesof this Member.The activities of the user.default ImageProxyReturns anImageProxyfor this member's avatar.The Discord Id for this member's per guild avatar image.default StringThe URL for the member's per guild avatar image.getColor()TheColorof this Member's name in a Guild.intThe raw RGB value for the color of this member.Thedefault channelfor aMember.default ImageProxyReturns anImageProxyfor this member's effective avatar image.default StringThe URL for the member's effective avatar image.Retrieves the Name displayed in the official Discord Client.default EnumSet<Member.MemberFlag>getFlags()intThe rawflagsbitset for this member.getGuild()The Guild in which this Member is represented.getJDA()The JDA instance.Returns the current nickname of this Member for the parent Guild.Returns theOnlineStatusof the User.getOnlineStatus(ClientType type) The platform dependentOnlineStatusof this member.getRoles()The roles applied to this Member.The time when this member boosted the guild.TheTimethis Member joined the Guild.The time this Member will be released from time out.getUser()The user wrapped by this Entity.TheVoiceStateof this Member.booleanWhether this member has accurategetTimeJoined()information.booleanReturns whether a member is boosting the guild or not.booleanisOwner()Checks whether this member is the owner of its relatedGuild.booleanChecks whether this member has passed theGuild'sMembership Screening requirements.default booleanWhether this Member is in time out.default AuditableRestAction<Void>kick()Kicks this Member from theGuild.default AuditableRestAction<Void>modifyFlags(Collection<Member.MemberFlag> newFlags) Updates the flags to the new flag set.default AuditableRestAction<Void>modifyNickname(String nickname) Changes this Member's nickname in this guild.default AuditableRestAction<Void>mute(boolean mute) Sets the Guild Muted state state of this Member based on the provided boolean.default AuditableRestAction<Void>Removes a time out from this Member in thisGuild.default AuditableRestAction<Void>timeoutFor(long amount, TimeUnit unit) Puts this Member in time out in thisGuildfor a specific amount of time.default AuditableRestAction<Void>timeoutFor(Duration duration) Puts this Member in time out in thisGuildfor a specific amount of time.default AuditableRestAction<Void>timeoutUntil(TemporalAccessor temporal) Puts this Member in time out in thisGuilduntil the specified date.Methods inherited from interface net.dv8tion.jda.api.entities.IMentionable
formatTo, getAsMentionMethods inherited from interface net.dv8tion.jda.api.entities.IPermissionHolder
canSync, canSync, getPermissions, getPermissions, getPermissionsExplicit, getPermissionsExplicit, hasAccess, hasPermission, hasPermission, hasPermission, hasPermissionMethods inherited from interface net.dv8tion.jda.api.entities.ISnowflake
getId, getIdLong, getTimeCreatedMethods inherited from interface net.dv8tion.jda.api.entities.UserSnowflake
getDefaultAvatar, getDefaultAvatarId, getDefaultAvatarUrl
-
Field Details
-
AVATAR_URL
Template forgetAvatarUrl().- See Also:
-
MAX_TIME_OUT_LENGTH
static final int MAX_TIME_OUT_LENGTHMaximum number of days a Member can be timed out for- See Also:
-
-
Method Details
-
getUser
The user wrapped by this Entity.- Returns:
User
-
getGuild
The Guild in which this Member is represented.- Specified by:
getGuildin interfaceIPermissionHolder- Returns:
Guild
-
getJDA
The JDA instance.- Returns:
- The current JDA instance.
-
getTimeJoined
TheTimethis Member joined the Guild.
If the member was loaded through a presence update (lazy loading) this will be identical to the creation time of the guild. You can usehasTimeJoined()to test whether this time can be relied on.You can use
guild.retrieveMemberById(member.getId())to load the join time.- Returns:
- The time at which this user has joined the guild.
-
hasTimeJoined
boolean hasTimeJoined()Whether this member has accurategetTimeJoined()information.
Discord doesn't always provide this information when we load members so we have to fallback to theGuildcreation time.You can use
guild.retrieveMemberById(member.getId())to load the join time.- Returns:
- True, if
getTimeJoined()is accurate
-
getTimeBoosted
The time when this member boosted the guild.
Null indicates this member is not currently boosting the guild.- Returns:
- The boosting time, or null if the member is not boosting
- Since:
- 4.0.0
-
isBoosting
boolean isBoosting()Returns whether a member is boosting the guild or not.- Returns:
- True, if it is boosting
-
getTimeOutEnd
The time this Member will be released from time out.
If this Member is not in time out, this returnsnull. This may also return dates in the past, in which case the time out has expired.- Returns:
- The time this Member will be released from time out or
nullif not in time out
-
isTimedOut
default boolean isTimedOut()Whether this Member is in time out.
While a Member is in time out, all permissions exceptVIEW_CHANNELandMESSAGE_HISTORYare removed from them.- Returns:
- True, if this Member is in time out
-
getVoiceState
TheVoiceStateof this Member.
This will be null when theCacheFlag.VOICE_STATEis disabled manuallyThis can be used to get the Member's VoiceChannel using
GuildVoiceState.getChannel().This requires
CacheFlag.VOICE_STATEto be enabled!- Returns:
GuildVoiceState
-
getActivities
The activities of the user.
If the user does not currently have any activity, this returns an empty list.This requires
CacheFlag.ACTIVITYto be enabled!- Returns:
- Immutable list of
Activitiesfor the user
-
getOnlineStatus
Returns theOnlineStatusof the User.
If theOnlineStatusis unrecognized, will returnUNKNOWN.This will always return
OnlineStatus.OFFLINEifCacheFlag.ONLINE_STATUSis disabled.- Returns:
- The current
OnlineStatusof theUser.
-
getOnlineStatus
The platform dependentOnlineStatusof this member.
Since a user can be connected from multiple different devices such as web and mobile, discord specifies a status for eachClientType.If a user is not online on the specified type,
OFFLINEis returned.This requires
CacheFlag.CLIENT_STATUSto be enabled!- Parameters:
type- The type of client- Returns:
- The status for that specific client or OFFLINE
- Throws:
IllegalArgumentException- If the provided type is null- Since:
- 4.0.0
-
getActiveClients
A Set of all activeClientTypesof this Member. EveryOnlineStatusother thanOFFLINEandUNKNOWNis interpreted as active. SinceINVISIBLEis only possible for the SelfUser, other Members will never have ClientTypes show as active when actually beingINVISIBLE, since they will show asOFFLINE.
If the Member is currently not active with any Client, this returns an empty Set.
WhenCacheFlag.CLIENT_STATUSis disabled, active clients will not be tracked and this will always return an empty Set.
Since a user can be connected from multiple different devices such as web and mobile, discord specifies a status for eachClientType.- Returns:
- EnumSet of all active
ClientTypes - Since:
- 4.0.0
-
getNickname
Returns the current nickname of this Member for the parent Guild.This can be changed using
modifyNickname(Member, String).- Returns:
- The nickname or null, if no nickname is set.
-
getEffectiveName
Retrieves the Name displayed in the official Discord Client.- Returns:
- The guild nickname of this Member or the
effective user nameif no guild nickname is present.
-
getAvatarId
The Discord Id for this member's per guild avatar image. If the member has not set a per guild avatar, this will return null.- Returns:
- Possibly-null String containing the
Memberper guild avatar id.
-
getAvatarUrl
The URL for the member's per guild avatar image. If the member has not set a per guild avatar, this will return null.- Returns:
- Possibly-null String containing the
Memberper guild avatar url.
-
getAvatar
Returns anImageProxyfor this member's avatar.- Returns:
- Possibly-null
ImageProxyof this member's avatar - See Also:
-
getEffectiveAvatarUrl
The URL for the member's effective avatar image. If they do not have a per guild avatar set, this will return the URL of their effectiveUseravatar.- Returns:
- Never-null String containing the
Memberavatar url.
-
getEffectiveAvatar
Returns anImageProxyfor this member's effective avatar image.- Returns:
- Never-null
ImageProxyof this member's effective avatar image - See Also:
-
getRoles
The roles applied to this Member.
The roles are ordered based on their position. The highest role being at index 0 and the lowest at the last index.A Member's roles can be changed using the
Guild.addRoleToMember(UserSnowflake, Role),Guild.removeRoleFromMember(UserSnowflake, Role), andGuild.modifyMemberRoles(Member, Collection, Collection)methods inGuild.The Public Role (
@everyone) is not included in the returned immutable list of roles
It is implicit that every member holds the Public Role in a Guild thus it is not listed here!- Returns:
- An immutable List of
Rolesfor this Member. - See Also:
-
getColor
TheColorof this Member's name in a Guild.This is determined by the color of the highest role assigned to them that does not have the default color.
If all roles have default color, this returns null.- Returns:
- The display Color for this Member.
- See Also:
-
getColorRaw
int getColorRaw()The raw RGB value for the color of this member.
Defaulting toRole.DEFAULT_COLOR_RAWif this member uses the default color (special property, it changes depending on theme used in the client)- Returns:
- The raw RGB value or the role default
-
getFlagsRaw
int getFlagsRaw()The rawflagsbitset for this member.- Returns:
- The raw flag bitset
-
getFlags
Theflagsfor this member as anEnumSet.
Modifying this set will not update the member, it is a copy of existing flags.- Returns:
- The flags
-
canInteract
Whether this Member can interact with the provided Member (kick/ban/etc.)- Parameters:
member- The target Member to check- Returns:
- True, if this Member is able to interact with the specified Member
- Throws:
NullPointerException- if the specified Member is nullIllegalArgumentException- if the specified Member is not from the same guild
-
canInteract
Whether this Member can interact with the providedRole(kick/ban/move/modify/delete/etc.)If this returns true this member can assign the role to other members.
- Parameters:
role- The target Role to check- Returns:
- True, if this member is able to interact with the specified Role
- Throws:
NullPointerException- if the specified Role is nullIllegalArgumentException- if the specified Role is not from the same guild
-
canInteract
Whether this Member can interact with the providedRichCustomEmoji(use in a message)- Parameters:
emoji- The target emoji to check- Returns:
- True, if this Member is able to interact with the specified emoji
- Throws:
NullPointerException- if the specified emoji is nullIllegalArgumentException- if the specified emoji is not from the same guild
-
isOwner
boolean isOwner()Checks whether this member is the owner of its relatedGuild.- Returns:
- True, if this member is the owner of the attached Guild.
-
isPending
Checks whether this member has passed theGuild'sMembership Screening requirements.- Returns:
- True, if this member hasn't passed the guild's Membership Screening requirements
- Since:
- 4.2.1
- Incubating:
- Discord is still trying to figure this out
-
getDefaultChannel
Thedefault channelfor aMember.
This is the channel that the Discord client will default to opening when a Guild is opened for the first time after joining the guild.
The default channel is the channel with the highest position in which the member hasPermission.VIEW_CHANNELpermissions. If this requirement doesn't apply for any channel in the guild, this method returnsnull.- Returns:
- The
channelrepresenting the default channel for this member or null if no such channel exists.
-
ban
@Nonnull @CheckReturnValue default AuditableRestAction<Void> ban(int deletionTimeframe, @Nonnull TimeUnit unit) Bans this Member and deletes messages sent by the user based on the amount of delDays.
If you wish to ban a user without deleting any messages, providedeletionTimeframewith a value of 0. To set a ban reason, useAuditableRestAction.reason(String).You can unban a user with
Guild.unban(UserSnowflake).Note:
Guild.getMembers()will still contain theMemberuntil Discord sends theGuildMemberRemoveEvent.Possible
ErrorResponsescaused by the returnedRestActioninclude the following:MISSING_PERMISSIONS
The target Member cannot be banned due to a permission discrepancyUNKNOWN_USER
The user no longer exists
- Parameters:
deletionTimeframe- The timeframe for the history of messages that will be deleted. (seconds precision)unit- Timeframe unit as aTimeUnit(for examplemember.ban(7, TimeUnit.DAYS)).- Returns:
AuditableRestAction- Throws:
InsufficientPermissionException- If the logged in account does not have thePermission.BAN_MEMBERSpermission.HierarchyException- If the logged in account cannot ban the other user due to permission hierarchy position.
SeecanInteract(Member)IllegalArgumentException-- If the provided deletionTimeframe is negative.
- If the provided deletionTimeframe is longer than 7 days.
- If the provided time unit is
null
- See Also:
-
kick
Kicks this Member from theGuild.Note:
Guild.getMembers()will still contain theUseruntil Discord sends theGuildMemberRemoveEvent.Possible
ErrorResponsescaused by the returnedRestActioninclude the following:MISSING_PERMISSIONS
The target Member cannot be kicked due to a permission discrepancyUNKNOWN_MEMBER
The specified Member was removed from the Guild before finishing the task
- Returns:
AuditableRestActionKicks the provided Member from the current Guild- Throws:
InsufficientPermissionException- If the logged in account does not have thePermission.KICK_MEMBERSpermission.HierarchyException- If the logged in account cannot kick the other member due to permission hierarchy position.
SeecanInteract(Member)- Since:
- 4.0.0
-
timeoutFor
@Nonnull @CheckReturnValue default AuditableRestAction<Void> timeoutFor(long amount, @Nonnull TimeUnit unit) Puts this Member in time out in thisGuildfor a specific amount of time.
While a Member is in time out, all permissions exceptVIEW_CHANNELandMESSAGE_HISTORYare removed from them.Possible
ErrorResponsescaused by the returnedRestActioninclude the following:MISSING_PERMISSIONS
The target Member cannot be put into time out due to a permission discrepancyUNKNOWN_MEMBER
The specified Member was removed from the Guild before finishing the task
- Parameters:
amount- The amount of the providedunitto put this Member in time out forunit- TheUnittype ofamount- Returns:
AuditableRestAction- Throws:
InsufficientPermissionException- If the logged in account does not have thePermission.MODERATE_MEMBERSpermission.IllegalArgumentException- If any of the following checks are true- The provided
amountis lower than or equal to0 - The provided
unitis null - The provided
amountwith theunitresults in a date that is more than 28 days in the future
- The provided
-
timeoutFor
Puts this Member in time out in thisGuildfor a specific amount of time.
While a Member is in time out, all permissions exceptVIEW_CHANNELandMESSAGE_HISTORYare removed from them.Possible
ErrorResponsescaused by the returnedRestActioninclude the following:MISSING_PERMISSIONS
The target Member cannot be put into time out due to a permission discrepancyUNKNOWN_MEMBER
The specified Member was removed from the Guild before finishing the task
- Parameters:
duration- The duration to put this Member in time out for- Returns:
AuditableRestAction- Throws:
InsufficientPermissionException- If the logged in account does not have thePermission.MODERATE_MEMBERSpermission.IllegalArgumentException- If any of the following checks are true- The provided
durationis null - The provided
durationis not positive - The provided
durationresults in a date that is more than 28 days in the future
- The provided
-
timeoutUntil
@Nonnull @CheckReturnValue default AuditableRestAction<Void> timeoutUntil(@Nonnull TemporalAccessor temporal) Puts this Member in time out in thisGuilduntil the specified date.
While a Member is in time out, all permissions exceptVIEW_CHANNELandMESSAGE_HISTORYare removed from them.Possible
ErrorResponsescaused by the returnedRestActioninclude the following:MISSING_PERMISSIONS
The target Member cannot be put into time out due to a permission discrepancyUNKNOWN_MEMBER
The specified Member was removed from the Guild before finishing the task
- Parameters:
temporal- The time this Member will be released from time out- Returns:
AuditableRestAction- Throws:
InsufficientPermissionException- If the logged in account does not have thePermission.MODERATE_MEMBERSpermission.IllegalArgumentException- If any of the following checks are true- The provided
temporalis null - The provided
temporalis in the past - The provided
temporalis more than 28 days in the future
- The provided
-
removeTimeout
Removes a time out from this Member in thisGuild.Possible
ErrorResponsescaused by the returnedRestActioninclude the following:MISSING_PERMISSIONS
The time out cannot be removed due to a permission discrepancyUNKNOWN_MEMBER
The specified Member was removed from the Guild before finishing the task
- Returns:
AuditableRestAction- Throws:
InsufficientPermissionException- If the logged in account does not have thePermission.MODERATE_MEMBERSpermission.
-
mute
Sets the Guild Muted state state of this Member based on the provided boolean.Note: The Member's
GuildVoiceState.isGuildMuted()value won't change until JDA receives theGuildVoiceGuildMuteEventevent related to this change.Possible
ErrorResponsescaused by the returnedRestActioninclude the following:MISSING_PERMISSIONS
The target Member cannot be muted due to a permission discrepancyUNKNOWN_MEMBER
The specified Member was removed from the Guild before finishing the taskUSER_NOT_CONNECTED
The specified Member is not connected to a voice channel
- Parameters:
mute- Whether thisMembershould be muted or unmuted.- Returns:
AuditableRestAction- Throws:
InsufficientPermissionException- If the logged in account does not have thePermission.VOICE_DEAF_OTHERSpermission.IllegalStateException- If the member is not currently connected to a voice channel.- Since:
- 4.0.0
-
deafen
Sets the Guild Deafened state state of this Member based on the provided boolean.Note: The Member's
GuildVoiceState.isGuildDeafened()value won't change until JDA receives theGuildVoiceGuildDeafenEventevent related to this change.Possible
ErrorResponsescaused by the returnedRestActioninclude the following:MISSING_PERMISSIONS
The target Member cannot be deafened due to a permission discrepancyUNKNOWN_MEMBER
The specified Member was removed from the Guild before finishing the taskUSER_NOT_CONNECTED
The specified Member is not connected to a voice channel
- Parameters:
deafen- Whether thisMembershould be deafened or undeafened.- Returns:
AuditableRestAction- Throws:
InsufficientPermissionException- If the logged in account does not have thePermission.VOICE_DEAF_OTHERSpermission.IllegalStateException- If the member is not currently connected to a voice channel.- Since:
- 4.0.0
-
modifyNickname
@Nonnull @CheckReturnValue default AuditableRestAction<Void> modifyNickname(@Nullable String nickname) Changes this Member's nickname in this guild. The nickname is visible to all members of this guild.To change the nickname for the currently logged in account only the Permission
NICKNAME_CHANGEis required.
To change the nickname of anyMemberfor thisGuildthe PermissionNICKNAME_MANAGEis required.Possible
ErrorResponsescaused by the returnedRestActioninclude the following:MISSING_PERMISSIONS
The nickname of the target Member is not modifiable due to a permission discrepancyUNKNOWN_MEMBER
The specified Member was removed from the Guild before finishing the task
- Parameters:
nickname- The new nickname of theMember, providenullor an empty String to reset the nickname- Returns:
AuditableRestAction- Throws:
InsufficientPermissionException-- If attempting to set nickname for self and the logged in account has neither
Permission.NICKNAME_CHANGEorPermission.NICKNAME_MANAGE - If attempting to set nickname for another member and the logged in account does not have
Permission.NICKNAME_MANAGE
- If attempting to set nickname for self and the logged in account has neither
HierarchyException- If attempting to set nickname for another member and the logged in account cannot manipulate the other user due to permission hierarchy position.
SeecanInteract(Member).- Since:
- 4.0.0
-
modifyFlags
@Nonnull @CheckReturnValue default AuditableRestAction<Void> modifyFlags(@Nonnull Collection<Member.MemberFlag> newFlags) Updates the flags to the new flag set.
If any of the flags is notmodifiable, it is not updated.Any flags not provided by the set will be disabled, all contained flags will be enabled.
- Parameters:
newFlags- The new flags for the member.- Returns:
AuditableRestAction- Throws:
InsufficientPermissionException- If the bot does not havePermission.MODERATE_MEMBERSin the guildIllegalArgumentException- Ifnullis provided
-