use of io.discloader.discloader.network.rest.RESTOptions in project DiscLoader by R3alCl0ud.
the class GuildChannel method deleteOverwrite.
// @Override
// public CompletableFuture<IGuildChannel> clone() {
// return guild.createTextChannel(name);
// }
@Override
public CompletableFuture<IOverwrite> deleteOverwrite(IOverwrite overwrite) {
CompletableFuture<IOverwrite> future = new CompletableFuture<>();
loader.rest.request(Methods.DELETE, Endpoints.channelOverwrite(getID(), overwrite.getID()), new RESTOptions(), Void.class).thenAcceptAsync(n -> {
future.complete(overwrite);
}).exceptionally(ex -> {
future.completeExceptionally(ex);
return null;
});
return future;
}
use of io.discloader.discloader.network.rest.RESTOptions 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;
}
use of io.discloader.discloader.network.rest.RESTOptions in project DiscLoader by R3alCl0ud.
the class GuildChannel method deleteOverwrites.
@Override
public CompletableFuture<List<IOverwrite>> deleteOverwrites(IOverwrite... overwrites) {
CompletableFuture<List<IOverwrite>> future = new CompletableFuture<>();
List<IOverwrite> keep = new ArrayList<>(), removed = new ArrayList<>();
for (IOverwrite ow : this.overwrites.values()) keep.add(ow);
for (IOverwrite ow : overwrites) {
if (this.overwrites.containsKey(ow.getID())) {
keep.remove(this.overwrites.get(ow.getID()));
removed.add(this.overwrites.get(ow.getID()));
}
}
JSONObject props = new JSONObject().put("permission_overwrites", keep);
loader.rest.request(Methods.PATCH, Endpoints.channel(getID()), new RESTOptions(props), ChannelJSON.class).thenAcceptAsync(data -> {
future.complete(removed);
}).exceptionally(ex -> {
future.completeExceptionally(ex);
return null;
});
return future;
}
use of io.discloader.discloader.network.rest.RESTOptions in project DiscLoader by R3alCl0ud.
the class TextChannel method sendMessage.
@Override
public CompletableFuture<IMessage> sendMessage(String content, RichEmbed embed, Attachment attachment) {
File file = attachment == null ? null : new File(attachment.filename);
SendableMessage sendable = new SendableMessage(content, false, embed, attachment, file);
CompletableFuture<IMessage> future = new CompletableFuture<>();
CompletableFuture<MessageJSON> mcf = loader.rest.request(Methods.POST, Endpoints.messages(getID()), new RESTOptions(sendable), MessageJSON.class);
mcf.thenAcceptAsync(e -> {
future.complete(new Message<>(this, e));
});
mcf.exceptionally(ex -> {
future.completeExceptionally(ex);
return null;
});
return future;
}
use of io.discloader.discloader.network.rest.RESTOptions in project DiscLoader by R3alCl0ud.
the class TextChannel method sendMessage.
@Override
public CompletableFuture<IMessage> sendMessage(String content, RichEmbed embed, Resource resource) {
Attachment attachment = resource == null ? null : new Attachment(resource.getFileName());
SendableMessage sendable = new SendableMessage(content, false, embed, attachment, resource);
CompletableFuture<IMessage> future = new CompletableFuture<>();
CompletableFuture<MessageJSON> mcf = loader.rest.request(Methods.POST, Endpoints.messages(getID()), new RESTOptions(sendable), MessageJSON.class);
mcf.thenAcceptAsync(e -> {
future.complete(new Message<>(this, e));
});
mcf.exceptionally(ex -> {
future.completeExceptionally(ex);
return null;
});
return future;
}
Aggregations