use of com.sx4.bot.entities.image.ImageRequest in project Sx4 by sx4-discord-bot.
the class WhoWouldWinCommand method onCommand.
public void onCommand(Sx4CommandEvent event, @Argument(value = "first image url") @ImageUrl String firstImageUrl, @Argument(value = "second image url", endless = true, acceptEmpty = true) @ImageUrl String secondImageUrl) {
Request request = new ImageRequest(event.getConfig().getImageWebserverUrl("www")).addQuery("first_image", firstImageUrl).addQuery("second_image", secondImageUrl).build(event.getConfig().getImageWebserver());
event.getHttpClient().newCall(request).enqueue((HttpCallback) response -> ImageUtility.getImageMessage(event, response).queue());
}
use of com.sx4.bot.entities.image.ImageRequest in project Sx4 by sx4-discord-bot.
the class AvatarCommand method onCommand.
public void onCommand(Sx4CommandEvent event, @Argument(value = "user", endless = true, nullDefault = true) Member member, @Option(value = "global", description = "Forced to show their global avatar") boolean global) {
Member effectiveMember = member == null ? event.getMember() : member;
User user = effectiveMember.getUser();
String avatar = global ? user.getEffectiveAvatarUrl() : effectiveMember.getEffectiveAvatarUrl();
Request request = new ImageRequest(event.getConfig().getImageWebserverUrl("median-colour")).addQuery("image", avatar).build(event.getConfig().getImageWebserver());
event.getHttpClient().newCall(request).enqueue((HttpCallback) response -> {
if (!response.isSuccessful()) {
ImageUtility.getErrorMessage(event.getTextChannel(), response.code(), response.body().string()).queue();
return;
}
Document data = Document.parse(response.body().string());
String sizedAvatar = avatar + "?size=1024";
EmbedBuilder embed = new EmbedBuilder().setImage(sizedAvatar).setColor(data.getInteger("colour")).setAuthor(user.getAsTag(), sizedAvatar, user.getEffectiveAvatarUrl());
event.reply(embed.build()).queue();
});
}
use of com.sx4.bot.entities.image.ImageRequest in project Sx4 by sx4-discord-bot.
the class BeautifulCommand method onCommand.
public void onCommand(Sx4CommandEvent event, @Argument(value = "image url", endless = true, acceptEmpty = true) @ImageUrl String imageUrl) {
Request request = new ImageRequest(event.getConfig().getImageWebserverUrl("beautiful")).addQuery("image", imageUrl).build(event.getConfig().getImageWebserver());
event.getHttpClient().newCall(request).enqueue((HttpCallback) response -> ImageUtility.getImageMessage(event, response).queue());
}
use of com.sx4.bot.entities.image.ImageRequest in project Sx4 by sx4-discord-bot.
the class ChangeColourCommand method onCommand.
public void onCommand(Sx4CommandEvent event, @Argument(value = "image", acceptEmpty = true) @ImageUrl String imageUrl, @Argument(value = "colour", endless = true) @Colour int colour) {
Request request = new ImageRequest(event.getConfig().getImageWebserverUrl("manipulate-colour")).addQuery("image", imageUrl).addQuery("colour", colour).build(event.getConfig().getImageWebserver());
event.getHttpClient().newCall(request).enqueue((HttpCallback) response -> ImageUtility.getImageMessage(event, response).queue());
}
use of com.sx4.bot.entities.image.ImageRequest in project Sx4 by sx4-discord-bot.
the class DiscordCommand method onCommand.
public void onCommand(Sx4CommandEvent event, @Argument(value = "user", nullDefault = true) Member member, @Argument(value = "text | message id", endless = true) @Limit(max = 250) Or<MessageArgument, String> option, @Option(value = "light", description = "Sets the discord theme to light") boolean light) {
if (member == null && option.hasSecond()) {
event.replyFailure("You need to provide a user when not giving a message").queue();
return;
}
this.getContext(option, member).thenAccept(pair -> {
Member effectiveMember = pair.getLeft();
User user = effectiveMember.getUser();
String text = pair.getRight();
Request request = new ImageRequest(event.getConfig().getImageWebserverUrl("discord")).addField("name", effectiveMember.getEffectiveName()).addField("avatar", user.getEffectiveAvatarUrl()).addField("bot", user.isBot()).addField("dark_theme", !light).addField("colour", effectiveMember.getColorRaw()).addField("text", text).addAllFields(this.getMentions(event.getShardManager(), event.getGuild(), text)).build(event.getConfig().getImageWebserver());
event.getHttpClient().newCall(request).enqueue((HttpCallback) response -> ImageUtility.getImageMessage(event, response).queue());
});
}
Aggregations