Class User

    • Constructor Detail

      • User

        public User​(GatewayDiscordClient gateway,
                    discord4j.discordjson.json.UserData data)
        Constructs an User with an associated GatewayDiscordClient and Discord data.
        Parameters:
        gateway - The GatewayDiscordClient associated to this object, must be non-null.
        data - The raw data as represented by Discord, must be non-null.
    • Method Detail

      • getUserData

        public discord4j.discordjson.json.UserData getUserData()
        Gets the data of the user.
        Returns:
        The data of the user.
      • getUsername

        public final String getUsername()
        Gets the user's username, not unique across the platform.
        Returns:
        The user's username, not unique across the platform.
      • getDiscriminator

        public final String getDiscriminator()
        Gets the user's 4-digit discriminator The discriminator is unique number to distinct one among all users with the same username. The discriminator is randomly generated, but can be changed if the user has a nitro subscription.
        Returns:
        The user's 4-digit discriminator.
      • getTag

        public final String getTag()
        Gets the user's username and discriminator separated by a # This is unique across the discord platform, but may change.
        Returns:
        getUsername()#getDiscriminator()
      • hasAnimatedAvatar

        public final boolean hasAnimatedAvatar()
        Gets if the user's avatar is animated.
        Returns:
        true if the user's avatar is animated, false otherwise.
      • getAvatarUrl

        public final Optional<String> getAvatarUrl​(Image.Format format)
        Gets the user's avatar URL, if present.
        Parameters:
        format - The format for the URL.
        Returns:
        The user's avatar URL, if present.
      • getAvatarUrl

        public final String getAvatarUrl()
        Gets the user's effective avatar URL.
        Returns:
        The user's effective avatar URL.
      • getAvatar

        public Mono<Image> getAvatar​(Image.Format format)
        Gets the user's avatar. This is the avatar at the url given by getAvatarUrl(Image.Format).
        Returns:
        A Mono where, upon successful completion, emits the avatar of the user. If an error is received, it is emitted through the Mono.
      • getAvatar

        public final Mono<Image> getAvatar()
        Gets the user's effective avatar. This is the avatar at the url given by getAvatarUrl().
        Returns:
        A Mono where, upon successful completion, emits the avatar of the user. If an error is received, it is emitted through the Mono.
      • getDefaultAvatarUrl

        public final String getDefaultAvatarUrl()
        Gets the default avatar URL for this user.
        Returns:
        The default avatar URL for this user.
      • hasAnimatedBanner

        public final boolean hasAnimatedBanner()
        Gets if the user's banner is animated.
        Returns:
        true if the user's banner is animated, false otherwise.
      • getBannerUrl

        public final Optional<String> getBannerUrl​(Image.Format format)
        Gets the user's banner URL, if present.
        Parameters:
        format - The format for the URL.
        Returns:
        The user's banner URL, if present.
      • getBannerUrl

        public final Optional<String> getBannerUrl()
        Gets the user's effective banner URL.
        Returns:
        The user's effective banner URL.
      • getBanner

        public Mono<Image> getBanner​(Image.Format format)
        Gets the user's banner. This is the banner at the url given by getBannerUrl(Image.Format).
        Returns:
        A Mono where, upon successful completion, emits the banner of the user. If an error is received, it is emitted through the Mono.
      • getBanner

        public final Mono<Image> getBanner()
        Gets the user's effective banner. This is the banner at the url given by getBannerUrl().
        Returns:
        A Mono where, upon successful completion, emits the banner of the user. If an error is received, it is emitted through the Mono.
      • getAccentColor

        public final Optional<Color> getAccentColor()
        Gets the user's banner accent color, if present.
        Returns:
        The user's banner accent color, if present.
      • isBot

        public boolean isBot()
        Gets whether the user is a bot.
        Returns:
        true if this user is a bot, false otherwise.
      • getMention

        public final String getMention()
        Gets the raw mention. This is the format utilized to directly mention another user (assuming the user exists in context of the mention).
        Returns:
        The raw mention.
      • getId

        public final Snowflake getId()
        Description copied from interface: Entity
        Gets the Snowflake that uniquely identifies this entity.
        Specified by:
        getId in interface Entity
        Returns:
        The Snowflake that uniquely identifies this entity.
      • asMember

        public Mono<Member> asMember​(Snowflake guildId)
        Requests to retrieve this user as a Member.
        Parameters:
        guildId - The ID of the guild to associate this user as a Member.
        Returns:
        A Mono where, upon successful completion, emits this user as a member. If an error is received, it is emitted through the Mono.
      • asMember

        public Mono<Member> asMember​(Snowflake guildId,
                                     EntityRetrievalStrategy retrievalStrategy)
        Requests to retrieve this user as a Member, using the given retrieval strategy.
        Parameters:
        guildId - The ID of the guild to associate this user as a Member.
        retrievalStrategy - the strategy to use to get the member
        Returns:
        A Mono where, upon successful completion, emits this user as a member. If an error is received, it is emitted through the Mono.
      • getPrivateChannel

        public final Mono<PrivateChannel> getPrivateChannel()
        Requests to retrieve the private channel (DM) to this user.
        Returns:
        A Mono where, upon successful completion, emits the private channel to this user. If an error is received, it is emitted through the Mono.
      • getPublicFlags

        public EnumSet<User.Flag> getPublicFlags()
        Returns the public flags of this User, describing its features.
        Returns:
        A EnumSet with the public flags of this user.
      • hashCode

        public final int hashCode()
        Overrides:
        hashCode in class Object