Interface JDOA2

  • All Known Implementing Classes:
    JDOA2Impl

    public interface JDOA2
    Represents the driver of the all components.

    JDOA2 stands for Java Discord OAuth2, representing a discord api wrapper of OAuth2 applications for interacting with user data.

    • Method Detail

      • doTokenExchange

        @Nonnull
        DiscordToken doTokenExchange()
        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!!!!

        Returns:
        token object
        See Also:
        DiscordToken
      • doTokenExchangeUsingRefreshToken

        @Nonnull
        DiscordToken doTokenExchangeUsingRefreshToken()
        Refreshes an existing OAuth2 token, or if none found, calls doTokenExchange(). You may want to call this hand in hand with 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!!!!

        Returns:
        token object
        See Also:
        DiscordToken
      • getCurrentToken

        Optional<DiscordToken> getCurrentToken()
        Returns the token this JDOA2 instance has last cached.
        Returns:
        last token
      • isCurrentTokenValid

        boolean isCurrentTokenValid()
        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 doTokenExchangeUsingRefreshToken().
        Returns:
        true if valid, false otherwise
      • getCurrentUser

        @CheckReturnValue
        com.github.natanbc.reliqua.request.PendingRequest<CurrentUser> getCurrentUser()
        Retrieves CurrentUser information, returning PendingRequest.
        Returns:
        pending request, containing current user information
        See Also:
        PendingRequest, CurrentUser
      • getUserAvatarUrl

        @Nonnull
        default String getUserAvatarUrl​(@Nonnull
                                        CurrentUser user)
        Returns the icon url of the CurrentUser specified. Note that every avatar method in CurrentUser returns an icon hash, and not an url.
        Parameters:
        user - current user
        Returns:
        icon url
      • getGuildIconUrl

        @Nullable
        default String getGuildIconUrl​(@Nonnull
                                       Guild guild)
        Returns the icon url of the guild specified. Note that Guild.getIcon() returns an icon hash, not an url.
        Parameters:
        guild - guild
        Returns:
        icon url
      • getCurrentUserGuilds

        @CheckReturnValue
        com.github.natanbc.reliqua.request.PendingRequest<List<Guild>> getCurrentUserGuilds()
        Retrieves a List of Guilds, which the CurrentUser has joined in, returning PendingRequest. Requires "guilds" scope.
        Returns:
        pending request, containing guilds information
        Throws:
        MissingScopeException - if "guilds" scope wasn't specified
        See Also:
        PendingRequest, Guild
      • getHttpClient

        @Nonnull
        okhttp3.OkHttpClient getHttpClient()
        Returns the OkHttpClient, used to handle requests.
        Returns:
        http client
      • getJsonMapper

        @Nonnull
        com.fasterxml.jackson.databind.ObjectMapper getJsonMapper()
        Returns the ObjectMapper, used to read json from discord api responses.
        Returns:
        json mapper