use of io.discloader.discloader.network.json.ChannelJSON in project DiscLoader by R3alCl0ud.
the class TextChannel method setTopic.
public CompletableFuture<IGuildTextChannel> setTopic(String topic) {
if (!this.permissionsOf(guild.getCurrentMember()).hasAny(Permissions.MANAGE_CHANNELS, Permissions.ADMINISTRATOR) && !guild.isOwner()) {
throw new PermissionsException("Insufficient Permissions");
}
if (topic.length() > 1024) {
throw new RuntimeException("topic length [" + topic.length() + "] > 1024");
}
CompletableFuture<IGuildTextChannel> future = new CompletableFuture<>();
JSONObject payload = new JSONObject().put("topic", topic);
CompletableFuture<ChannelJSON> cf = loader.rest.request(Methods.PATCH, Endpoints.channel(getID()), new RESTOptions(payload), ChannelJSON.class);
cf.thenAcceptAsync(data -> {
IGuildTextChannel channel = (IGuildTextChannel) EntityBuilder.getChannelFactory().buildChannel(data, getLoader(), getGuild(), false);
future.complete(channel);
});
cf.exceptionally(ex -> {
future.completeExceptionally(ex);
return null;
});
return future;
}
Aggregations