Interface User

    • Method Detail

      • getMentionTag

        default String getMentionTag​()
        Description copied from interface: Mentionable
        Gets the tag used to mention the entity.
        Specified by:
        getMentionTag in interface Mentionable
        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 returns false if logged in to a user account.
        Returns:
        Whether this user is the owner of the current account.
      • getActivity

        Optional<Activity> getActivity​()
        Gets the activity of the user.
        Returns:
        The activity 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.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()
      • 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

        default Collection<Server> getMutualServers​()
        Gets all mutual servers with this user.
        Returns:
        All mutual servers with this user.
      • getDisplayName

        default 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 ServerUpdater from Server.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 ServerUpdater from Server.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 ServerUpdater from Server.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 ServerUpdater from Server.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

        default 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

        default 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

        default 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

        default 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

        default 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

        default 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, using openPrivateChannel().
        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.
      • getCurrentCachedInstance

        default 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 interface UpdatableFromCache<User>
        Returns:
        The current cached instance.
      • getLatestInstance

        default 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 a NoSuchElementException. If a request to Discord is made, the according remote call exception will be used to complete the CompletableFuture exceptionally.

        Specified by:
        getLatestInstance in interface Updatable<User>
        Specified by:
        getLatestInstance in interface UpdatableFromCache<User>
        Returns:
        The current cached instance.