Package discord4j.core.object.entity
Class User
- java.lang.Object
-
- discord4j.core.object.entity.User
-
- All Implemented Interfaces:
DiscordObject,Entity
- Direct Known Subclasses:
PartialMember
public class User extends Object implements Entity
A Discord user.- See Also:
- Users Resource
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classUser.FlagDescribes the flags of a user.
-
Constructor Summary
Constructors Constructor Description User(GatewayDiscordClient gateway, discord4j.discordjson.json.UserData data)Constructs anUserwith an associatedGatewayDiscordClientand Discord data.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Mono<Member>asMember(Snowflake guildId)Requests to retrieve this user as aMember.Mono<Member>asMember(Snowflake guildId, EntityRetrievalStrategy retrievalStrategy)Requests to retrieve this user as aMember, using the given retrieval strategy.booleanequals(Object obj)Optional<Color>getAccentColor()Gets the user's banner accent color, if present.Mono<Image>getAvatar()Gets the user's effective avatar.Mono<Image>getAvatar(Image.Format format)Gets the user's avatar.StringgetAvatarUrl()Gets the user's effective avatar URL.Optional<String>getAvatarUrl(Image.Format format)Gets the user's avatar URL, if present.Mono<Image>getBanner()Gets the user's effective banner.Mono<Image>getBanner(Image.Format format)Gets the user's banner.Optional<String>getBannerUrl()Gets the user's effective banner URL.Optional<String>getBannerUrl(Image.Format format)Gets the user's banner URL, if present.GatewayDiscordClientgetClient()Returns theGatewayDiscordClientthat created this object.StringgetDefaultAvatarUrl()Gets the default avatar URL for this user.StringgetDiscriminator()Gets the user's 4-digit discriminator The discriminator is unique number to distinct one among all users with the same username.SnowflakegetId()Gets the Snowflake that uniquely identifies this entity.StringgetMention()Gets the raw mention.Mono<PrivateChannel>getPrivateChannel()Requests to retrieve the private channel (DM) to this user.EnumSet<User.Flag>getPublicFlags()Returns the public flags of thisUser, describing its features.StringgetTag()Gets the user's username and discriminator separated by a # This is unique across the discord platform, but may change.discord4j.discordjson.json.UserDatagetUserData()Gets the data of the user.StringgetUsername()Gets the user's username, not unique across the platform.booleanhasAnimatedAvatar()Gets if the user's avatar is animated.booleanhasAnimatedBanner()Gets if the user's banner is animated.inthashCode()booleanisBot()Gets whether the user is a bot.StringtoString()
-
-
-
Constructor Detail
-
User
public User(GatewayDiscordClient gateway, discord4j.discordjson.json.UserData data)
Constructs anUserwith an associatedGatewayDiscordClientand Discord data.- Parameters:
gateway- TheGatewayDiscordClientassociated to this object, must be non-null.data- The raw data as represented by Discord, must be non-null.
-
-
Method Detail
-
getClient
public final GatewayDiscordClient getClient()
Description copied from interface:DiscordObjectReturns theGatewayDiscordClientthat created this object. Methods in it are exclusively based on the entity cache orStorein use. Refer to callinggetClient().rest()to access aDiscordClientthat is capable of requesting entities directly from the REST API.- Specified by:
getClientin interfaceDiscordObject- Returns:
- The
GatewayDiscordClientassociated to this object.
-
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:
trueif the user's avatar is animated,falseotherwise.
-
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 bygetAvatarUrl(Image.Format).
-
getAvatar
public final Mono<Image> getAvatar()
Gets the user's effective avatar. This is the avatar at the url given bygetAvatarUrl().
-
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:
trueif the user's banner is animated,falseotherwise.
-
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 bygetBannerUrl(Image.Format).
-
getBanner
public final Mono<Image> getBanner()
Gets the user's effective banner. This is the banner at the url given bygetBannerUrl().
-
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:
trueif this user is a bot,falseotherwise.
-
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:EntityGets the Snowflake that uniquely identifies this entity.
-
asMember
public Mono<Member> asMember(Snowflake guildId)
Requests to retrieve this user as aMember.
-
asMember
public Mono<Member> asMember(Snowflake guildId, EntityRetrievalStrategy retrievalStrategy)
Requests to retrieve this user as aMember, using the given retrieval strategy.
-
getPrivateChannel
public final Mono<PrivateChannel> getPrivateChannel()
Requests to retrieve the private channel (DM) to this user.- Returns:
- A
Monowhere, upon successful completion, emits theprivate channelto this user. If an error is received, it is emitted through theMono.
-
getPublicFlags
public EnumSet<User.Flag> getPublicFlags()
Returns the public flags of thisUser, describing its features.- Returns:
- A
EnumSetwith the public flags of this user.
-
-