Class JDOA2Impl

java.lang.Object
com.github.natanbc.reliqua.Reliqua
com.mrivanplays.jdoa2.internal.JDOA2Impl
All Implemented Interfaces:
JDOA2

public class JDOA2Impl extends com.github.natanbc.reliqua.Reliqua implements JDOA2
  • Constructor Details

  • Method Details

    • doTokenExchange

      @Nonnull public DiscordToken doTokenExchange()
      Description copied from interface: JDOA2
      Starts a OAuth2 token exchange process. You may want to call this right after you receive a instance of this class in order for the application to interact with discord api to provide you information.

      WARNING: This is a thread blocking method, it may block the thread if the application is rate limited by discord api. CONSIDER RUNNING ASYNCHRONOUSLY!!!!

      Specified by:
      doTokenExchange in interface JDOA2
      Returns:
      token object
      See Also:
    • doTokenExchangeUsingRefreshToken

      @Nonnull public DiscordToken doTokenExchangeUsingRefreshToken()
      Description copied from interface: JDOA2
      Refreshes an existing OAuth2 token, or if none found, calls JDOA2.doTokenExchange(). You may want to call this hand in hand with JDOA2.isCurrentTokenValid() in order for the wrapper to have a working access token.

      WARNING: This is a thread blocking method, it may block the thread if the application is rate limited by discord api. CONSIDER RUNNING ASYNCHRONOUSLY!!!!

      Specified by:
      doTokenExchangeUsingRefreshToken in interface JDOA2
      Returns:
      token object
      See Also:
    • getCurrentToken

      public Optional<DiscordToken> getCurrentToken()
      Description copied from interface: JDOA2
      Returns the token this JDOA2 instance has last cached.
      Specified by:
      getCurrentToken in interface JDOA2
      Returns:
      last token
    • isCurrentTokenValid

      public boolean isCurrentTokenValid()
      Description copied from interface: JDOA2
      Returns whenever the token we have is valid or not. You may want to check this every time before using any of the information receiver methods, and if the token isn't valid you may want to call JDOA2.doTokenExchangeUsingRefreshToken().
      Specified by:
      isCurrentTokenValid in interface JDOA2
      Returns:
      true if valid, false otherwise
    • getCurrentUser

      public com.github.natanbc.reliqua.request.PendingRequest<CurrentUser> getCurrentUser()
      Description copied from interface: JDOA2
      Retrieves CurrentUser information, returning PendingRequest.

      Caching is recommended in order to not hit discord's rate limits. Due to the nature of the api, we currently cannot apply caching.

      Specified by:
      getCurrentUser in interface JDOA2
      Returns:
      pending request, containing current user information
      See Also:
    • getCurrentUserGuilds

      public com.github.natanbc.reliqua.request.PendingRequest<List<Guild>> getCurrentUserGuilds()
      Description copied from interface: JDOA2
      Retrieves a List of Guilds, which the CurrentUser has joined in, returning PendingRequest. Requires "guilds" scope.

      Caching is recommended in order to not hit discord's rate limits. Due to the nature of the api, we currently cannot apply caching.

      Specified by:
      getCurrentUserGuilds in interface JDOA2
      Returns:
      pending request, containing guilds information
      See Also:
    • getHttpClient

      @Nonnull public okhttp3.OkHttpClient getHttpClient()
      Description copied from interface: JDOA2
      Returns the OkHttpClient, used to handle requests.
      Specified by:
      getHttpClient in interface JDOA2
      Returns:
      http client
    • getJsonMapper

      @Nonnull public com.fasterxml.jackson.databind.ObjectMapper getJsonMapper()
      Description copied from interface: JDOA2
      Returns the ObjectMapper, used to read json from discord api responses.
      Specified by:
      getJsonMapper in interface JDOA2
      Returns:
      json mapper
    • getApplicationInfo

      @Nonnull public ApplicationInfo getApplicationInfo()
      Description copied from interface: JDOA2
      Returns the ApplicationInfo
      Specified by:
      getApplicationInfo in interface JDOA2
      Returns:
      application info
      See Also: