use of io.discloader.discloader.entity.channel.IChannelCategory in project DiscLoader by R3alCl0ud.
the class Guild method createCategory.
@Override
public CompletableFuture<IChannelCategory> createCategory(String name) {
CompletableFuture<IChannelCategory> future = new CompletableFuture<>();
JSONObject chanSet = new JSONObject().put("name", name).put("type", 4);
loader.rest.request(Methods.POST, Endpoints.guildChannels(getID()), new RESTOptions(chanSet), ChannelJSON.class).thenAcceptAsync(d -> {
IChannel channel = EntityBuilder.getChannelFactory().buildChannel(d, loader, this, false);
if (channel instanceof IChannelCategory)
future.complete((IChannelCategory) channel);
});
return future;
}
use of io.discloader.discloader.entity.channel.IChannelCategory in project DiscLoader by R3alCl0ud.
the class Guild method createCategory.
@Override
public CompletableFuture<IChannelCategory> createCategory(String name, IOverwrite... overwrites) {
CompletableFuture<IChannelCategory> future = new CompletableFuture<>();
JSONArray ows = new JSONArray();
for (IOverwrite ow : overwrites) {
ows.put(ow);
}
JSONObject chanSet = new JSONObject().put("name", name).put("type", 4).put("permission_overwrites", ows);
loader.rest.request(Methods.POST, Endpoints.guildChannels(getID()), new RESTOptions(chanSet), ChannelJSON.class).thenAcceptAsync(d -> {
IChannel channel = EntityBuilder.getChannelFactory().buildChannel(d, loader, this, false);
if (channel instanceof IChannelCategory)
future.complete((IChannelCategory) channel);
});
return future;
}
use of io.discloader.discloader.entity.channel.IChannelCategory in project DiscLoader by R3alCl0ud.
the class GuildChannel method setCategory.
@Override
public CompletableFuture<IGuildChannel> setCategory(IChannelCategory category) {
CompletableFuture<IGuildChannel> future = new CompletableFuture<>();
JSONObject settings = new JSONObject().put("parent_id", SnowflakeUtil.asString(category));
loader.rest.request(Methods.PATCH, Endpoints.channel(getID()), new RESTOptions(settings), ChannelJSON.class).thenAcceptAsync(data -> {
IGuildChannel newChannel = (IGuildChannel) EntityBuilder.getChannelFactory().buildChannel(data, getLoader(), getGuild(), false);
future.complete(newChannel);
}).exceptionally(ex -> {
future.completeExceptionally(ex);
return null;
});
return future;
}
Aggregations