use of io.discloader.discloader.network.json.ChannelJSON in project DiscLoader by R3alCl0ud.
the class CreateDMChannel method complete.
public void complete(String packet, Throwable ex) {
if (ex != null) {
future.completeExceptionally(ex);
return;
}
ChannelJSON data = gson.fromJson(packet, ChannelJSON.class);
future.complete((IPrivateChannel) EntityRegistry.addChannel(data, loader));
}
use of io.discloader.discloader.network.json.ChannelJSON in project DiscLoader by R3alCl0ud.
the class CreateVoiceChannel method complete.
public void complete(String packet, Throwable ex) {
if (ex != null) {
future.completeExceptionally(ex);
return;
}
ChannelJSON data = gson.fromJson(packet, ChannelJSON.class);
future.complete((IGuildVoiceChannel) EntityRegistry.addChannel(data, loader));
}
use of io.discloader.discloader.network.json.ChannelJSON in project DiscLoader by R3alCl0ud.
the class ChannelCategory method createTextChannel.
@Override
public CompletableFuture<IGuildTextChannel> createTextChannel(String name) {
CompletableFuture<IGuildTextChannel> future = new CompletableFuture<>();
JSONObject data = new JSONObject().put("parent_id", SnowflakeUtil.asString(this)).put("name", name).put("type", 0);
// System.out.println(data.toString());
CompletableFuture<ChannelJSON> cf = loader.rest.request(Methods.POST, Endpoints.guildChannels(getGuild().getID()), new RESTOptions(data), ChannelJSON.class);
cf.thenAcceptAsync(channelJSON -> {
if (channelJSON != null) {
IGuildTextChannel channel = (IGuildTextChannel) EntityBuilder.getChannelFactory().buildChannel(channelJSON, getLoader(), getGuild(), false);
if (channel != null)
future.complete(channel);
}
});
cf.exceptionally(ex -> {
future.completeExceptionally(ex);
return null;
});
return future;
}
use of io.discloader.discloader.network.json.ChannelJSON in project DiscLoader by R3alCl0ud.
the class ChannelCategory method createChannel.
@Override
public CompletableFuture<IGuildChannel> createChannel(String name, ChannelTypes type, IOverwrite... overwrites) {
CompletableFuture<IGuildChannel> future = new CompletableFuture<>();
// JSONObject data = new JSONObject().put("parent_id",
// SnowflakeUtil.asString(this)).put("name", name).put("type", type.toInt()).;
ChannelPayload data = new ChannelPayload(name, type, overwrites);
CompletableFuture<ChannelJSON> cf = loader.rest.request(Methods.POST, Endpoints.guildChannels(getGuild().getID()), new RESTOptions(data), ChannelJSON.class);
cf.thenAcceptAsync(channelJSON -> {
if (channelJSON != null) {
IGuildChannel channel = (IGuildChannel) EntityBuilder.getChannelFactory().buildChannel(channelJSON, getLoader(), getGuild(), false);
if (channel != null)
future.complete(channel);
}
});
cf.exceptionally(ex -> {
future.completeExceptionally(ex);
return null;
});
return future;
}
use of io.discloader.discloader.network.json.ChannelJSON in project DiscLoader by R3alCl0ud.
the class ChannelCategory method createVoiceChannel.
@Override
public CompletableFuture<IGuildVoiceChannel> createVoiceChannel(String name) {
CompletableFuture<IGuildVoiceChannel> future = new CompletableFuture<>();
JSONObject data = new JSONObject().put("parent_id", SnowflakeUtil.asString(this)).put("name", name).put("type", 2);
CompletableFuture<ChannelJSON> cf = loader.rest.request(Methods.POST, Endpoints.guildChannels(getGuild().getID()), new RESTOptions(data), 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