Class UserImpl
java.lang.Object
net.dv8tion.jda.internal.entities.UserSnowflakeImpl
net.dv8tion.jda.internal.entities.UserImpl
- All Implemented Interfaces:
Formattable
,IMentionable
,ISnowflake
,User
,UserSnowflake
- Direct Known Subclasses:
SelfUserImpl
-
Nested Class Summary
Nested classes/interfaces inherited from interface net.dv8tion.jda.api.entities.User
User.Profile, User.UserFlag
-
Field Summary
Fields inherited from interface net.dv8tion.jda.api.entities.User
AVATAR_URL, BANNER_URL, DEFAULT_ACCENT_COLOR_RAW, DEFAULT_AVATAR_URL, USER_TAG
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
getAsTag()
The "tag" for this userThe Discord ID for this user's avatar image.The Discord ID for this user's default avatar image.The discriminator of theUser
.short
getFlags()
Returns theUserFlags
of this user.int
Returns the bitmask representation of theUserFlags
of this user.The global display name of the user.getJDA()
Returns theJDA
instance of this UsergetName()
The username of theUser
.boolean
Whether or not the currently logged in user and this user have a currently openPrivateChannel
or not.boolean
isBot()
Returns whether or not the given user is a Bot-Account (special badge in client, some different behaviour)boolean
isSystem()
Returns whether or not the given user is a System account, which includes the urgent message account and the community updates bot.Opens aPrivateChannel
with this User.Loads the user'sUser.Profile
data.setAvatarId
(String avatarId) setBot
(boolean bot) setDiscriminator
(short discriminator) setFlags
(int flags) setGlobalName
(String globalName) setPrivateChannel
(PrivateChannel privateChannel) setProfile
(User.Profile profile) setSystem
(boolean system) toString()
Methods inherited from class net.dv8tion.jda.internal.entities.UserSnowflakeImpl
equals, getAsMention, getIdLong, hashCode
Methods inherited from interface net.dv8tion.jda.api.entities.IMentionable
getAsMention
Methods inherited from interface net.dv8tion.jda.api.entities.ISnowflake
getId, getIdLong, getTimeCreated
Methods inherited from interface net.dv8tion.jda.api.entities.User
getAvatar, getAvatarUrl, getEffectiveAvatar, getEffectiveAvatarUrl, getEffectiveName
Methods inherited from interface net.dv8tion.jda.api.entities.UserSnowflake
getDefaultAvatar, getDefaultAvatarUrl
-
Constructor Details
-
UserImpl
-
-
Method Details
-
getName
Description copied from interface:User
The username of theUser
. Length is between 2 and 32 characters (inclusive). -
getGlobalName
Description copied from interface:User
The global display name of the user.
This name is not unique and allows more characters.This name is usually displayed in the UI.
- Specified by:
getGlobalName
in interfaceUser
- Returns:
- The global display name or null if unset.
-
getDiscriminator
Description copied from interface:User
The discriminator of theUser
. Used to differentiate between users with the same usernames.
This only contains the 4 digits after the username and the #.For most users, no discriminator is used and this will be
"0000"
instead. The primary use-case for discriminators is bot and guest accounts, to prevent name squatting.- Specified by:
getDiscriminator
in interfaceUser
- Returns:
- Never-null String containing the
User
discriminator.
-
getAvatarId
Description copied from interface:User
The Discord ID for this user's avatar image. If the user has not set an image, this will return null.- Specified by:
getAvatarId
in interfaceUser
- Returns:
- Possibly-null String containing the
User
avatar id.
-
retrieveProfile
Description copied from interface:User
Loads the user'sUser.Profile
data. Returns a completed RestAction if this User has been retrieved usingJDA.retrieveUserById(long)
. You can useuseCache(false)
to force the request for a new profile with up-to-date information.- Specified by:
retrieveProfile
in interfaceUser
- Returns:
CacheRestAction
- Type:User.Profile
-
getProfile
-
getDefaultAvatarId
Description copied from interface:UserSnowflake
The Discord ID for this user's default avatar image.- Specified by:
getDefaultAvatarId
in interfaceUserSnowflake
- Overrides:
getDefaultAvatarId
in classUserSnowflakeImpl
- Returns:
- Never-null String containing the user's default avatar id.
-
getAsTag
Description copied from interface:User
The "tag" for this userThis is the equivalent of calling
String.format
("%#s", user)Users without a discriminator use
#0000
instead. -
hasPrivateChannel
public boolean hasPrivateChannel()Description copied from interface:User
Whether or not the currently logged in user and this user have a currently openPrivateChannel
or not.- Specified by:
hasPrivateChannel
in interfaceUser
- Returns:
- True if the logged in account shares a PrivateChannel with this user.
-
openPrivateChannel
Description copied from interface:User
Opens aPrivateChannel
with this User.
If a channel has already been opened with this user, it is immediately returned in the RestAction's success consumer without contacting the Discord API. You can useuseCache(false)
to force the request for a new channel object, which is rarely useful since the channel id never changes.Examples
// Send message without response handling public void sendMessage(User user, String content) { user.openPrivateChannel() .flatMap(channel -> channel.sendMessage(content)) .queue(); } // Send message and delete 30 seconds later public RestAction<Void> sendSecretMessage(User user, String content) { return user.openPrivateChannel() // RestAction<PrivateChannel> .flatMap(channel -> channel.sendMessage(content)) // RestAction<Message> .delay(30, TimeUnit.SECONDS) // RestAction<Message> with delayed response .flatMap(Message::delete); // RestAction<Void> (executed 30 seconds after sending) }
- Specified by:
openPrivateChannel
in interfaceUser
- Returns:
CacheRestAction
- Type:PrivateChannel
Retrieves the PrivateChannel to use to directly message this User.- See Also:
-
getPrivateChannel
-
getMutualGuilds
Description copied from interface:User
Finds and collects allGuild
instances that contain thisUser
within the currentJDA
instance.
This method is a shortcut for
JDA.getMutualGuilds(User)
.- Specified by:
getMutualGuilds
in interfaceUser
- Returns:
- Immutable list of all
Guilds
that this user is a member of.
-
isBot
public boolean isBot()Description copied from interface:User
Returns whether or not the given user is a Bot-Account (special badge in client, some different behaviour) -
isSystem
public boolean isSystem()Description copied from interface:User
Returns whether or not the given user is a System account, which includes the urgent message account and the community updates bot. -
getJDA
Description copied from interface:User
Returns theJDA
instance of this User -
getFlags
Description copied from interface:User
Returns theUserFlags
of this user. -
getFlagsRaw
public int getFlagsRaw()Description copied from interface:User
Returns the bitmask representation of theUserFlags
of this user.- Specified by:
getFlagsRaw
in interfaceUser
- Returns:
- bitmask representation of the user's flags.
-
toString
- Overrides:
toString
in classUserSnowflakeImpl
-
setName
-
setGlobalName
-
setDiscriminator
-
setAvatarId
-
setProfile
-
setPrivateChannel
-
setBot
-
setSystem
-
setFlags
-
getDiscriminatorInt
public short getDiscriminatorInt() -
formatTo
- Specified by:
formatTo
in interfaceFormattable
- Specified by:
formatTo
in interfaceIMentionable
-