Interface Member
-
- All Superinterfaces:
Formattable
,IMentionable
,IPermissionHolder
,ISnowflake
public interface Member extends IMentionable, IPermissionHolder
Represents a Guild-specific User.Contains all guild-specific information about a User. (Roles, Nickname, VoiceStatus etc.)
- Since:
- 3.0
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default AuditableRestAction<Void>
ban(int delDays)
Bans this Member and deletes messages sent by the user based on the amount of delDays.default AuditableRestAction<Void>
ban(int delDays, String reason)
Bans this Member and deletes messages sent by the user based on the amount of delDays.boolean
canInteract(Emote emote)
Whether this Member can interact with the providedEmote
(use in a message)boolean
canInteract(Member member)
Whether this Member can interact with the provided Member (kick/ban/etc.)boolean
canInteract(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.List<Activity>
getActivities()
The activities of the user.Color
getColor()
TheColor
of this Member's name in a Guild.int
getColorRaw()
The raw RGB value for the color of this member.TextChannel
getDefaultChannel()
The defaultTextChannel
for aMember
.String
getEffectiveName()
Retrieves the Name displayed in the official Discord Client.Guild
getGuild()
The Guild in which this Member is represented.JDA
getJDA()
The JDA instance.String
getNickname()
Returns the current nickname of this Member for the parent Guild.OnlineStatus
getOnlineStatus()
Returns theOnlineStatus
of the User.OnlineStatus
getOnlineStatus(ClientType type)
The platform dependentOnlineStatus
of this member.List<Role>
getRoles()
The roles applied to this Member.OffsetDateTime
getTimeBoosted()
The time when this member boosted the guild.OffsetDateTime
getTimeJoined()
TheTime
this Member joined the Guild.User
getUser()
The user wrapped by this Entity.GuildVoiceState
getVoiceState()
TheVoiceState
of this Member.boolean
isOwner()
Checks whether this member is the owner of its relatedGuild
.default AuditableRestAction<Void>
kick()
Kicks this Member from theGuild
.default AuditableRestAction<Void>
kick(String reason)
Kicks this from theGuild
.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.-
Methods inherited from interface net.dv8tion.jda.api.entities.IMentionable
formatTo, getAsMention
-
Methods inherited from interface net.dv8tion.jda.api.entities.IPermissionHolder
getPermissions, getPermissions, getPermissionsExplicit, getPermissionsExplicit, hasPermission, hasPermission, hasPermission, hasPermission
-
Methods inherited from interface net.dv8tion.jda.api.entities.ISnowflake
getId, getIdLong, getTimeCreated
-
-
-
-
Method Detail
-
getGuild
@Nonnull Guild getGuild()
The Guild in which this Member is represented.- Specified by:
getGuild
in interfaceIPermissionHolder
- Returns:
Guild
-
getTimeJoined
@Nonnull OffsetDateTime getTimeJoined()
TheTime
this Member joined the Guild.- Returns:
- The Join Date.
-
getTimeBoosted
@Nullable OffsetDateTime 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
-
getVoiceState
@Nullable GuildVoiceState getVoiceState()
TheVoiceState
of this Member.
This will be null when theCacheFlag.VOICE_STATE
is disabled manuallyThis can be used to get the Member's VoiceChannel using
GuildVoiceState.getChannel()
.- Returns:
GuildVoiceState
-
getActivities
@Nonnull List<Activity> getActivities()
The activities of the user.
If the user does not currently have any activity, this returns an empty list.- Returns:
- Immutable list of
Activities
for the user
-
getOnlineStatus
@Nonnull OnlineStatus getOnlineStatus()
- Returns:
- The current
OnlineStatus
of theUser
.
-
getOnlineStatus
@Nonnull OnlineStatus getOnlineStatus(@Nonnull ClientType type)
The platform dependentOnlineStatus
of 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,
OFFLINE
is returned.- 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
-
getNickname
@Nullable String 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
@Nonnull String getEffectiveName()
Retrieves the Name displayed in the official Discord Client.- Returns:
- The Nickname of this Member or the Username if no Nickname is present.
-
getRoles
@Nonnull List<Role> 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 addRolesToMember, removeRolesFromMember, and modifyMemberRoles methods in
Guild
.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
Roles
for this Member.
-
getColor
@Nullable Color getColor()
TheColor
of 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()
-
getColorRaw
int getColorRaw()
The raw RGB value for the color of this member.
Defaulting toRole.DEFAULT_COLOR_RAW
if 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
-
canInteract
boolean canInteract(@Nonnull Member member)
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
boolean canInteract(@Nonnull Role role)
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
boolean canInteract(@Nonnull Emote emote)
Whether this Member can interact with the providedEmote
(use in a message)- Parameters:
emote
- The target Emote to check- Returns:
- True, if this Member is able to interact with the specified Emote
- Throws:
NullPointerException
- if the specified Emote is nullIllegalArgumentException
- if the specified Emote 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.
-
getDefaultChannel
@Nullable TextChannel getDefaultChannel()
The defaultTextChannel
for 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.MESSAGE_READ
permissions. If this requirement doesn't apply for any channel in the guild, this method returnsnull
.- Returns:
- The
TextChannel
representing the default channel for this member or null if no such channel exists.
-
ban
@Nonnull @CheckReturnValue default AuditableRestAction<Void> ban(int delDays)
Bans this Member and deletes messages sent by the user based on the amount of delDays.
If you wish to ban a member without deleting any messages, provide delDays with a value of 0.You can unban a user with
Guild.unban(User)
.Note:
Guild.getMembers()
will still contain theMember
until Discord sends theGuildMemberLeaveEvent
.Possible
ErrorResponses
caused by the returnedRestAction
include the following:MISSING_PERMISSIONS
The target Member cannot be banned due to a permission discrepancyUNKNOWN_MEMBER
The specified Member was removed from the Guild before finishing the task
- Parameters:
delDays
- The history of messages, in days, that will be deleted.- Returns:
AuditableRestAction
- Throws:
InsufficientPermissionException
- If the logged in account does not have thePermission.BAN_MEMBERS
permission.HierarchyException
- If the logged in account cannot ban the other user due to permission hierarchy position.
SeecanInteract(Member)
IllegalArgumentException
-- If the provided amount of days (delDays) is less than 0.
- If the provided amount of days (delDays) is bigger than 7.
- If the provided member is
null
- Since:
- 4.0.0
-
ban
@Nonnull @CheckReturnValue default AuditableRestAction<Void> ban(int delDays, @Nullable String reason)
Bans this Member and deletes messages sent by the user based on the amount of delDays.
If you wish to ban a member without deleting any messages, provide delDays with a value of 0.You can unban a user with
Guild.unban(User)
.Note:
Guild.getMembers()
will still contain theMember
until Discord sends theGuildMemberLeaveEvent
.Possible
ErrorResponses
caused by the returnedRestAction
include the following:MISSING_PERMISSIONS
The target Member cannot be banned due to a permission discrepancyUNKNOWN_MEMBER
The specified Member was removed from the Guild before finishing the task
- Parameters:
delDays
- The history of messages, in days, that will be deleted.reason
- The reason for this action ornull
if there is no specified reason- Returns:
AuditableRestAction
- Throws:
InsufficientPermissionException
- If the logged in account does not have thePermission.BAN_MEMBERS
permission.HierarchyException
- If the logged in account cannot ban the other user due to permission hierarchy position.
SeecanInteract(Member)
IllegalArgumentException
-- If the provided amount of days (delDays) is less than 0.
- If the provided amount of days (delDays) is bigger than 7.
- If the provided member is
null
- Since:
- 4.0.0
-
kick
@Nonnull @CheckReturnValue default AuditableRestAction<Void> kick()
Kicks this Member from theGuild
.Note:
Guild.getMembers()
will still contain theUser
until Discord sends theGuildMemberLeaveEvent
.Possible
ErrorResponses
caused by the returnedRestAction
include 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:
AuditableRestAction
Kicks the provided Member from the current Guild- Throws:
IllegalArgumentException
- If the provided member is not a Member of this Guild or isnull
InsufficientPermissionException
- If the logged in account does not have thePermission.KICK_MEMBERS
permission.HierarchyException
- If the logged in account cannot kick the other member due to permission hierarchy position.
SeecanInteract(Member)
- Since:
- 4.0.0
-
kick
@Nonnull @CheckReturnValue default AuditableRestAction<Void> kick(@Nullable String reason)
Kicks this from theGuild
.Note:
Guild.getMembers()
will still contain theUser
until Discord sends theGuildMemberLeaveEvent
.Possible
ErrorResponses
caused by the returnedRestAction
include 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
- Parameters:
reason
- The reason for this action ornull
if there is no specified reason- Returns:
AuditableRestAction
Kicks the provided Member from the current Guild- Throws:
IllegalArgumentException
- If the provided member is not a Member of this Guild or isnull
InsufficientPermissionException
- If the logged in account does not have thePermission.KICK_MEMBERS
permission.HierarchyException
- If the logged in account cannot kick the other member due to permission hierarchy position.
SeecanInteract(Member)
- Since:
- 4.0.0
-
mute
@Nonnull @CheckReturnValue default AuditableRestAction<Void> mute(boolean 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 theGuildVoiceGuildMuteEvent
event related to this change.Possible
ErrorResponses
caused by the returnedRestAction
include 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 thisMember
should be muted or unmuted.- Returns:
AuditableRestAction
- Throws:
InsufficientPermissionException
- If the logged in account does not have thePermission.VOICE_DEAF_OTHERS
permission.IllegalArgumentException
- If the provided member is not from this Guild or null.IllegalStateException
- If the provided member is not currently connected to a voice channel.- Since:
- 4.0.0
-
deafen
@Nonnull @CheckReturnValue default AuditableRestAction<Void> deafen(boolean 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 theGuildVoiceGuildDeafenEvent
event related to this change.Possible
ErrorResponses
caused by the returnedRestAction
include 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 thisMember
should be deafened or undeafened.- Returns:
AuditableRestAction
- Throws:
InsufficientPermissionException
- If the logged in account does not have thePermission.VOICE_DEAF_OTHERS
permission.IllegalArgumentException
- If the provided member is not from this Guild or null.IllegalStateException
- If the provided 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_CHANGE
is required.
To change the nickname of anyMember
for thisGuild
the PermissionNICKNAME_MANAGE
is required.Possible
ErrorResponses
caused by the returnedRestAction
include 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
, providenull
or an empty String to reset the nickname- Returns:
AuditableRestAction
- Throws:
IllegalArgumentException
- If the specifiedMember
is not from the sameGuild
. Or if the provided member isnull
InsufficientPermissionException
-- If attempting to set nickname for self and the logged in account has neither
Permission.NICKNAME_CHANGE
orPermission.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
-
-