Package discord4j.core.object.entity
Class User
java.lang.Object
discord4j.core.object.entity.User
- All Implemented Interfaces:
DiscordObject
,Entity
- Direct Known Subclasses:
PartialMember
A Discord user.
- See Also:
-
Nested Class Summary
-
Constructor Summary
ConstructorDescriptionUser
(GatewayDiscordClient gateway, discord4j.discordjson.json.UserData data) Constructs anUser
with an associatedGatewayDiscordClient
and Discord data. -
Method Summary
Modifier and TypeMethodDescriptionRequests to retrieve this user as aMember
.asMember
(Snowflake guildId, EntityRetrievalStrategy retrievalStrategy) Requests to retrieve this user as aMember
, using the given retrieval strategy.final boolean
Gets the user's banner accent color, if present.Gets the user's effective avatar.getAvatar
(Image.Format format) Gets the user's avatar.final String
Gets the user's effective avatar URL.getAvatarUrl
(Image.Format format) Gets the user's avatar URL, if present.Gets the user's effective banner.getBanner
(Image.Format format) Gets the user's banner.Gets the user's effective banner URL.getBannerUrl
(Image.Format format) Gets the user's banner URL, if present.final GatewayDiscordClient
Returns theGatewayDiscordClient
that created this object.final String
Gets the default avatar URL for this user.final String
Deprecated.This method will be removed once the system change is complete.Gets the user's global username, not enforced to be unique across the platform.final Snowflake
getId()
Gets the Snowflake that uniquely identifies this entity.final String
Gets the raw mention.final Mono<PrivateChannel>
Requests to retrieve the private channel (DM) to this user.Returns the public flags of thisUser
, describing its features.final String
getTag()
Gets the user's username and discriminator separated by a # or its username if the user is using the new systemdiscord4j.discordjson.json.UserData
Gets the data of the user.final String
Gets the user's username.final boolean
Gets if the user's avatar is animated.final boolean
Gets if the user's banner is animated.final int
hashCode()
boolean
isBot()
Gets whether the user is a bot.toString()
-
Constructor Details
-
User
Constructs anUser
with an associatedGatewayDiscordClient
and Discord data.- Parameters:
gateway
- TheGatewayDiscordClient
associated to this object, must be non-null.data
- The raw data as represented by Discord, must be non-null.
-
-
Method Details
-
getClient
Description copied from interface:DiscordObject
Returns theGatewayDiscordClient
that created this object. Methods in it are exclusively based on the entity cache orStore
in use. Refer to callinggetClient().rest()
to access aDiscordClient
that is capable of requesting entities directly from the REST API.- Specified by:
getClient
in interfaceDiscordObject
- Returns:
- The
GatewayDiscordClient
associated to this object.
-
getUserData
public discord4j.discordjson.json.UserData getUserData()Gets the data of the user.- Returns:
- The data of the user.
-
getGlobalName
Gets the user's global username, not enforced to be unique across the platform. May be empty if the user has not set a global username.- Returns:
- The user's global name
-
getUsername
Gets the user's username. May or may not be unique across the platform (due to the system ongoing change)- Returns:
- The user's username, not unique across the platform.
-
getDiscriminator
Deprecated.This method will be removed once the system change is complete.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. Migrated users from the old system will have a discriminator of "0". May become null after the system change is complete.- Returns:
- The user's 4-digit discriminator, or "0" if the user is migrated to the new system.
-
getTag
Gets the user's username and discriminator separated by a # or its username if the user is using the new system- Returns:
getUsername()
#getDiscriminator()
if the user is not migrated,getUsername()
otherwise.
-
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
Gets the user's avatar URL, if present.- Parameters:
format
- The format for the URL.- Returns:
- The user's avatar URL, if present.
-
getAvatarUrl
Gets the user's effective avatar URL.- Returns:
- The user's effective avatar URL.
-
getAvatar
Gets the user's avatar. This is the avatar at the url given bygetAvatarUrl(Image.Format)
. -
getAvatar
Gets the user's effective avatar. This is the avatar at the url given bygetAvatarUrl()
. -
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
Gets the user's banner URL, if present.- Parameters:
format
- The format for the URL.- Returns:
- The user's banner URL, if present.
-
getBannerUrl
Gets the user's effective banner URL.- Returns:
- The user's effective banner URL.
-
getBanner
Gets the user's banner. This is the banner at the url given bygetBannerUrl(Image.Format)
. -
getBanner
Gets the user's effective banner. This is the banner at the url given bygetBannerUrl()
. -
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
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
Description copied from interface:Entity
Gets the Snowflake that uniquely identifies this entity. -
asMember
Requests to retrieve this user as aMember
. -
asMember
Requests to retrieve this user as aMember
, using the given retrieval strategy. -
getPrivateChannel
Requests to retrieve the private channel (DM) to this user.- Returns:
- A
Mono
where, upon successful completion, emits theprivate channel
to this user. If an error is received, it is emitted through theMono
.
-
getPublicFlags
Returns the public flags of thisUser
, describing its features.- Returns:
- A
EnumSet
with the public flags of this user.
-
equals
-
hashCode
public final int hashCode() -
toString
-