Class OAuth2UserImpl

java.lang.Object
com.jagrosh.jdautilities.oauth2.entities.impl.OAuth2UserImpl
All Implemented Interfaces:
OAuth2User, Formattable, net.dv8tion.jda.api.entities.IMentionable, net.dv8tion.jda.api.entities.ISnowflake

public class OAuth2UserImpl extends Object implements OAuth2User
Author:
John Grosh ([email protected])
  • Constructor Details

  • Method Details

    • getClient

      public OAuth2Client getClient()
      Description copied from interface: OAuth2User
      Gets the underlying OAuth2Client that created this OAuth2User.
      Specified by:
      getClient in interface OAuth2User
      Returns:
      The OAuth2Client that created this OAuth2User.
    • getSession

      public Session getSession()
      Description copied from interface: OAuth2User
      Gets the originating Session that is responsible for this OAuth2User.
      Specified by:
      getSession in interface OAuth2User
      Returns:
      The Session responsible for this OAuth2User.
    • getId

      public String getId()
      Description copied from interface: OAuth2User
      Gets the user's Snowflake ID as a String.
      Specified by:
      getId in interface net.dv8tion.jda.api.entities.ISnowflake
      Specified by:
      getId in interface OAuth2User
      Returns:
      The user's Snowflake ID as a String.
    • getIdLong

      public long getIdLong()
      Description copied from interface: OAuth2User
      Gets the user's Snowflake ID as a long.
      Specified by:
      getIdLong in interface net.dv8tion.jda.api.entities.ISnowflake
      Specified by:
      getIdLong in interface OAuth2User
      Returns:
      The user's Snowflake ID as a long.
    • getName

      public String getName()
      Description copied from interface: OAuth2User
      Gets the user's account name.
      Specified by:
      getName in interface OAuth2User
      Returns:
      The user's account name.
    • getEmail

      public String getEmail()
      Description copied from interface: OAuth2User
      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.

      Specified by:
      getEmail in interface OAuth2User
      Returns:
      The user's email.
    • isVerified

      public boolean isVerified()
      Description copied from interface: OAuth2User
      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.

      Specified by:
      isVerified in interface OAuth2User
      Returns:
      true if the user has verified their account, false otherwise.
    • isMfaEnabled

      public boolean isMfaEnabled()
      Description copied from interface: OAuth2User
      Returns true if this user has multi-factor authentication enabled.

      Some guilds require mfa for administrative actions.

      Specified by:
      isMfaEnabled in interface OAuth2User
      Returns:
      true if the user has mfa enabled, false otherwise.
    • getDiscriminator

      public String getDiscriminator()
      Description copied from interface: OAuth2User
      Gets the user's discriminator.
      Specified by:
      getDiscriminator in interface OAuth2User
      Returns:
      The user's discriminator.
    • getAvatarId

      public String getAvatarId()
      Description copied from interface: OAuth2User
      Gets the user's avatar ID, or null if they have not set one.
      Specified by:
      getAvatarId in interface OAuth2User
      Returns:
      The user's avatar ID, or null if they have not set one.
    • getAvatarUrl

      public String getAvatarUrl()
      Description copied from interface: OAuth2User
      Gets the user's avatar URL, or null if they have not set one.
      Specified by:
      getAvatarUrl in interface OAuth2User
      Returns:
      The user's avatar URL, or null if they have not set one.
    • getDefaultAvatarId

      public String getDefaultAvatarId()
      Description copied from interface: OAuth2User
      Gets the user's avatar URL.
      Specified by:
      getDefaultAvatarId in interface OAuth2User
      Returns:
      The user's avatar URL.
    • getDefaultAvatarUrl

      public String getDefaultAvatarUrl()
      Description copied from interface: OAuth2User
      Gets the user's default avatar ID.
      Specified by:
      getDefaultAvatarUrl in interface OAuth2User
      Returns:
      The user's default avatar ID.
    • getEffectiveAvatarUrl

      public String getEffectiveAvatarUrl()
      Description copied from interface: OAuth2User
      Gets the user's avatar URL, or their default avatar URL if they do not have a custom avatar set on their account.
      Specified by:
      getEffectiveAvatarUrl in interface OAuth2User
      Returns:
      The user's effective avatar URL.
    • getAsMention

      public String getAsMention()
      Description copied from interface: OAuth2User
      Gets the user as a discord formatted mention:
      <@SNOWFLAKE_ID>
      Specified by:
      getAsMention in interface net.dv8tion.jda.api.entities.IMentionable
      Specified by:
      getAsMention in interface OAuth2User
      Returns:
      A discord formatted mention of this user.
    • getJDAUser

      public net.dv8tion.jda.api.entities.User getJDAUser(net.dv8tion.jda.api.JDA jda)
      Description copied from interface: OAuth2User
      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 OAuth2User.getJDAUser(ShardManager).

      Specified by:
      getJDAUser in interface OAuth2User
      Parameters:
      jda - The instance of JDA to get from.
      Returns:
      A JDA User, possibly null.
    • getJDAUser

      public net.dv8tion.jda.api.entities.User getJDAUser(net.dv8tion.jda.api.sharding.ShardManager shardManager)
      Description copied from interface: OAuth2User
      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 OAuth2User.getJDAUser(JDA).

      Specified by:
      getJDAUser in interface OAuth2User
      Parameters:
      shardManager - The ShardManager to get from.
      Returns:
      A JDA User, possibly null.
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object