use of io.discloader.discloader.entity.sendable.CreateEmoji in project DiscLoader by R3alCl0ud.
the class Guild method createEmoji.
@Override
public CompletableFuture<IGuildEmoji> createEmoji(String name, String image, IRole... roles) {
CompletableFuture<IGuildEmoji> future = new CompletableFuture<>();
String base64 = null;
try {
base64 = new String("data:image/jpg;base64," + Base64.encodeBase64String(Files.readAllBytes(Paths.get(image))));
} catch (IOException e) {
e.printStackTrace();
}
String[] rids = new String[roles.length];
for (int i = 0; i < rids.length; i++) {
rids[i] = SnowflakeUtil.asString(roles[i]);
}
CreateEmoji ce = new CreateEmoji(name, base64, rids);
CompletableFuture<EmojiJSON> cf = getLoader().rest.request(Methods.POST, Endpoints.guildEmojis(getID()), new RESTOptions(ce), EmojiJSON.class);
cf.thenAcceptAsync(ed -> {
future.complete(new GuildEmoji(ed, this));
});
cf.exceptionally(ex -> {
future.completeExceptionally(ex);
return null;
});
return future;
}
Aggregations