Package net.dv8tion.jda.api.entities
Interface User
- 
- All Superinterfaces:
- java.util.Formattable,- IMentionable,- ISnowflake
 - All Known Subinterfaces:
- SelfUser
 
 public interface User extends IMentionable Represents a Discord User. Contains all publicly available information about a specific Discord User.FormattableThis interface extendsFormattableand can be used with aFormattersuch as used byString.format(String, Object...)orPrintStream.printf(String, Object...).This will use IMentionable.getAsMention()rather thanObject.toString()!
 Supported Features:- Alternative
     
 - Uses the Discord Tag (Username#Discriminator) instead (Example:%#s- results ingetName()#getDiscriminator()-> Minn#6688
- Width/Left-Justification
     
 - Ensures the size of a format (Example:%20s- uses at minimum 20 chars;%-10s- uses left-justified padding)
- Precision
     
 - Cuts the content to the specified size (Example:%.20s)
 More information on formatting syntax can be found in the format syntax documentation!
- 
- 
Nested Class SummaryNested Classes Modifier and Type Interface Description static classUser.ProfileRepresents the information contained in aUser's profile.static classUser.UserFlagRepresents the bit offsets used by Discord for public flags
 - 
Field SummaryFields Modifier and Type Field Description static java.lang.StringAVATAR_URLTemplate forgetAvatarUrl().static java.lang.StringBANNER_URLTemplate forUser.Profile.getBannerUrl()static intDEFAULT_ACCENT_COLOR_RAWUsed to keep consistency between color values used in the APIstatic java.lang.StringDEFAULT_AVATAR_URLTemplate forgetDefaultAvatarUrl()static java.util.regex.PatternUSER_TAGCompiled pattern for a Discord Tag:(.{2,32})#(\d{4})
 - 
Method SummaryAll Methods Static Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description static UserfromId(long id)Creates a User instance which only wraps an ID.static UserfromId(java.lang.String id)Creates a User instance which only wraps an ID.java.lang.StringgetAsTag()The "tag" for this userjava.lang.StringgetAvatarId()The Discord Id for this user's avatar image.default java.lang.StringgetAvatarUrl()The URL for the user's avatar image.java.lang.StringgetDefaultAvatarId()The Discord Id for this user's default avatar image.default java.lang.StringgetDefaultAvatarUrl()The URL for the for the user's default avatar image.java.lang.StringgetDiscriminator()
 The discriminator of theUser.default java.lang.StringgetEffectiveAvatarUrl()The URL for the user's avatar image.java.util.EnumSet<User.UserFlag>getFlags()Returns theUserFlagsof this user.intgetFlagsRaw()Returns the bitmask representation of theUserFlagsof this user.JDAgetJDA()Returns theJDAinstance of this Userjava.util.List<Guild>getMutualGuilds()java.lang.StringgetName()The username of theUser.booleanhasPrivateChannel()Whether or not the currently logged in user and this user have a currently openPrivateChannelor not.booleanisBot()Returns whether or not the given user is a Bot-Account (special badge in client, some different behaviour)booleanisSystem()Returns whether or not the given user is a System account, which includes the urgent message account and the community updates bot.RestAction<PrivateChannel>openPrivateChannel()Opens aPrivateChannelwith this User.RestAction<User.Profile>retrieveProfile()Loads the user'sUser.Profiledata.- 
Methods inherited from interface net.dv8tion.jda.api.entities.IMentionableformatTo, getAsMention
 - 
Methods inherited from interface net.dv8tion.jda.api.entities.ISnowflakegetId, getIdLong, getTimeCreated
 
- 
 
- 
- 
- 
Field Detail- 
USER_TAGstatic final java.util.regex.Pattern USER_TAG Compiled pattern for a Discord Tag:(.{2,32})#(\d{4})
 - 
AVATAR_URLstatic final java.lang.String AVATAR_URL Template forgetAvatarUrl().- See Also:
- Constant Field Values
 
 - 
DEFAULT_AVATAR_URLstatic final java.lang.String DEFAULT_AVATAR_URL Template forgetDefaultAvatarUrl()- See Also:
- Constant Field Values
 
 - 
BANNER_URLstatic final java.lang.String BANNER_URL Template forUser.Profile.getBannerUrl()- See Also:
- Constant Field Values
 
 - 
DEFAULT_ACCENT_COLOR_RAWstatic final int DEFAULT_ACCENT_COLOR_RAW Used to keep consistency between color values used in the API- See Also:
- Constant Field Values
 
 
- 
 - 
Method Detail- 
fromId@Nonnull static User fromId(long id) Creates a User instance which only wraps an ID.
 All other methods besideISnowflake.getIdLong()andISnowflake.getId()will throwUnsupportedOperationException.- Parameters:
- id- The user id
- Returns:
- A user instance
- Since:
- 4.2.1
- See Also:
- JDA.retrieveUserById(long)
 
 - 
fromId@Nonnull static User fromId(@Nonnull java.lang.String id) Creates a User instance which only wraps an ID.
 All other methods besideISnowflake.getIdLong()andISnowflake.getId()will throwUnsupportedOperationException.- Parameters:
- id- The user id
- Returns:
- A user instance
- Throws:
- java.lang.IllegalArgumentException- If the provided ID is not a valid snowflake
- Since:
- 4.2.1
- See Also:
- JDA.retrieveUserById(String)
 
 - 
getName@Nonnull java.lang.String getName() The username of theUser. Length is between 2 and 32 characters (inclusive).- Returns:
- Never-null String containing the User's username.
- Throws:
- java.lang.UnsupportedOperationException- If this User was created with- fromId(long)
 
 - 
getDiscriminator@Nonnull java.lang.String getDiscriminator() 
 The discriminator of theUser. Used to differentiate between users with the same usernames.
 This only contains the 4 digits after the username and the #.- Returns:
- Never-null String containing the Userdiscriminator.
- Throws:
- java.lang.UnsupportedOperationException- If this User was created with- fromId(long)Ex: 6297
 
 - 
getAvatarId@Nullable java.lang.String getAvatarId() The Discord Id for this user's avatar image. If the user has not set an image, this will return null.- Returns:
- Possibly-null String containing the Useravatar id.
- Throws:
- java.lang.UnsupportedOperationException- If this User was created with- fromId(long)
 
 - 
getAvatarUrl@Nullable default java.lang.String getAvatarUrl() The URL for the user's avatar image. If the user has not set an image, this will return null.- Returns:
- Possibly-null String containing the Useravatar url.
- Throws:
- java.lang.UnsupportedOperationException- If this User was created with- fromId(long)
 
 - 
getDefaultAvatarId@Nonnull java.lang.String getDefaultAvatarId() The Discord Id for this user's default avatar image.- Returns:
- Never-null String containing the Userdefault avatar id.
- Throws:
- java.lang.UnsupportedOperationException- If this User was created with- fromId(long)
 
 - 
getDefaultAvatarUrl@Nonnull default java.lang.String getDefaultAvatarUrl() The URL for the for the user's default avatar image.- Returns:
- Never-null String containing the Userdefault avatar url.
- Throws:
- java.lang.UnsupportedOperationException- If this User was created with- fromId(long)
 
 - 
getEffectiveAvatarUrl@Nonnull default java.lang.String getEffectiveAvatarUrl() The URL for the user's avatar image. If they do not have an avatar set, this will return the URL of their default avatar- Returns:
- Never-null String containing the Usereffective avatar url.
- Throws:
- java.lang.UnsupportedOperationException- If this User was created with- fromId(long)
 
 - 
retrieveProfile@Nonnull @CheckReturnValue RestAction<User.Profile> retrieveProfile() Loads the user'sUser.Profiledata. Returns a completed RestAction if this User has been retrieved usingJDA.retrieveUserById(long).- Returns:
- RestAction- Type:- User.Profile
- Throws:
- java.lang.UnsupportedOperationException- If this User was created with- fromId(long)
- Since:
- 4.3.0
 
 - 
getAsTag@Nonnull java.lang.String getAsTag() The "tag" for this userThis is the equivalent of calling String.format("%#s", user)- Returns:
- Never-null String containing the tag for this user, for example DV8FromTheWorld#6297
- Throws:
- java.lang.UnsupportedOperationException- If this User was created with- fromId(long)
 
 - 
hasPrivateChannelboolean hasPrivateChannel() Whether or not the currently logged in user and this user have a currently openPrivateChannelor not.- Returns:
- True if the logged in account shares a PrivateChannel with this user.
- Throws:
- java.lang.UnsupportedOperationException- If this User was created with- fromId(long)
 
 - 
openPrivateChannel@Nonnull @CheckReturnValue RestAction<PrivateChannel> openPrivateChannel() Opens aPrivateChannelwith 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.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) }- Returns:
- RestAction- Type:- PrivateChannel
 Retrieves the PrivateChannel to use to directly message this User.
