Search in sources :

Example 1 with PruneCountJSON

use of io.discloader.discloader.network.json.PruneCountJSON in project DiscLoader by R3alCl0ud.

the class Guild method getPruneCount.

@Override
public CompletableFuture<Integer> getPruneCount(int days) {
    CompletableFuture<Integer> future = new CompletableFuture<>();
    JSONObject payload = new JSONObject().put("days", days);
    CompletableFuture<PruneCountJSON> cf = getLoader().rest.request(Methods.GET, Endpoints.guildPrune(getID()), new RESTOptions(payload), PruneCountJSON.class);
    cf.thenAcceptAsync(data -> {
        future.complete(Integer.valueOf(data.pruned));
    });
    cf.exceptionally(ex -> {
        future.completeExceptionally(ex);
        return null;
    });
    return future;
}
Also used : CompletableFuture(java.util.concurrent.CompletableFuture) JSONObject(org.json.JSONObject) RESTOptions(io.discloader.discloader.network.rest.RESTOptions) PruneCountJSON(io.discloader.discloader.network.json.PruneCountJSON)

Aggregations

PruneCountJSON (io.discloader.discloader.network.json.PruneCountJSON)1 RESTOptions (io.discloader.discloader.network.rest.RESTOptions)1 CompletableFuture (java.util.concurrent.CompletableFuture)1 JSONObject (org.json.JSONObject)1