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 OAuth2Client#getUser.
Author:
John Grosh ([email protected]), Kaidan Gustave
  • Method Summary

    Modifier and Type
    Method
    Description
    Gets the user as a discord formatted mention:
    <@SNOWFLAKE_ID>
    Gets the user's avatar ID, or null if they have not set one.
    Gets the user's avatar URL, or null if they have not set one.
    Gets the underlying OAuth2Client 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 their default avatar URL if they do not have a custom avatar set on their account.
    Gets the user's email address that is associated with their Discord account.
    Gets the user's Snowflake ID as a String.
    long
    Gets the user's Snowflake ID as a long.
    net.dv8tion.jda.api.entities.User
    getJDAUser(net.dv8tion.jda.api.JDA jda)
    Gets the corresponding JDA User from the provided instance of JDA.
    net.dv8tion.jda.api.entities.User
    getJDAUser(net.dv8tion.jda.api.sharding.ShardManager shardManager)
    Gets the corresponding JDA User from the provided ShardManager.
    Gets the user's account name.
    Gets the originating Session that is responsible for this OAuth2User.
    default boolean
    Deprecated.
    Due to the nature of OAuth2 at this moment, bots are not allowed to use the various urls provided.
    boolean
    Returns true if this user has multi-factor authentication enabled.
    boolean
    Returns true 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 underlying OAuth2Client that created this OAuth2User.
      Returns:
      The OAuth2Client that created this OAuth2User.
    • getSession

      Session getSession()
      Gets the originating Session 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 interface net.dv8tion.jda.api.entities.ISnowflake
      Returns:
      The user's Snowflake ID as a String.
    • getIdLong

      long getIdLong()
      Gets the user's Snowflake ID as a long.
      Specified by:
      getIdLong in interface net.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' OAuth Scope, this will throw a MissingScopeException.

      Returns:
      The user's email.
      Throws:
      MissingScopeException - If the corresponding session does not have the proper 'email' OAuth2 scope
    • isVerified

      boolean isVerified()
      Returns true 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()
      Returns true 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, or null 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, or null 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 their default avatar URL if they do not have a custom avatar set on their account.
      Returns:
      The user's effective avatar URL.
    • isBot

      @Deprecated default boolean 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 with master in JDA-Utilities 2.2
      Gets 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 interface net.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 corresponding JDA User from the provided instance of JDA.

      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 corresponding JDA User from the provided ShardManager.

      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.