- Throws:
- java.lang.UnsupportedOperationException- If the recipient User is the currently logged in account (represented by- SelfUser) or if the user was created with- fromId(long)
- See Also:
- JDA.openPrivateChannelById(long)
 
 - 
getMutualGuilds@Nonnull java.util.List<Guild> getMutualGuilds() Finds and collects allGuildinstances that contain thisUserwithin the currentJDAinstance.
 This method is a shortcut for JDA.getMutualGuilds(User).- Returns:
- Immutable list of all Guildsthat this user is a member of.
- Throws:
- java.lang.UnsupportedOperationException- If this User was created with- fromId(long)
 
 - 
isBotboolean isBot() Returns whether or not the given user is a Bot-Account (special badge in client, some different behaviour)- Returns:
- If the User's Account is marked as Bot
- Throws:
- java.lang.UnsupportedOperationException- If this User was created with- fromId(long)
 
 - 
isSystemboolean isSystem() Returns whether or not the given user is a System account, which includes the urgent message account and the community updates bot.- Returns:
- Whether the User's account is marked as System
- Throws:
- java.lang.UnsupportedOperationException- If this User was created with- fromId(long)
 
 - 
getJDA@Nonnull JDA getJDA() Returns theJDAinstance of this User- Returns:
- the corresponding JDA instance
- Throws:
- java.lang.UnsupportedOperationException- If this User was created with- fromId(long)
 
 - 
getFlags@Nonnull java.util.EnumSet<User.UserFlag> getFlags() Returns theUserFlagsof this user.- Returns:
- EnumSet containing the flags of the user.
- Throws:
- java.lang.UnsupportedOperationException- If this User was created with- fromId(long)
 
 - 
getFlagsRawint getFlagsRaw() Returns the bitmask representation of theUserFlagsof this user.- Returns:
- bitmask representation of the user's flags.
- Throws:
- java.lang.UnsupportedOperationException- If this User was created with- fromId(long)
 
 
- 
 
-