Interface User
-
- All Superinterfaces:
DiscordEntity
,java.util.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 java.util.concurrent.CompletableFuture<java.lang.Void>
addRole(Role role)
Adds the given role to the user.default java.util.concurrent.CompletableFuture<java.lang.Void>
addRole(Role role, java.lang.String reason)
Adds the given role to the user.default boolean
canManageRole(Role role)
Checks if the user can manage the target role.default java.util.concurrent.CompletableFuture<java.lang.Void>
deafen(Server server)
Deafens this user on the given server.default java.util.concurrent.CompletableFuture<java.lang.Void>
deafen(Server server, java.lang.String reason)
Deafens this user on the given server.default java.util.Optional<java.time.Instant>
getActiveTimeout(Server server)
Gets the timestamp of when the user's timeout will expire and the user will be able to communicate in the server again.java.util.Set<Activity>
getActivities()
Gets the activities of the user.Icon
getAvatar()
Gets the avatar of the user.Icon
getAvatar(int size)
Gets the avatar of the user.java.util.Optional<java.lang.String>
getAvatarHash()
Gets the avatar hash of the user.default java.util.Optional<ServerVoiceChannel>
getConnectedVoiceChannel(Server server)
Gets the voice channel this user is connected to on the given server if any.default java.util.Collection<ServerVoiceChannel>
getConnectedVoiceChannels()
Gets the server voice channels the user is connected to.default java.util.Optional<User>
getCurrentCachedInstance()
Gets an updated instance of this entity from the cache.default java.util.Set<DiscordClient>
getCurrentClients()
Gets all clients of the user that are notoffline
.default UserStatus
getDesktopStatus()
Gets the status of the user on thedesktop
client.default java.lang.String
getDiscriminatedName()
Gets the discriminated name of the user, e.g.java.lang.String
getDiscriminator()
Gets the discriminator of the user.java.lang.String
getDisplayName(Server server)
Gets the display name of the user.Icon
getEffectiveAvatar(Server server)
Gets the user's effective avatar in the given server.Icon
getEffectiveAvatar(Server server, int size)
Gets the user's effective avatar in the given server at the given size.java.util.Optional<java.time.Instant>
getJoinedAtTimestamp(Server server)
Gets the timestamp of when the user joined the given server.default java.util.concurrent.CompletableFuture<User>
getLatestInstance()
Gets an updated instance of this entity from the cache or from Discord directly.default java.lang.String
getMentionTag()
Gets the tag used to mention the entity.default UserStatus
getMobileStatus()
Gets the status of the user on themobile
client.java.util.Set<Server>
getMutualServers()
Gets all mutual servers with this user.java.util.Optional<java.lang.String>
getNickname(Server server)
Gets the nickname of the user in the given server.default java.lang.String
getNicknameMentionTag()
Gets the mention tag, to mention the user with its nickname, instead of its normal name.java.util.Optional<PrivateChannel>
getPrivateChannel()
Gets the private channel with the user.java.util.Optional<java.awt.Color>
getRoleColor(Server server)
Gets the displayed color of the user based on their roles in the given server.java.util.List<Role>
getRoles(Server server)
Gets a sorted list (by position) with all roles of the user in the given server.java.util.Optional<Icon>
getServerAvatar(Server server)
Gets the user's server-specific avatar in the given server.java.util.Optional<Icon>
getServerAvatar(Server server, int size)
Gets the user's server-specific avatar in the given server at the given image size.UserStatus
getStatus()
Gets the connection status of the user as it is displayed in the user list.UserStatus
getStatusOnClient(DiscordClient client)
Gets the status of the user on the given client.java.util.Optional<java.time.Instant>
getTimeout(Server server)
Gets the timestamp of when the user's timeout will expire and the user will be able to communicate in the server again.java.util.EnumSet<UserFlag>
getUserFlags()
Gets the public flags (badges) present on this account.default UserStatus
getWebStatus()
Gets the status of the user on theweb
(browser) client.boolean
hasDefaultAvatar()
Gets if the user has a default Discord avatar.boolean
isBot()
Checks if the user is a bot account.default boolean
isBotOwner()
Checks if this user is the owner of the current account.default boolean
isConnected(ServerVoiceChannel channel)
Checks whether this user is connected to the given channel.default boolean
isDeafened(Server server)
Gets the deafened state of the user in the given server.default boolean
isMuted(Server server)
Gets the muted state of the user in the given server.boolean
isPending(Server server)
Gets the pending state of the user in the given server.boolean
isSelfDeafened(Server server)
Gets the self-deafened state of the user in the given server.boolean
isSelfMuted(Server server)
Gets the self-muted state of the user in the given server.default boolean
isYourself()
Gets if this user is the user of the connected account.default java.util.concurrent.CompletableFuture<java.lang.Void>
move(ServerVoiceChannel channel)
Moves this user to the given channel.default java.util.concurrent.CompletableFuture<java.lang.Void>
mute(Server server)
Mutes this user on the given server.default java.util.concurrent.CompletableFuture<java.lang.Void>
mute(Server server, java.lang.String reason)
Mutes this user on the given server.java.util.concurrent.CompletableFuture<PrivateChannel>
openPrivateChannel()
Opens a new private channel with the given user.default java.util.concurrent.CompletableFuture<java.lang.Void>
removeRole(Role role)
Removes the given role from the user.default java.util.concurrent.CompletableFuture<java.lang.Void>
removeRole(Role role, java.lang.String reason)
Removes the given role from the user.default java.util.concurrent.CompletableFuture<java.lang.Void>
removeTimeout(Server server)
Removes a timeout of the user on the given server.default java.util.concurrent.CompletableFuture<java.lang.Void>
removeTimeout(Server server, java.lang.String reason)
Removes a timeout of the user on the given server.default java.util.concurrent.CompletableFuture<java.lang.Void>
resetNickname(Server server)
Removes the nickname of the user in the given server.default java.util.concurrent.CompletableFuture<java.lang.Void>
resetNickname(Server server, java.lang.String reason)
Removes the nickname of the user in the given server.default java.util.concurrent.CompletableFuture<java.lang.Void>
timeout(Server server, java.time.Duration duration)
Timeouts the user on the given server.default java.util.concurrent.CompletableFuture<java.lang.Void>
timeout(Server server, java.time.Duration duration, java.lang.String reason)
Timeouts the user on the given server.default java.util.concurrent.CompletableFuture<java.lang.Void>
timeout(Server server, java.time.Instant timeout)
Timeouts the user on the given server.default java.util.concurrent.CompletableFuture<java.lang.Void>
timeout(Server server, java.time.Instant timeout, java.lang.String reason)
Timeouts the user on the given server.default java.util.concurrent.CompletableFuture<java.lang.Void>
undeafen(Server server)
Undeafens this user on the given server.default java.util.concurrent.CompletableFuture<java.lang.Void>
undeafen(Server server, java.lang.String reason)
Undeafens this user on the given server.default java.util.concurrent.CompletableFuture<java.lang.Void>
unmute(Server server)
Unmutes this user on the given server.default java.util.concurrent.CompletableFuture<java.lang.Void>
unmute(Server server, java.lang.String reason)
Unmutes this user on the given server.default java.util.concurrent.CompletableFuture<java.lang.Void>
updateNickname(Server server, java.lang.String nickname)
Changes the nickname of the user in the given server.default java.util.concurrent.CompletableFuture<java.lang.Void>
updateNickname(Server server, java.lang.String nickname, java.lang.String reason)
Changes the nickname of the user in the given server.-
Methods inherited from interface org.javacord.api.entity.DiscordEntity
getApi, 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, sendMessage, sendMessage, sendMessage, sendMessage, sendMessage, sendMessage, sendMessage, sendMessage, sendMessage, sendMessage, sendMessage, sendMessage, sendMessage
-
Methods inherited from interface org.javacord.api.listener.user.UserAttachableListenerManager
addAutocompleteCreateListener, addButtonClickListener, addInteractionCreateListener, addMessageComponentCreateListener, addMessageContextMenuCommandListener, addMessageCreateListener, addModalSubmitListener, addPrivateChannelCreateListener, addPrivateChannelDeleteListener, addReactionAddListener, addReactionRemoveListener, addSelectMenuChooseListener, addServerChannelChangeOverwrittenPermissionsListener, addServerMemberBanListener, addServerMemberJoinListener, addServerMemberLeaveListener, addServerMemberUnbanListener, addServerVoiceChannelMemberJoinListener, addServerVoiceChannelMemberLeaveListener, addSlashCommandCreateListener, addUserAttachableListener, addUserChangeActivityListener, addUserChangeAvatarListener, addUserChangeDeafenedListener, addUserChangeDiscriminatorListener, addUserChangeMutedListener, addUserChangeNameListener, addUserChangeNicknameListener, addUserChangePendingListener, addUserChangeSelfDeafenedListener, addUserChangeSelfMutedListener, addUserChangeServerAvatarListener, addUserChangeStatusListener, addUserChangeTimeoutListener, addUserContextMenuCommandListener, addUserRoleAddListener, addUserRoleRemoveListener, addUserStartTypingListener, getAutocompleteCreateListeners, getButtonClickListeners, getInteractionCreateListeners, getMessageComponentCreateListeners, getMessageContextMenuCommandListeners, getMessageCreateListeners, getModalSubmitListeners, getPrivateChannelCreateListeners, getPrivateChannelDeleteListeners, getReactionAddListeners, getReactionRemoveListeners, getSelectMenuChooseListeners, getServerChannelChangeOverwrittenPermissionsListeners, getServerMemberBanListeners, getServerMemberJoinListeners, getServerMemberLeaveListeners, getServerMemberUnbanListeners, getServerVoiceChannelMemberJoinListeners, getServerVoiceChannelMemberLeaveListeners, getSlashCommandCreateListeners, getUserAttachableListeners, getUserChangeActivityListeners, getUserChangeAvatarListeners, getUserChangeDeafenedListeners, getUserChangeDiscriminatorListeners, getUserChangeMutedListeners, getUserChangeNameListeners, getUserChangeNicknameListeners, getUserChangePendingListeners, getUserChangeSelfDeafenedListeners, getUserChangeSelfMutedListeners, getUserChangeServerAvatarListeners, getUserChangeStatusListeners, getUserChangeTimeoutListeners, getUserContextMenuCommandListeners, getUserRoleAddListeners, getUserRoleRemoveListeners, getUserStartTypingListeners, removeListener, removeUserAttachableListener
-
-
-
-
Method Detail
-
getMentionTag
default java.lang.String getMentionTag()
Description copied from interface:Mentionable
Gets the tag used to mention the entity.- Specified by:
getMentionTag
in interfaceMentionable
- Returns:
- The tag used to mention the entity.
-
getNicknameMentionTag
default java.lang.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
java.lang.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 returnsfalse
if logged in to a user account.- Returns:
- Whether this user is the owner of the current account.
-
getActivities
java.util.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 java.util.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 java.util.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.OFFLINE
for 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.OFFLINE
for 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 thedesktop
client.This will return
UserStatus.OFFLINE
for invisible users.- Returns:
- The status of the user.
- See Also:
getStatusOnClient(DiscordClient)
-
getMobileStatus
default UserStatus getMobileStatus()
Gets the status of the user on themobile
client.This will return
UserStatus.OFFLINE
for invisible users.- Returns:
- The status of the user.
- See Also:
getStatusOnClient(DiscordClient)
-
getWebStatus
default UserStatus getWebStatus()
Gets the status of the user on theweb
(browser) client.This will return
UserStatus.OFFLINE
for invisible users.- Returns:
- The status of the user.
- See Also:
getStatusOnClient(DiscordClient)
-
getCurrentClients
default java.util.Set<DiscordClient> getCurrentClients()
Gets all clients of the user that are notoffline
.- Returns:
- A set with the clients.
- See Also:
getStatusOnClient(DiscordClient)
-
getUserFlags
java.util.EnumSet<UserFlag> getUserFlags()
Gets the public flags (badges) present on this account.- Returns:
- The public flags for this account.
-
getAvatarHash
java.util.Optional<java.lang.String> getAvatarHash()
Gets the avatar hash of the user.- Returns:
- The avatar hash.
-
getAvatar
Icon getAvatar()
Gets the avatar of the user.- Returns:
- The avatar of the user.
-
getAvatar
Icon getAvatar(int size)
Gets the avatar of the user.- Parameters:
size
- the size of the image. must be any power of 2 between 16 and 4096- Returns:
- The avatar of the user.
-
getServerAvatar
java.util.Optional<Icon> getServerAvatar(Server server)
Gets the user's server-specific avatar in the given server.- Parameters:
server
- The server.- Returns:
- The user's avatar in the server
-
getServerAvatar
java.util.Optional<Icon> getServerAvatar(Server server, int size)
Gets the user's server-specific avatar in the given server at the given image size.- Parameters:
server
- The server.size
- The size of the image, must be any power of 2 between 16 and 4096.- Returns:
- The user's avatar in the server.
-
getEffectiveAvatar
Icon getEffectiveAvatar(Server server)
Gets the user's effective avatar in the given server. This will return the user's server-specific avatar if they have one, otherwise it will return their account avatar.- Parameters:
server
- The server.- Returns:
- The user's effective avatar.
-
getEffectiveAvatar
Icon getEffectiveAvatar(Server server, int size)
Gets the user's effective avatar in the given server at the given size. This will return the user's server-specific avatar if they have one, otherwise it will return their account avatar.- Parameters:
server
- The server.size
- The size of the image, must be any power of 2 between 16 and 4096.- Returns:
- The user's effective avatar.
-
hasDefaultAvatar
boolean hasDefaultAvatar()
Gets if the user has a default Discord avatar.- Returns:
- Whether this user has a default avatar or not.
-
getMutualServers
java.util.Set<Server> getMutualServers()
Gets all mutual servers with this user.- Returns:
- All mutual servers with this user.
-
getDisplayName
java.lang.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 java.lang.String getDiscriminatedName()
Gets the discriminated name of the user, e.g.Bastian#8222
.- Returns:
- The discriminated name of the user.
-
updateNickname
default java.util.concurrent.CompletableFuture<java.lang.Void> updateNickname(Server server, java.lang.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
ServerUpdater
fromServer.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 java.util.concurrent.CompletableFuture<java.lang.Void> updateNickname(Server server, java.lang.String nickname, java.lang.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
ServerUpdater
fromServer.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 java.util.concurrent.CompletableFuture<java.lang.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
ServerUpdater
fromServer.createUpdater()
which provides a better performance!- Parameters:
server
- The server.- Returns:
- A future to check if the update was successful.
-
resetNickname
default java.util.concurrent.CompletableFuture<java.lang.Void> resetNickname(Server server, java.lang.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
ServerUpdater
fromServer.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
java.util.Optional<java.lang.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.
-
timeout
default java.util.concurrent.CompletableFuture<java.lang.Void> timeout(Server server, java.time.Instant timeout)
Timeouts the user on the given server.If you want to update several settings at once, it's recommended to use the
ServerUpdater
fromServer.createUpdater()
which provides a better performance!- Parameters:
server
- The server.timeout
- The new timeout of the user.- Returns:
- A future to check if the update was successful.
-
timeout
default java.util.concurrent.CompletableFuture<java.lang.Void> timeout(Server server, java.time.Instant timeout, java.lang.String reason)
Timeouts the user on the given server.If you want to update several settings at once, it's recommended to use the
ServerUpdater
fromServer.createUpdater()
which provides a better performance!- Parameters:
server
- The server.timeout
- The new timeout of the user.reason
- The audit log reason for this update.- Returns:
- A future to check if the update was successful.
-
timeout
default java.util.concurrent.CompletableFuture<java.lang.Void> timeout(Server server, java.time.Duration duration)
Timeouts the user on the given server.If you want to update several settings at once, it's recommended to use the
ServerUpdater
fromServer.createUpdater()
which provides a better performance!- Parameters:
server
- The server.duration
- The duration of the timeout.- Returns:
- A future to check if the update was successful.
-
timeout
default java.util.concurrent.CompletableFuture<java.lang.Void> timeout(Server server, java.time.Duration duration, java.lang.String reason)
Timeouts the user on the given server.If you want to update several settings at once, it's recommended to use the
ServerUpdater
fromServer.createUpdater()
which provides a better performance!- Parameters:
server
- The server.duration
- The duration of the timeout.reason
- The audit log reason for this update.- Returns:
- A future to check if the update was successful.
-
removeTimeout
default java.util.concurrent.CompletableFuture<java.lang.Void> removeTimeout(Server server)
Removes a timeout of the user on the given server.If you want to update several settings at once, it's recommended to use the
ServerUpdater
fromServer.createUpdater()
which provides a better performance!- Parameters:
server
- The server.- Returns:
- A future to check if the update was successful.
-
removeTimeout
default java.util.concurrent.CompletableFuture<java.lang.Void> removeTimeout(Server server, java.lang.String reason)
Removes a timeout of the user on the given server.If you want to update several settings at once, it's recommended to use the
ServerUpdater
fromServer.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.
-
getTimeout
java.util.Optional<java.time.Instant> getTimeout(Server server)
Gets the timestamp of when the user's 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.- Parameters:
server
- The server to get the timeout for the user from.- Returns:
- The timestamp of when this user will no longer be timed out. Empty or a timestamp in the past, if user is currently not timed out.
-
getActiveTimeout
default java.util.Optional<java.time.Instant> getActiveTimeout(Server server)
Gets the timestamp of when the user's timeout will expire and the user will be able to communicate in the server again. The returned Instant will be checked againstInstant.now()
and will only return an Instant, if the timeout is active at the moment when this method is called.- Parameters:
server
- The server to get the timeout for the user from.- Returns:
- The timestamp of when this user will no longer be timed out.
-
isPending
boolean isPending(Server server)
Gets the pending state of the user in the given server.This will always return false if the server doesn't have membership screening enable. You can check through
Server.getFeatures()
if it hasServerFeature.MEMBER_VERIFICATION_GATE_ENABLED
.- Parameters:
server
- The server to check.- Returns:
- Whether the user has passed the Membership screening.
-
move
default java.util.concurrent.CompletableFuture<java.lang.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 java.util.concurrent.CompletableFuture<java.lang.Void> mute(Server server)
Mutes this user on the given server.- Parameters:
server
- The server to mute this user on.- Returns:
- A future to check if the mute was successful.
-
mute
default java.util.concurrent.CompletableFuture<java.lang.Void> mute(Server server, java.lang.String reason)
Mutes this user on the given server.- Parameters:
server
- The server to mute this user on.reason
- The audit log reason for this action.- Returns:
- A future to check if the mute was successful.
-
unmute
default java.util.concurrent.CompletableFuture<java.lang.Void> unmute(Server server)
Unmutes this user on the given server.- Parameters:
server
- The server to unmute this user on.- Returns:
- A future to check if the unmute was successful.
-
unmute
default java.util.concurrent.CompletableFuture<java.lang.Void> unmute(Server server, java.lang.String reason)
Unmutes this user on the given server.- Parameters:
server
- The server to unmute 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 java.util.concurrent.CompletableFuture<java.lang.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 java.util.concurrent.CompletableFuture<java.lang.Void> deafen(Server server, java.lang.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 java.util.concurrent.CompletableFuture<java.lang.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 java.util.concurrent.CompletableFuture<java.lang.Void> undeafen(Server server, java.lang.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
java.util.Optional<java.time.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
java.util.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
java.util.Optional<java.awt.Color> getRoleColor(Server server)
Gets the displayed color of the user based on their 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
java.util.Optional<PrivateChannel> getPrivateChannel()
Gets the private channel with the user. This will only be present, if there was a 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
java.util.concurrent.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.
-
addRole
default java.util.concurrent.CompletableFuture<java.lang.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
ServerUpdater
fromServer.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 java.util.concurrent.CompletableFuture<java.lang.Void> addRole(Role role, java.lang.String reason)
Adds the given role to the user.If you want to update several settings at once, it's recommended to use the
ServerUpdater
fromServer.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 java.util.concurrent.CompletableFuture<java.lang.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
ServerUpdater
fromServer.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 java.util.concurrent.CompletableFuture<java.lang.Void> removeRole(Role role, java.lang.String reason)
Removes the given role from the user.If you want to update several settings at once, it's recommended to use the
ServerUpdater
fromServer.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 java.util.Optional<User> getCurrentCachedInstance()
Description copied from interface:UpdatableFromCache
Gets 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
Optional
if the entity is not cached any longer, for example because it was deleted or the message was thrown out of the cache.- Specified by:
getCurrentCachedInstance
in interfaceUpdatableFromCache<User>
- Returns:
- The current cached instance.
-
getLatestInstance
default java.util.concurrent.CompletableFuture<User> getLatestInstance()
Description copied from interface:Updatable
Gets 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
CompletableFuture
completes exceptionally with aNoSuchElementException
. If a request to Discord is made, the according remote call exception will be used to complete theCompletableFuture
exceptionally.- Specified by:
getLatestInstance
in interfaceUpdatable<User>
- Specified by:
getLatestInstance
in interfaceUpdatableFromCache<User>
- Returns:
- The current cached instance.
-
-