Interface User
-
- All Superinterfaces:
DiscordEntity,Formattable,Mentionable,Messageable,Nameable,Permissionable,Updatable<User>,UpdatableFromCache<User>,UserAttachableListenerManager
public interface User extends DiscordEntity, Messageable, Nameable, Mentionable, Permissionable, UpdatableFromCache<User>, UserAttachableListenerManager
This class represents a user.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default CompletableFuture<Void>addRole(Role role)Adds the given role to the user.default CompletableFuture<Void>addRole(Role role, String reason)Adds the given role to the user.default booleancanManageRole(Role role)Checks if the user can manage the target role.default CompletableFuture<Void>deafen(Server server)Deafens this user on the given server.default CompletableFuture<Void>deafen(Server server, String reason)Deafens this user on the given server.Set<Activity>getActivities()Gets the activities of the user.IcongetAvatar()Gets the avatar of the user.default Optional<ServerVoiceChannel>getConnectedVoiceChannel(Server server)Gets the voice channel this user is connected to on the given server if any.default Collection<ServerVoiceChannel>getConnectedVoiceChannels()Gets the server voice channels the user is connected to.default Optional<User>getCurrentCachedInstance()Gets an updated instance of this entity from the cache.default Set<DiscordClient>getCurrentClients()Gets all clients of the user that are notoffline.default UserStatusgetDesktopStatus()Gets the status of the user on thedesktopclient.default StringgetDiscriminatedName()Gets the discriminated name of the user, e.StringgetDiscriminator()Gets the discriminator of the user.StringgetDisplayName(Server server)Gets the display name of the user.default Collection<GroupChannel>getGroupChannels()Gets the currently existing group channels with the user.Optional<Instant>getJoinedAtTimestamp(Server server)Gets the timestamp of when the user joined the given server.default CompletableFuture<User>getLatestInstance()Gets an updated instance of this entity from the cache or from Discord directly.default StringgetMentionTag()Gets the tag used to mention the entity.default UserStatusgetMobileStatus()Gets the status of the user on themobileclient.Collection<Server>getMutualServers()Gets all mutual servers with this user.Optional<String>getNickname(Server server)Gets the nickname of the user in the given server.default StringgetNicknameMentionTag()Gets the mention tag, to mention the user with its nickname, instead of its normal name.Optional<PrivateChannel>getPrivateChannel()Gets the private channel with the user.Optional<Color>getRoleColor(Server server)Gets the displayed color of the user based on his roles in the given server.List<Role>getRoles(Server server)Gets a sorted list (by position) with all roles of the user in the given server.UserStatusgetStatus()Gets the connection status of the user as it is displayed in the user list.UserStatusgetStatusOnClient(DiscordClient client)Gets the status of the user on the given client.EnumSet<UserFlag>getUserFlags()Gets the public flags (badges) present on this account.default UserStatusgetWebStatus()Gets the status of the user on theweb(browser) client.booleanhasDefaultAvatar()Gets if the user has a default Discord avatar.booleanisBot()Checks if the user is a bot account.default booleanisBotOwner()Checks if this user is the owner of the current account.default booleanisConnected(ServerVoiceChannel channel)Checks whether this user is connected to the given channel.default booleanisDeafened(Server server)Gets the deafened state of the user in the given server.default booleanisMuted(Server server)Gets the muted state of the user in the given server.booleanisSelfDeafened(Server server)Gets the self-deafened state of the user in the given server.booleanisSelfMuted(Server server)Gets the self-muted state of the user in the given server.default booleanisYourself()Gets if this user is the user of the connected account.default CompletableFuture<Void>move(ServerVoiceChannel channel)Moves this user to the given channel.default CompletableFuture<Void>mute(Server server)Mutes this user on the given server.default CompletableFuture<Void>mute(Server server, String reason)Mutes this user on the given server.CompletableFuture<PrivateChannel>openPrivateChannel()Opens a new private channel with the given user.default CompletableFuture<Void>removeRole(Role role)Removes the given role from the user.default CompletableFuture<Void>removeRole(Role role, String reason)Removes the given role from the user.default CompletableFuture<Void>resetNickname(Server server)Removes the nickname of the user in the given server.default CompletableFuture<Void>resetNickname(Server server, String reason)Removes the nickname of the user in the given server.default CompletableFuture<Void>undeafen(Server server)Undeafens this user on the given server.default CompletableFuture<Void>undeafen(Server server, String reason)Undeafens this user on the given server.default CompletableFuture<Void>unmute(Server server)Unmutes this user on the given server.default CompletableFuture<Void>unmute(Server server, String reason)Unmutes this user on the given server.default CompletableFuture<Void>updateNickname(Server server, String nickname)Changes the nickname of the user in the given server.default CompletableFuture<Void>updateNickname(Server server, String nickname, String reason)Changes the nickname of the user in the given server.-
Methods inherited from interface org.javacord.api.entity.DiscordEntity
getApi, getCreationTimestamp, getCreationTimestamp, getId, getIdAsString
-
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 interface org.javacord.api.listener.user.UserAttachableListenerManager
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
-
-
-
-
Method Detail
-
getMentionTag
default String getMentionTag()
Description copied from interface:MentionableGets the tag used to mention the entity.- Specified by:
getMentionTagin interfaceMentionable- Returns:
- The tag used to mention the entity.
-
getNicknameMentionTag
default String getNicknameMentionTag()
Gets the mention tag, to mention the user with its nickname, instead of its normal name.- Returns:
- The mention tag, to mention the user with its nickname.
-
getDiscriminator
String getDiscriminator()
Gets the discriminator of the user.- Returns:
- The discriminator of the user.
-
isBot
boolean isBot()
Checks if the user is a bot account.- Returns:
- Whether the user is a bot account or not.
-
isBotOwner
default boolean isBotOwner()
Checks if this user is the owner of the current account. Always returnsfalseif logged in to a user account.- Returns:
- Whether this user is the owner of the current account.
-
getActivities
Set<Activity> getActivities()
Gets the activities of the user.- Returns:
- The activities of the user.
-
canManageRole
default boolean canManageRole(Role role)
Checks if the user can manage the target role.- Parameters:
role- The role that is to be managed.- Returns:
- Whether the user can manage the role.
-
getConnectedVoiceChannels
default Collection<ServerVoiceChannel> getConnectedVoiceChannels()
Gets the server voice channels the user is connected to.- Returns:
- The server voice channels the user is connected to.
-
isConnected
default boolean isConnected(ServerVoiceChannel channel)
Checks whether this user is connected to the given channel.- Parameters:
channel- The channel to check.- Returns:
- Whether this user is connected to the given channel or not.
-
getConnectedVoiceChannel
default Optional<ServerVoiceChannel> getConnectedVoiceChannel(Server server)
Gets the voice channel this user is connected to on the given server if any.- Parameters:
server- The server to check.- Returns:
- The server voice channel the user is connected to.
-
getStatus
UserStatus getStatus()
Gets the connection status of the user as it is displayed in the user list.This will return
UserStatus.OFFLINEfor invisible users.To see if a non-offline user is connected via a mobile client, a desktop client, a web client or any combination of the three use the
getStatusOnClient(DiscordClient)} method.- Returns:
- The status of the user.
-
getStatusOnClient
UserStatus getStatusOnClient(DiscordClient client)
Gets the status of the user on the given client.This will return
UserStatus.OFFLINEfor invisible users.- Parameters:
client- The client.- Returns:
- The status of the user
- See Also:
getStatus()
-
getDesktopStatus
default UserStatus getDesktopStatus()
Gets the status of the user on thedesktopclient.This will return
UserStatus.OFFLINEfor invisible users.- Returns:
- The status of the the user.
- See Also:
getStatusOnClient(DiscordClient)
-
getMobileStatus
default UserStatus getMobileStatus()
Gets the status of the user on themobileclient.This will return
UserStatus.OFFLINEfor invisible users.- Returns:
- The status of the the user.
- See Also:
getStatusOnClient(DiscordClient)
-
getWebStatus
default UserStatus getWebStatus()
Gets the status of the user on theweb(browser) client.This will return
UserStatus.OFFLINEfor invisible users.- Returns:
- The status of the the user.
- See Also:
getStatusOnClient(DiscordClient)
-
getCurrentClients
default Set<DiscordClient> getCurrentClients()
Gets all clients of the user that are notoffline.- Returns:
- A set with the clients.
- See Also:
getStatusOnClient(DiscordClient)
-
getUserFlags
EnumSet<UserFlag> getUserFlags()
Gets the public flags (badges) present on this account.- Returns:
- The public flags for this account.
-
getAvatar
Icon getAvatar()
Gets the avatar of the user.- Returns:
- The avatar of the user.
-
hasDefaultAvatar
boolean hasDefaultAvatar()
Gets if the user has a default Discord avatar.- Returns:
- Whether this user has a default avatar or not.
-
getMutualServers
Collection<Server> getMutualServers()
Gets all mutual servers with this user.- Returns:
- All mutual servers with this user.
-
getDisplayName
String getDisplayName(Server server)
Gets the display name of the user. If the user has a nickname, it will return the nickname, otherwise it will return the "normal" name.- Parameters:
server- The server.- Returns:
- The display name of the user.
-
getDiscriminatedName
default String getDiscriminatedName()
Gets the discriminated name of the user, e. g.Bastian#8222.- Returns:
- The discriminated name of the user.
-
updateNickname
default CompletableFuture<Void> updateNickname(Server server, String nickname)
Changes the nickname of the user in the given server.If you want to update several settings at once, it's recommended to use the
ServerUpdaterfromServer.createUpdater()which provides a better performance!- Parameters:
server- The server.nickname- The new nickname of the user.- Returns:
- A future to check if the update was successful.
-
updateNickname
default CompletableFuture<Void> updateNickname(Server server, String nickname, String reason)
Changes the nickname of the user in the given server.If you want to update several settings at once, it's recommended to use the
ServerUpdaterfromServer.createUpdater()which provides a better performance!- Parameters:
server- The server.nickname- The new nickname of the user.reason- The audit log reason for this update.- Returns:
- A future to check if the update was successful.
-
resetNickname
default CompletableFuture<Void> resetNickname(Server server)
Removes the nickname of the user in the given server.If you want to update several settings at once, it's recommended to use the
ServerUpdaterfromServer.createUpdater()which provides a better performance!- Parameters:
server- The server.- Returns:
- A future to check if the update was successful.
-
resetNickname
default CompletableFuture<Void> resetNickname(Server server, String reason)
Removes the nickname of the user in the given server.If you want to update several settings at once, it's recommended to use the
ServerUpdaterfromServer.createUpdater()which provides a better performance!- Parameters:
server- The server.reason- The audit log reason for this update.- Returns:
- A future to check if the update was successful.
-
getNickname
Optional<String> getNickname(Server server)
Gets the nickname of the user in the given server.- Parameters:
server- The server to check.- Returns:
- The nickname of the user.
-
move
default CompletableFuture<Void> move(ServerVoiceChannel channel)
Moves this user to the given channel.- Parameters:
channel- The channel to move the user to.- Returns:
- A future to check if the move was successful.
-
isSelfMuted
boolean isSelfMuted(Server server)
Gets the self-muted state of the user in the given server.- Parameters:
server- The server to check.- Returns:
- Whether the user is self-muted in the given server.
-
isSelfDeafened
boolean isSelfDeafened(Server server)
Gets the self-deafened state of the user in the given server.- Parameters:
server- The server to check.- Returns:
- Whether the user is self-deafened in the given server.
-
mute
default CompletableFuture<Void> mute(Server server)
Mutes this user on the given server.- Parameters:
server- The server to umute this user on.- Returns:
- A future to check if the mute was successful.
-
mute
default CompletableFuture<Void> mute(Server server, String reason)
Mutes this user on the given server.- Parameters:
server- The server to umute this user on.reason- The audit log reason for this action.- Returns:
- A future to check if the mute was successful.
-
unmute
default CompletableFuture<Void> unmute(Server server)
Unmutes this user on the given server.- Parameters:
server- The server to unumute this user on.- Returns:
- A future to check if the unmute was successful.
-
unmute
default CompletableFuture<Void> unmute(Server server, String reason)
Unmutes this user on the given server.- Parameters:
server- The server to unumute this user on.reason- The audit log reason for this action.- Returns:
- A future to check if the unmute was successful.
-
isMuted
default boolean isMuted(Server server)
Gets the muted state of the user in the given server.- Parameters:
server- The server to check.- Returns:
- Whether the user is muted in the given server.
-
deafen
default CompletableFuture<Void> deafen(Server server)
Deafens this user on the given server.- Parameters:
server- The server to deafen this user on.- Returns:
- A future to check if the deafen was successful.
-
deafen
default CompletableFuture<Void> deafen(Server server, String reason)
Deafens this user on the given server.- Parameters:
server- The server to deafen this user on.reason- The audit log reason for this action.- Returns:
- A future to check if the deafen was successful.
-
undeafen
default CompletableFuture<Void> undeafen(Server server)
Undeafens this user on the given server.- Parameters:
server- The server to undeafen this user on.- Returns:
- A future to check if the undeafen was successful.
-
undeafen
default CompletableFuture<Void> undeafen(Server server, String reason)
Undeafens this user on the given server.- Parameters:
server- The server to undeafen this user on.reason- The audit log reason for this action.- Returns:
- A future to check if the undeafen was successful.
-
isDeafened
default boolean isDeafened(Server server)
Gets the deafened state of the user in the given server.- Parameters:
server- The server to check.- Returns:
- Whether the user is deafened in the given server.
-
getJoinedAtTimestamp
Optional<Instant> getJoinedAtTimestamp(Server server)
Gets the timestamp of when the user joined the given server.- Parameters:
server- The server to check.- Returns:
- The timestamp of when the user joined the server.
-
getRoles
List<Role> getRoles(Server server)
Gets a sorted list (by position) with all roles of the user in the given server.- Parameters:
server- The server.- Returns:
- A sorted list (by position) with all roles of the user in the given server.
- See Also:
Server.getRoles(User)
-
getRoleColor
Optional<Color> getRoleColor(Server server)
Gets the displayed color of the user based on his roles in the given server.- Parameters:
server- The server.- Returns:
- The color.
- See Also:
Server.getRoleColor(User)
-
isYourself
default boolean isYourself()
Gets if this user is the user of the connected account.- Returns:
- Whether this user is the user of the connected account or not.
- See Also:
DiscordApi.getYourself()
-
getPrivateChannel
Optional<PrivateChannel> getPrivateChannel()
Gets the private channel with the user. This will only be present, if there was an conversation with the user in the past or you manually opened a private channel with the given user, usingopenPrivateChannel().- Returns:
- The private channel with the user.
-
openPrivateChannel
CompletableFuture<PrivateChannel> openPrivateChannel()
Opens a new private channel with the given user. If there's already a private channel with the user, it will just return the one which already exists.- Returns:
- The new (or old) private channel with the user.
-
getGroupChannels
default Collection<GroupChannel> getGroupChannels()
Gets the currently existing group channels with the user.- Returns:
- The group channels with the user.
-
addRole
default CompletableFuture<Void> addRole(Role role)
Adds the given role to the user.If you want to update several settings at once, it's recommended to use the
ServerUpdaterfromServer.createUpdater()which provides a better performance!- Parameters:
role- The role which should be added to the user.- Returns:
- A future to check if the update was successful.
- See Also:
Server.addRoleToUser(User, Role)
-
addRole
default CompletableFuture<Void> addRole(Role role, String reason)
Adds the given role to the user.If you want to update several settings at once, it's recommended to use the
ServerUpdaterfromServer.createUpdater()which provides a better performance!- Parameters:
role- The role which should be added to the user.reason- The audit log reason for this update.- Returns:
- A future to check if the update was successful.
- See Also:
Server.addRoleToUser(User, Role, String)
-
removeRole
default CompletableFuture<Void> removeRole(Role role)
Removes the given role from the user.If you want to update several settings at once, it's recommended to use the
ServerUpdaterfromServer.createUpdater()which provides a better performance!- Parameters:
role- The role which should be removed from the user.- Returns:
- A future to check if the update was successful.
- See Also:
Server.removeRoleFromUser(User, Role)
-
removeRole
default CompletableFuture<Void> removeRole(Role role, String reason)
Removes the given role from the user.If you want to update several settings at once, it's recommended to use the
ServerUpdaterfromServer.createUpdater()which provides a better performance!- Parameters:
role- The role which should be removed from the user.reason- The audit log reason for this update.- Returns:
- A future to check if the update was successful.
- See Also:
Server.removeRoleFromUser(User, Role, String)
-
getCurrentCachedInstance
default Optional<User> getCurrentCachedInstance()
Description copied from interface:UpdatableFromCacheGets an updated instance of this entity from the cache. This is for example necessary if an instance got invalid by a reconnect to Discord which invalidates all existing instances which means they do not get any further updates from Discord applied. Due to that, references to instances should usually not be held for an extended period of time. If they are, this method can be used to retrieve the current instance from the cache, that gets updates from Discord, in case this one was invalidated.This method returns the currently cached entity, or an empty
Optionalif the entity is not cached any longer, for example because it was deleted or the message was thrown out of the cache.- Specified by:
getCurrentCachedInstancein interfaceUpdatableFromCache<User>- Returns:
- The current cached instance.
-
getLatestInstance
default CompletableFuture<User> getLatestInstance()
Description copied from interface:UpdatableGets an updated instance of this entity from the cache or from Discord directly. This is for example necessary if an instance got invalid by a reconnect to Discord which invalidates all existing instances which means they do not get any further updates from Discord applied. Due to that, references to instances should usually not be held for an extended period of time. If they are, this method can be used to retrieve the current instance from the cache if present or from Discord directly.This method returns the currently cached entity if present, or request the entity from Discord if it is not cached or not permanently cached. If the entity is a fully cached entity and is not in the cache any longer, for example because it was deleted or the message was thrown out of the cache, the
CompletableFuturecompletes exceptionally with aNoSuchElementException. If a request to Discord is made, the according remote call exception will be used to complete theCompletableFutureexceptionally.- Specified by:
getLatestInstancein interfaceUpdatable<User>- Specified by:
getLatestInstancein interfaceUpdatableFromCache<User>- Returns:
- The current cached instance.
-
-