use of io.discloader.discloader.network.json.OAuthApplicationJSON in project DiscLoader by R3alCl0ud.
the class DLUser method getOAuth2Application.
/**
* Gets the OAuth2 application of the logged in user, if {@link User#isBot()}
* returns true
*
* @return A Future that completes with a new {@link OAuth2Application} if
* successful.
* @throws AccountTypeException
* Thrown if the account the client is logged in as is a user
* account.
*/
public CompletableFuture<OAuth2Application> getOAuth2Application() {
if (!isBot()) {
throw new AccountTypeException("Cannot fetch the OAuth2Application details of a User Account.");
}
CompletableFuture<OAuth2Application> future = new CompletableFuture<>();
CompletableFuture<OAuthApplicationJSON> cf = getLoader().rest.request(Methods.GET, Endpoints.currentOAuthApplication, new RESTOptions(), OAuthApplicationJSON.class);
cf.thenAcceptAsync(appData -> {
IUser owner = EntityRegistry.addUser(appData.owner);
future.complete(new OAuth2Application(appData, owner));
});
cf.exceptionally(ex -> {
future.completeExceptionally(ex);
return null;
});
return future;
}
Aggregations