use of io.discloader.discloader.network.rest.RESTOptions in project DiscLoader by R3alCl0ud.
the class Guild method getAuditLog.
@Override
public CompletableFuture<IAuditLog> getAuditLog(IUser user) {
CompletableFuture<IAuditLog> future = new CompletableFuture<>();
JSONObject params = new JSONObject().put("user_id", SnowflakeUtil.asString(user));
CompletableFuture<AuditLogJSON> cf = loader.rest.request(Methods.GET, Endpoints.auditLogs(getID()), new RESTOptions(params), AuditLogJSON.class);
cf.thenAcceptAsync(al -> {
future.complete(new AuditLog(this, al));
});
cf.exceptionally(ex -> {
future.completeExceptionally(ex);
return null;
});
return future;
}
use of io.discloader.discloader.network.rest.RESTOptions in project DiscLoader by R3alCl0ud.
the class Guild method getAuditLog.
/*
* (non-Javadoc)
*
* @see io.discloader.discloader.entity.guild.IGuild#getAuditLog(io.discloader.
* discloader.entity.auditlog.ActionTypes, short)
*/
@Override
public CompletableFuture<IAuditLog> getAuditLog(ActionTypes action, int limit) {
CompletableFuture<IAuditLog> future = new CompletableFuture<>();
CompletableFuture<AuditLogJSON> cf = loader.rest.request(Methods.GET, Endpoints.auditLogs(getID()) + "?action_type=" + action.toInt() + "&limit=" + limit, new RESTOptions(), AuditLogJSON.class);
cf.thenAcceptAsync(al -> {
future.complete(new AuditLog(this, al));
});
cf.exceptionally(ex -> {
future.completeExceptionally(ex);
return null;
});
return future;
}
use of io.discloader.discloader.network.rest.RESTOptions 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;
}
use of io.discloader.discloader.network.rest.RESTOptions in project DiscLoader by R3alCl0ud.
the class Guild method ban.
@Override
public CompletableFuture<IGuildMember> ban(IGuildMember member, String reason) throws PermissionsException {
if (!hasPermission(Permissions.BAN_MEMBERS))
throw new PermissionsException("");
CompletableFuture<IGuildMember> future = new CompletableFuture<>();
loader.rest.request(Methods.PUT, Endpoints.guildBanMember(getID(), member.getID()), new RESTOptions(reason), Void.class).thenAcceptAsync(action -> {
future.complete(member);
});
return future;
}
use of io.discloader.discloader.network.rest.RESTOptions in project DiscLoader by R3alCl0ud.
the class Guild method ban.
@Override
public CompletableFuture<IGuildMember> ban(IGuildMember member) {
if (!hasPermission(Permissions.BAN_MEMBERS))
throw new PermissionsException("");
CompletableFuture<IGuildMember> future = new CompletableFuture<>();
loader.rest.request(Methods.PUT, Endpoints.guildBanMember(getID(), member.getID()), new RESTOptions(), Void.class).thenAcceptAsync(action -> {
future.complete(member);
});
return future;
}
Aggregations