Package org.javacord.core.entity.user
Class UserImpl
- java.lang.Object
-
- org.javacord.core.entity.user.UserImpl
-
- All Implemented Interfaces:
Formattable
,DiscordEntity
,Mentionable
,Messageable
,Nameable
,Permissionable
,Updatable<User>
,UpdatableFromCache<User>
,User
,UserAttachableListenerManager
,InternalUserAttachableListenerManager
,Cleanupable
public class UserImpl extends Object implements User, Cleanupable, InternalUserAttachableListenerManager
The implementation ofUser
.
-
-
Constructor Summary
Constructors Constructor Description UserImpl(DiscordApiImpl api, com.fasterxml.jackson.databind.JsonNode data)
Creates a new user.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
cleanup()
Does any cleanup that would prevent this instance from being eligible for garbage collection like cancelling scheduled repeated tasks or callingcleanup
on "owned" cleanupable objects.boolean
equals(Object o)
Optional<Activity>
getActivity()
DiscordApi
getApi()
Gets the discord api instance.Icon
getAvatar()
static Icon
getAvatar(DiscordApi api, String avatarHash, String discriminator, long userId)
Gets the avatar for the given details.String
getAvatarHash()
Gets the avatar hash of the user.String
getDiscriminator()
long
getId()
Gets the id of this object.String
getName()
PrivateChannel
getOrCreateChannel(com.fasterxml.jackson.databind.JsonNode data)
Gets or creates a new private channel.Optional<PrivateChannel>
getPrivateChannel()
UserStatus
getStatus()
UserStatus
getStatusOnClient(DiscordClient client)
boolean
hasDefaultAvatar()
int
hashCode()
boolean
isBot()
CompletableFuture<PrivateChannel>
openPrivateChannel()
void
setActivity(Activity activity)
Sets the activity of the user.void
setAvatarHash(String avatarHash)
Sets the avatar hash of the user.void
setChannel(PrivateChannel channel)
Sets the private channel with the user.void
setClientStatus(DiscordClient client, UserStatus status)
Sets the client status of the user.void
setDiscriminator(String discriminator)
Sets the discriminator of the user.void
setName(String name)
Sets the name of the user.void
setStatus(UserStatus status)
Sets the status of the user.String
toString()
-
Methods inherited from interface org.javacord.api.entity.DiscordEntity
getCreationTimestamp, getCreationTimestamp, getIdAsString
-
Methods inherited from interface org.javacord.core.listener.user.InternalUserAttachableListenerManager
addGroupChannelChangeNameListener, addGroupChannelCreateListener, addGroupChannelDeleteListener, addMessageCreateListener, addPrivateChannelCreateListener, addPrivateChannelDeleteListener, addReactionAddListener, addReactionRemoveListener, addServerChannelChangeOverwrittenPermissionsListener, addServerMemberBanListener, addServerMemberJoinListener, addServerMemberLeaveListener, addServerMemberUnbanListener, addServerVoiceChannelMemberJoinListener, addServerVoiceChannelMemberLeaveListener, addUserAttachableListener, addUserChangeActivityListener, addUserChangeAvatarListener, addUserChangeDeafenedListener, addUserChangeDiscriminatorListener, addUserChangeMutedListener, addUserChangeNameListener, addUserChangeNicknameListener, addUserChangeSelfDeafenedListener, addUserChangeSelfMutedListener, addUserChangeStatusListener, addUserRoleAddListener, addUserRoleRemoveListener, addUserStartTypingListener, getGroupChannelChangeNameListeners, getGroupChannelCreateListeners, getGroupChannelDeleteListeners, getMessageCreateListeners, getPrivateChannelCreateListeners, getPrivateChannelDeleteListeners, getReactionAddListeners, getReactionRemoveListeners, getServerChannelChangeOverwrittenPermissionsListeners, getServerMemberBanListeners, getServerMemberJoinListeners, getServerMemberLeaveListeners, getServerMemberUnbanListeners, getServerVoiceChannelMemberJoinListeners, getServerVoiceChannelMemberLeaveListeners, getUserAttachableListeners, getUserChangeActivityListeners, getUserChangeAvatarListeners, getUserChangeDeafenedListeners, getUserChangeDiscriminatorListeners, getUserChangeMutedListeners, getUserChangeNameListeners, getUserChangeNicknameListeners, getUserChangeSelfDeafenedListeners, getUserChangeSelfMutedListeners, getUserChangeStatusListeners, getUserRoleAddListeners, getUserRoleRemoveListeners, getUserStartTypingListeners, removeListener, removeUserAttachableListener
-
Methods inherited from interface org.javacord.api.entity.message.Messageable
sendMessage, sendMessage, sendMessage, sendMessage, sendMessage, sendMessage, sendMessage, sendMessage, sendMessage, sendMessage, sendMessage, sendMessage, sendMessage, sendMessage
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.javacord.api.entity.user.User
addRole, addRole, canManageRole, deafen, deafen, getConnectedVoiceChannel, getConnectedVoiceChannels, getCurrentCachedInstance, getCurrentClients, getDesktopStatus, getDiscriminatedName, getDisplayName, getGroupChannels, getJoinedAtTimestamp, getLatestInstance, getMentionTag, getMobileStatus, getMutualServers, getNickname, getNicknameMentionTag, getRoleColor, getRoles, getWebStatus, isBotOwner, isConnected, isDeafened, isMuted, isSelfDeafened, isSelfMuted, isYourself, move, mute, mute, removeRole, removeRole, resetNickname, resetNickname, undeafen, undeafen, unmute, unmute, updateNickname, updateNickname
-
-
-
-
Constructor Detail
-
UserImpl
public UserImpl(DiscordApiImpl api, com.fasterxml.jackson.databind.JsonNode data)
Creates a new user.- Parameters:
api
- The discord api instance.data
- The json data of the user.
-
-
Method Detail
-
setChannel
public void setChannel(PrivateChannel channel)
Sets the private channel with the user.- Parameters:
channel
- The channel to set.
-
setActivity
public void setActivity(Activity activity)
Sets the activity of the user.- Parameters:
activity
- The activity to set.
-
setStatus
public void setStatus(UserStatus status)
Sets the status of the user.- Parameters:
status
- The status to set.
-
setClientStatus
public void setClientStatus(DiscordClient client, UserStatus status)
Sets the client status of the user.- Parameters:
client
- The client.status
- The status to set.
-
setName
public void setName(String name)
Sets the name of the user.- Parameters:
name
- The name to set.
-
setDiscriminator
public void setDiscriminator(String discriminator)
Sets the discriminator of the user.- Parameters:
discriminator
- The discriminator to set.
-
getAvatarHash
public String getAvatarHash()
Gets the avatar hash of the user. Might benull
.- Returns:
- The avatar hash of the user.
-
setAvatarHash
public void setAvatarHash(String avatarHash)
Sets the avatar hash of the user.- Parameters:
avatarHash
- The avatar hash to set.
-
getOrCreateChannel
public PrivateChannel getOrCreateChannel(com.fasterxml.jackson.databind.JsonNode data)
Gets or creates a new private channel.- Parameters:
data
- The data of the private channel.- Returns:
- The private channel for the given data.
-
getDiscriminator
public String getDiscriminator()
- Specified by:
getDiscriminator
in interfaceUser
-
getActivity
public Optional<Activity> getActivity()
- Specified by:
getActivity
in interfaceUser
-
getStatus
public UserStatus getStatus()
-
getStatusOnClient
public UserStatus getStatusOnClient(DiscordClient client)
- Specified by:
getStatusOnClient
in interfaceUser
-
getAvatar
public static Icon getAvatar(DiscordApi api, String avatarHash, String discriminator, long userId)
Gets the avatar for the given details.- Parameters:
api
- The discord api instance.avatarHash
- The avatar hash ornull
for default avatar.discriminator
- The discriminator if default avatar is wanted.userId
- The user id.- Returns:
- The avatar for the given details.
-
hasDefaultAvatar
public boolean hasDefaultAvatar()
- Specified by:
hasDefaultAvatar
in interfaceUser
-
getPrivateChannel
public Optional<PrivateChannel> getPrivateChannel()
- Specified by:
getPrivateChannel
in interfaceUser
-
openPrivateChannel
public CompletableFuture<PrivateChannel> openPrivateChannel()
- Specified by:
openPrivateChannel
in interfaceUser
-
getApi
public DiscordApi getApi()
Description copied from interface:InternalUserAttachableListenerManager
Gets the discord api instance.- Specified by:
getApi
in interfaceDiscordEntity
- Specified by:
getApi
in interfaceInternalUserAttachableListenerManager
- Returns:
- The discord api instance.
-
getId
public long getId()
Description copied from interface:InternalUserAttachableListenerManager
Gets the id of this object.- Specified by:
getId
in interfaceDiscordEntity
- Specified by:
getId
in interfaceInternalUserAttachableListenerManager
- Returns:
- The id of this object.
-
cleanup
public void cleanup()
Description copied from interface:Cleanupable
Does any cleanup that would prevent this instance from being eligible for garbage collection like cancelling scheduled repeated tasks or callingcleanup
on "owned" cleanupable objects. This method has to be thread-safe and idempotent.- Specified by:
cleanup
in interfaceCleanupable
-
-