use of io.discloader.discloader.core.entity.invite.Invite in project DiscLoader by R3alCl0ud.
the class DiscLoader method getInvite.
/**
* @param code
* @return A CompletableFuture that completes with an IInvite object if
* successful.
*/
public CompletableFuture<IInvite> getInvite(String code) {
CompletableFuture<IInvite> future = new CompletableFuture<>();
CompletableFuture<InviteJSON> cf = rest.request(Methods.GET, Endpoints.invite(code), new RESTOptions(), InviteJSON.class);
cf.thenAcceptAsync(inviteJSON -> {
future.complete(new Invite(inviteJSON, this));
});
cf.exceptionally(ex -> {
future.completeExceptionally(ex);
return null;
});
return future;
}
use of io.discloader.discloader.core.entity.invite.Invite in project DiscLoader by R3alCl0ud.
the class Guild method fetchInvites.
@Override
public CompletableFuture<List<IInvite>> fetchInvites() {
CompletableFuture<List<IInvite>> future = new CompletableFuture<List<IInvite>>();
CompletableFuture<InviteJSON[]> cf = getLoader().rest.request(Methods.GET, Endpoints.guildInvites(getID()), new RESTOptions(), InviteJSON[].class);
cf.thenAcceptAsync(inJ -> {
List<IInvite> ins = new ArrayList<>();
for (int i = 0; i < inJ.length; i++) {
IInvite in = new Invite(inJ[i], getLoader());
invites.put(in.getCode(), in);
ins.add(in);
}
future.complete(ins);
});
return future;
}
Aggregations