Package org.javacord.core.entity.user
Class MemberImpl
- java.lang.Object
-
- org.javacord.core.entity.user.MemberImpl
-
- All Implemented Interfaces:
DiscordEntity
,Mentionable
,Messageable
,Permissionable
,Member
public final class MemberImpl extends Object implements Member
Maps a member object.- See Also:
- Discord Docs
-
-
Constructor Summary
Constructors Constructor Description MemberImpl(DiscordApiImpl api, ServerImpl server, com.fasterxml.jackson.databind.JsonNode data, UserImpl user)
Creates a new immutable member instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description DiscordApi
getApi()
long
getId()
Instant
getJoinedAtTimestamp()
Gets the timestamp of when this member joined the server.Optional<String>
getNickname()
Gets the nickname of this member.Optional<Color>
getRoleColor()
Gets the displayed color of this member based on his roles.List<Long>
getRoleIds()
Gets a list with the member's role ids.List<Role>
getRoles()
Gets a sorted list (by position) with all roles of this member.Server
getServer()
Gets the server, this user is a part of.String
getServerBoostingSince()
Gets the string value of the server boosting since field.Optional<Instant>
getServerBoostingSinceTimestamp()
Gets the timestamp of when this member started boosting the server.User
getUser()
Gets the user object linked to this member.boolean
hasRole(Role role)
Checks if this member has the given role.boolean
isSelfDeafened()
Gets the self-deafened state of this member.boolean
isSelfMuted()
Gets the self-muted state of this member.MemberImpl
setNickname(String nickname)
Creates a new member object with the new nickname.MemberImpl
setPartialUser(com.fasterxml.jackson.databind.JsonNode partialUserJson)
Creates a new member object with the new partial user data.MemberImpl
setRoleIds(List<Long> roleIds)
Creates a new member object with the new role ids.MemberImpl
setServerBoostingSince(String serverBoostingSince)
Creates a new member object with the new nickname.MemberImpl
setUser(UserImpl user)
Creates a new member object with the new user.String
toString()
-
Methods inherited from interface org.javacord.api.entity.DiscordEntity
getCreationTimestamp, getCreationTimestamp, getIdAsString
-
Methods inherited from interface org.javacord.core.entity.user.Member
getDisplayName, getMentionTag
-
Methods inherited from interface org.javacord.api.entity.message.Messageable
sendMessage, sendMessage, sendMessage, sendMessage, sendMessage, sendMessage, sendMessage, sendMessage, sendMessage, sendMessage, sendMessage, sendMessage, sendMessage, sendMessage
-
-
-
-
Constructor Detail
-
MemberImpl
public MemberImpl(DiscordApiImpl api, ServerImpl server, com.fasterxml.jackson.databind.JsonNode data, UserImpl user)
Creates a new immutable member instance.- Parameters:
api
- The api instance.server
- The server of the member.data
- The json data of the member.user
- A user object in case the json does not contain user data (e.g., for message create events). If the json contains a non-null user field, this parameter is ignored.
-
-
Method Detail
-
setUser
public MemberImpl setUser(UserImpl user)
Creates a new member object with the new user.- Parameters:
user
- The new user.- Returns:
- The new member.
-
setPartialUser
public MemberImpl setPartialUser(com.fasterxml.jackson.databind.JsonNode partialUserJson)
Creates a new member object with the new partial user data.- Parameters:
partialUserJson
- The new partial user data.- Returns:
- The new member.
-
setRoleIds
public MemberImpl setRoleIds(List<Long> roleIds)
Creates a new member object with the new role ids.- Parameters:
roleIds
- The new role ids.- Returns:
- The new member.
-
getRoleIds
public List<Long> getRoleIds()
Gets a list with the member's role ids.- Returns:
- A list with the member's role ids.
-
setNickname
public MemberImpl setNickname(String nickname)
Creates a new member object with the new nickname.- Parameters:
nickname
- The new nickname.- Returns:
- The new member.
-
setServerBoostingSince
public MemberImpl setServerBoostingSince(String serverBoostingSince)
Creates a new member object with the new nickname.- Parameters:
serverBoostingSince
- The new timestamp when the user started boosting the server.- Returns:
- The new member.
-
getServerBoostingSince
public String getServerBoostingSince()
Gets the string value of the server boosting since field.- Returns:
- The server boosting since field.
-
getApi
public DiscordApi getApi()
- Specified by:
getApi
in interfaceDiscordEntity
-
getId
public long getId()
- Specified by:
getId
in interfaceDiscordEntity
-
getServer
public Server getServer()
Description copied from interface:Member
Gets the server, this user is a part of.
-
getUser
public User getUser()
Description copied from interface:Member
Gets the user object linked to this member.
-
getNickname
public Optional<String> getNickname()
Description copied from interface:Member
Gets the nickname of this member.- Specified by:
getNickname
in interfaceMember
- Returns:
- The nickname of this member.
-
getRoles
public List<Role> getRoles()
Description copied from interface:Member
Gets a sorted list (by position) with all roles of this member.
-
hasRole
public boolean hasRole(Role role)
Description copied from interface:Member
Checks if this member has the given role.
-
getRoleColor
public Optional<Color> getRoleColor()
Description copied from interface:Member
Gets the displayed color of this member based on his roles.- Specified by:
getRoleColor
in interfaceMember
- Returns:
- The color.
-
getJoinedAtTimestamp
public Instant getJoinedAtTimestamp()
Description copied from interface:Member
Gets the timestamp of when this member joined the server.- Specified by:
getJoinedAtTimestamp
in interfaceMember
- Returns:
- The timestamp of when this member joined the server.
-
getServerBoostingSinceTimestamp
public Optional<Instant> getServerBoostingSinceTimestamp()
Description copied from interface:Member
Gets the timestamp of when this member started boosting the server.- Specified by:
getServerBoostingSinceTimestamp
in interfaceMember
- Returns:
- The timestamp of when this member started boosting joined the server.
-
isSelfMuted
public boolean isSelfMuted()
Description copied from interface:Member
Gets the self-muted state of this member.- Specified by:
isSelfMuted
in interfaceMember
- Returns:
- Whether or not this member is self-muted.
-
isSelfDeafened
public boolean isSelfDeafened()
Description copied from interface:Member
Gets the self-deafened state of this member.- Specified by:
isSelfDeafened
in interfaceMember
- Returns:
- Whether or not this member is self-deafened.
-
-