Interface OAuth2User
- All Superinterfaces:
Formattable,net.dv8tion.jda.api.entities.IMentionable,net.dv8tion.jda.api.entities.ISnowflake
- All Known Implementing Classes:
OAuth2UserImpl
public interface OAuth2User
extends net.dv8tion.jda.api.entities.ISnowflake, net.dv8tion.jda.api.entities.IMentionable
OAuth2 representation of a Discord User.
More specifically, this is the User that the session is currently managing when retrieved using
More specifically, this is the User that the session is currently managing when retrieved using
OAuth2Client#getUser.- Author:
- John Grosh ([email protected]), Kaidan Gustave
-
Method Summary
Modifier and TypeMethodDescriptionGets the user as a discord formatted mention:<@SNOWFLAKE_ID>Gets the user's avatar ID, ornullif they have not set one.Gets the user's avatar URL, ornullif they have not set one.Gets the underlyingOAuth2Clientthat created this OAuth2User.Gets the user's avatar URL.Gets the user's default avatar ID.Gets the user's discriminator.Gets the user's avatar URL, or theirdefault avatar URLif they do not have a custom avatar set on their account.getEmail()Gets the user's email address that is associated with their Discord account.getId()Gets the user's Snowflake ID as a String.longGets the user's Snowflake ID as along.net.dv8tion.jda.api.entities.UsergetJDAUser(net.dv8tion.jda.api.JDA jda) Gets the correspondingJDA Userfrom the provided instance ofJDA.net.dv8tion.jda.api.entities.UsergetJDAUser(net.dv8tion.jda.api.sharding.ShardManager shardManager) Gets the correspondingJDA Userfrom the providedShardManager.getName()Gets the user's account name.Gets the originatingSessionthat is responsible for this OAuth2User.default booleanisBot()Deprecated.Due to the nature of OAuth2 at this moment, bots are not allowed to use the various urls provided.booleanReturnstrueif this user has multi-factor authentication enabled.booleanReturnstrueif the user's Discord account has been verified via email.Methods inherited from interface net.dv8tion.jda.api.entities.IMentionable
formatToMethods inherited from interface net.dv8tion.jda.api.entities.ISnowflake
getTimeCreated
-
Method Details
-
getClient
OAuth2Client getClient()Gets the underlyingOAuth2Clientthat created this OAuth2User.- Returns:
- The OAuth2Client that created this OAuth2User.
-
getSession
Session getSession()Gets the originatingSessionthat is responsible for this OAuth2User.- Returns:
- The Session responsible for this OAuth2User.
-
getId
String getId()Gets the user's Snowflake ID as a String.- Specified by:
getIdin interfacenet.dv8tion.jda.api.entities.ISnowflake- Returns:
- The user's Snowflake ID as a String.
-
getIdLong
long getIdLong()Gets the user's Snowflake ID as along.- Specified by:
getIdLongin interfacenet.dv8tion.jda.api.entities.ISnowflake- Returns:
- The user's Snowflake ID as a
long.
-
getName
String getName()Gets the user's account name.- Returns:
- The user's account name.
-
getEmail
String getEmail()Gets the user's email address that is associated with their Discord account.Note that if this user is acquired without the '
email' OAuthScope, this will throw aMissingScopeException.- Returns:
- The user's email.
- Throws:
MissingScopeException- If the correspondingsessiondoes not have the proper 'email' OAuth2 scope
-
isVerified
boolean isVerified()Returnstrueif the user's Discord account has been verified via email.This is required to send messages in guilds where certain moderation levels are used.
- Returns:
trueif the user has verified their account,falseotherwise.
-
isMfaEnabled
boolean isMfaEnabled()Returnstrueif this user has multi-factor authentication enabled.Some guilds require mfa for administrative actions.
- Returns:
trueif the user has mfa enabled,falseotherwise.
-
getDiscriminator
String getDiscriminator()Gets the user's discriminator.- Returns:
- The user's discriminator.
-
getAvatarId
String getAvatarId()Gets the user's avatar ID, ornullif they have not set one.- Returns:
- The user's avatar ID, or
nullif they have not set one.
-
getAvatarUrl
String getAvatarUrl()Gets the user's avatar URL, ornullif they have not set one.- Returns:
- The user's avatar URL, or
nullif they have not set one.
-
getDefaultAvatarId
String getDefaultAvatarId()Gets the user's avatar URL.- Returns:
- The user's avatar URL.
-
getDefaultAvatarUrl
String getDefaultAvatarUrl()Gets the user's default avatar ID.- Returns:
- The user's default avatar ID.
-
getEffectiveAvatarUrl
String getEffectiveAvatarUrl()Gets the user's avatar URL, or theirdefault avatar URLif they do not have a custom avatar set on their account.- Returns:
- The user's effective avatar URL.
-
isBot
Deprecated.Due to the nature of OAuth2 at this moment, bots are not allowed to use the various urls provided.
This method is scheduled for removal upon merging it withmasterin JDA-Utilities 2.2Gets whether or not this user is a bot.While, at the time of writing this documentation, bots cannot authenticate applications, there may be a time in the future where they have such an ability.
- Returns:
false
-
getAsMention
String getAsMention()Gets the user as a discord formatted mention:<@SNOWFLAKE_ID>- Specified by:
getAsMentionin interfacenet.dv8tion.jda.api.entities.IMentionable- Returns:
- A discord formatted mention of this user.
-
getJDAUser
net.dv8tion.jda.api.entities.User getJDAUser(net.dv8tion.jda.api.JDA jda) Gets the correspondingJDA Userfrom the provided instance ofJDA.Note that there is no guarantee that this will not return
nullas the instance of JDA may not have access to the User.For sharded bots, use
getJDAUser(ShardManager).- Parameters:
jda- The instance of JDA to get from.- Returns:
- A JDA User, possibly
null.
-
getJDAUser
net.dv8tion.jda.api.entities.User getJDAUser(net.dv8tion.jda.api.sharding.ShardManager shardManager) Gets the correspondingJDA Userfrom the providedShardManager.Note that there is no guarantee that this will not return
nullas the ShardManager may not have access to the User.For un-sharded bots, use
getJDAUser(JDA).- Parameters:
shardManager- The ShardManager to get from.- Returns:
- A JDA User, possibly
null.
-