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 java.lang.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()
java.time.Instant
getJoinedAtTimestamp()
Gets the timestamp of when this member joined the server.java.util.Optional<java.lang.String>
getNickname()
Gets the nickname of this member.java.util.Optional<java.awt.Color>
getRoleColor()
Gets the displayed color of this member based on his roles.java.util.List<java.lang.Long>
getRoleIds()
Gets the member's role ids.java.util.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.java.util.Optional<Icon>
getServerAvatar()
Gets the member's server avatar.java.util.Optional<Icon>
getServerAvatar(int size)
Gets the member's server avatar in the given size.java.util.Optional<java.lang.String>
getServerAvatarHash()
Gets the member's server avatar hash.java.lang.String
getServerBoostingSince()
Gets the string value of the server boosting since field.java.util.Optional<java.time.Instant>
getServerBoostingSinceTimestamp()
Gets the timestamp of when this member started boosting the server.java.util.Optional<java.time.Instant>
getTimeout()
Gets the timestamp of the timeout when the timeout will expire and the user will be able to communicate in the server again.User
getUser()
Gets the user object linked to this member.boolean
hasRole(Role role)
Checks if this member has the given role.boolean
isDeafened()
Gets the deafened state of this member.boolean
isMuted()
Gets the muted state of this member.boolean
isPending()
Gets the pending state of this member.boolean
isSelfDeafened()
Gets the self-deafened state of this member.boolean
isSelfMuted()
Gets the self-muted state of this member.MemberImpl
setDeafened(boolean deafened)
Creates a new member object with the new deafened status.MemberImpl
setMuted(boolean muted)
Creates a new member object with the new muted status.MemberImpl
setNickname(java.lang.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(java.util.List<java.lang.Long> roleIds)
Creates a new member object with the new role ids.MemberImpl
setSelfDeafened(boolean selfDeafened)
Creates a new member object with the new self-deafened status.MemberImpl
setSelfMuted(boolean selfMuted)
Creates a new member object with the new self-muted status.MemberImpl
setServerBoostingSince(java.lang.String serverBoostingSince)
Creates a new member object with the new server boosting since timestamp.MemberImpl
setTimeout(java.time.Instant timeout)
Creates a new member object with the new timeout.MemberImpl
setUser(UserImpl user)
Creates a new member object with the new user.java.lang.String
toString()
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.javacord.api.entity.DiscordEntity
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, sendMessage, sendMessage, sendMessage, sendMessage, sendMessage, sendMessage, sendMessage, sendMessage, 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(java.util.List<java.lang.Long> roleIds)
Creates a new member object with the new role ids.- Parameters:
roleIds
- The new role ids.- Returns:
- The new member.
-
getRoleIds
public java.util.List<java.lang.Long> getRoleIds()
Gets the member's role ids.- Returns:
- The member's role ids.
-
setNickname
public MemberImpl setNickname(java.lang.String nickname)
Creates a new member object with the new nickname.- Parameters:
nickname
- The new nickname.- Returns:
- The new member.
-
setTimeout
public MemberImpl setTimeout(java.time.Instant timeout)
Creates a new member object with the new timeout.- Parameters:
timeout
- The instant until the user should be timeout.- Returns:
- The new member.
-
setServerBoostingSince
public MemberImpl setServerBoostingSince(java.lang.String serverBoostingSince)
Creates a new member object with the new server boosting since timestamp.- Parameters:
serverBoostingSince
- The new timestamp when the user started boosting the server.- Returns:
- The new member.
-
getServerBoostingSince
public java.lang.String getServerBoostingSince()
Gets the string value of the server boosting since field.- Returns:
- The server boosting since field.
-
setMuted
public MemberImpl setMuted(boolean muted)
Creates a new member object with the new muted status.- Parameters:
muted
- Whether the user is muted or not.- Returns:
- The new member.
-
setDeafened
public MemberImpl setDeafened(boolean deafened)
Creates a new member object with the new deafened status.- Parameters:
deafened
- Whether the user is deafened or not.- Returns:
- The new member.
-
setSelfMuted
public MemberImpl setSelfMuted(boolean selfMuted)
Creates a new member object with the new self-muted status.- Parameters:
selfMuted
- Whether the user is self-muted or not.- Returns:
- The new member.
-
setSelfDeafened
public MemberImpl setSelfDeafened(boolean selfDeafened)
Creates a new member object with the new self-deafened status.- Parameters:
selfDeafened
- Whether the user is self-deafened or not.- Returns:
- The new member.
-
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 java.util.Optional<java.lang.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 java.util.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 java.util.Optional<java.awt.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.
-
getServerAvatarHash
public java.util.Optional<java.lang.String> getServerAvatarHash()
Description copied from interface:Member
Gets the member's server avatar hash.- Specified by:
getServerAvatarHash
in interfaceMember
- Returns:
- The member's server avatar hash.
-
getServerAvatar
public java.util.Optional<Icon> getServerAvatar()
Description copied from interface:Member
Gets the member's server avatar.- Specified by:
getServerAvatar
in interfaceMember
- Returns:
- The member's server avatar.
-
getServerAvatar
public java.util.Optional<Icon> getServerAvatar(int size)
Description copied from interface:Member
Gets the member's server avatar in the given size.- Specified by:
getServerAvatar
in interfaceMember
- Parameters:
size
- The size of the image, must be any power of 2 between 16 and 4096.- Returns:
- The member's server avatar in the given size.
-
getJoinedAtTimestamp
public java.time.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 java.util.Optional<java.time.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 the server.
-
isMuted
public boolean isMuted()
Description copied from interface:Member
Gets the muted state of this member.
-
isDeafened
public boolean isDeafened()
Description copied from interface:Member
Gets the deafened state of this member.- Specified by:
isDeafened
in interfaceMember
- Returns:
- Whether or not this member is deafened.
-
isSelfMuted
public boolean isSelfMuted()
Description copied from interface:Member
Gets the self-muted state of this member.- Specified by:
isSelfMuted
in interfaceMember
- Returns:
- Whether 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 this member is self-deafened.
-
isPending
public boolean isPending()
Description copied from interface:Member
Gets the pending state of this member.
-
getTimeout
public java.util.Optional<java.time.Instant> getTimeout()
Description copied from interface:Member
Gets the timestamp of the timeout when the timeout will expire and the user will be able to communicate in the server again. The returned Instant may be in the past which indicates that the user is not timed out.- Specified by:
getTimeout
in interfaceMember
- Returns:
- The timestamp of when this member will no longer be timed out.
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-