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, ornull
if they have not set one.Gets the user's avatar URL, ornull
if they have not set one.Gets the underlyingOAuth2Client
that 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 URL
if 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.long
Gets the user's Snowflake ID as along
.net.dv8tion.jda.api.entities.User
getJDAUser
(net.dv8tion.jda.api.JDA jda) Gets the correspondingJDA User
from the provided instance ofJDA
.net.dv8tion.jda.api.entities.User
getJDAUser
(net.dv8tion.jda.api.sharding.ShardManager shardManager) Gets the correspondingJDA User
from the providedShardManager
.getName()
Gets the user's account name.Gets the originatingSession
that is responsible for this OAuth2User.default boolean
isBot()
Deprecated.Due to the nature of OAuth2 at this moment, bots are not allowed to use the various urls provided.boolean
Returnstrue
if this user has multi-factor authentication enabled.boolean
Returnstrue
if the user's Discord account has been verified via email.Methods inherited from interface net.dv8tion.jda.api.entities.IMentionable
formatTo
Methods inherited from interface net.dv8tion.jda.api.entities.ISnowflake
getTimeCreated
-
Method Details
-
getClient
OAuth2Client getClient()Gets the underlyingOAuth2Client
that created this OAuth2User.- Returns:
- The OAuth2Client that created this OAuth2User.
-
getSession
Session getSession()Gets the originatingSession
that 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:
getId
in 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:
getIdLong
in 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 correspondingsession
does not have the proper 'email' OAuth2 scope
-
isVerified
boolean isVerified()Returnstrue
if 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:
true
if the user has verified their account,false
otherwise.
-
isMfaEnabled
boolean isMfaEnabled()Returnstrue
if this user has multi-factor authentication enabled.Some guilds require mfa for administrative actions.
- Returns:
true
if the user has mfa enabled,false
otherwise.
-
getDiscriminator
String getDiscriminator()Gets the user's discriminator.- Returns:
- The user's discriminator.
-
getAvatarId
String getAvatarId()Gets the user's avatar ID, ornull
if they have not set one.- Returns:
- The user's avatar ID, or
null
if they have not set one.
-
getAvatarUrl
String getAvatarUrl()Gets the user's avatar URL, ornull
if they have not set one.- Returns:
- The user's avatar URL, or
null
if 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 URL
if 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 withmaster
in 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:
getAsMention
in 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 User
from the provided instance ofJDA
.Note that there is no guarantee that this will not return
null
as 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 User
from the providedShardManager
.Note that there is no guarantee that this will not return
null
as 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
.
-