use of io.discloader.discloader.entity.invite.IInvite in project DiscLoader by R3alCl0ud.
the class Invite method delete.
@Override
public CompletableFuture<IInvite> delete() {
CompletableFuture<IInvite> future = new CompletableFuture<>();
CompletableFuture<InviteJSON> cf = loader.rest.request(Methods.DELETE, Endpoints.invite(code), new RESTOptions(), InviteJSON.class);
cf.thenAcceptAsync(inviteJSON -> {
future.complete(new Invite(inviteJSON, loader));
});
cf.exceptionally(ex -> {
future.completeExceptionally(ex);
return null;
});
return future;
}
use of io.discloader.discloader.entity.invite.IInvite in project DiscLoader by R3alCl0ud.
the class FetchInvites method complete.
@Override
public void complete(String s, Throwable ex) {
if (ex != null) {
future.completeExceptionally(ex);
return;
}
List<IInvite> invites = new ArrayList<>();
InviteJSON[] inviteJSONs = gson.fromJson(s, InviteJSON[].class);
for (InviteJSON invite : inviteJSONs) {
invites.add(EntityBuilder.getInviteFactory().buildInvite(invite));
}
future.complete(invites);
}
use of io.discloader.discloader.entity.invite.IInvite 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.entity.invite.IInvite 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