use of io.discloader.discloader.network.rest.RESTOptions in project DiscLoader by R3alCl0ud.
the class Guild method getAuditLog.
@Override
public CompletableFuture<IAuditLog> getAuditLog() {
CompletableFuture<IAuditLog> future = new CompletableFuture<>();
CompletableFuture<AuditLogJSON> cf = loader.rest.request(Methods.GET, Endpoints.auditLogs(getID()), new RESTOptions(), AuditLogJSON.class);
cf.thenAcceptAsync(al -> {
System.out.println("Does this get called?");
try {
future.complete(new AuditLog(this, al));
} catch (Exception e) {
future.completeExceptionally(e);
}
});
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 createTextChannel.
@Override
public CompletableFuture<IGuildTextChannel> createTextChannel(String name, IChannelCategory category, IOverwrite... overwrites) {
CompletableFuture<IGuildTextChannel> future = new CompletableFuture<>();
if (!hasPermission(Permissions.MANAGE_CHANNELS)) {
PermissionsException ex = new PermissionsException("Insufficient Permissions");
future.completeExceptionally(ex);
// return early
return future;
}
ChannelPayload data = new ChannelPayload(name, ChannelTypes.TEXT, overwrites);
data.setParent(category);
CompletableFuture<ChannelJSON> cf = getLoader().rest.request(Methods.POST, Endpoints.guildChannels(getID()), new RESTOptions(data), ChannelJSON.class);
cf.thenAcceptAsync(channelJSON -> {
IGuildTextChannel channel = (IGuildTextChannel) EntityBuilder.getChannelFactory().buildChannel(channelJSON, getLoader(), this, false);
future.complete(channel);
});
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.
@Override
public CompletableFuture<IAuditLog> getAuditLog(ActionTypes action) {
CompletableFuture<IAuditLog> future = new CompletableFuture<>();
CompletableFuture<AuditLogJSON> cf = loader.rest.request(Methods.GET, Endpoints.auditLogs(getID()) + "?action_type=" + action.toInt(), 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 GuildEmoji method setName.
@Override
public CompletableFuture<IGuildEmoji> setName(String name) {
if (!guild.hasPermission(Permissions.MANAGE_EMOJIS)) {
throw new PermissionsException("Insufficient Permissions: \"MANAGE_EMOJIS\" is required to use this endpoint");
}
CompletableFuture<IGuildEmoji> future = new CompletableFuture<>();
JSONObject payload = new JSONObject().put("name", name);
IEventListener el = new EventListenerAdapter() {
@Override
public void GuildEmojiUpdate(GuildEmojiUpdateEvent event) {
if (getID() == event.getEmoji().getID()) {
future.complete(event.getEmoji());
getLoader().removeEventListener(this);
}
}
};
getLoader().addEventListener(el).rest.request(Methods.PATCH, Endpoints.guildEmoji(getGuild().getID(), getID()), new RESTOptions(payload), EmojiJSON.class).exceptionally(ex -> {
future.completeExceptionally(ex);
getLoader().removeEventListener(el);
return null;
});
return future;
}
use of io.discloader.discloader.network.rest.RESTOptions 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;
}
Aggregations