use of io.discloader.discloader.entity.sendable.EditChannel in project DiscLoader by R3alCl0ud.
the class VoiceChannel method edit.
/**
* Changes the channels settings
*
* @param name
* The new name for the channel
* @param position
* The new position for the channel
* @param bitrate
* The new {@link #bitrate}
* @param userLimit
* The new {@link #userLimit}
* @return A Future that completes with a voice channel if successful
*/
public CompletableFuture<IGuildVoiceChannel> edit(String name, int position, int bitrate, int userLimit) {
CompletableFuture<IGuildVoiceChannel> future = new CompletableFuture<>();
EditChannel d = new EditChannel(name, null, position, bitrate, userLimit);
CompletableFuture<ChannelJSON> cf = loader.rest.request(Methods.PATCH, Endpoints.channel(getID()), new RESTOptions(d), ChannelJSON.class);
cf.thenAcceptAsync(channelJSON -> {
if (channelJSON != null) {
IGuildVoiceChannel channel = (IGuildVoiceChannel) EntityBuilder.getChannelFactory().buildChannel(channelJSON, getLoader(), getGuild(), false);
if (channel != null)
future.complete(channel);
}
});
cf.exceptionally(ex -> {
future.completeExceptionally(ex);
return null;
});
return future;
}
Aggregations