use of com.jockie.bot.core.argument.Argument in project Sx4 by sx4-discord-bot.
the class HalloweenCommand 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("halloween")).addQuery("image", imageUrl).build(event.getConfig().getImageWebserver());
event.getHttpClient().newCall(request).enqueue((HttpCallback) response -> ImageUtility.getImageMessage(event, response).queue());
}
use of com.jockie.bot.core.argument.Argument in project Sx4 by sx4-discord-bot.
the class HowToGoogleCommand method onCommand.
public void onCommand(Sx4CommandEvent event, @Argument(value = "query", endless = true) @Limit(max = 50) String query) {
Request request = new ImageRequest(event.getConfig().getImageWebserverUrl("google")).addQuery("q", query).build(event.getConfig().getImageWebserver());
event.getHttpClient().newCall(request).enqueue((HttpCallback) response -> ImageUtility.getImageMessage(event, response).queue());
}
use of com.jockie.bot.core.argument.Argument in project Sx4 by sx4-discord-bot.
the class HueCommand 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("hue")).addQuery("image", imageUrl).build(event.getConfig().getImageWebserver());
event.getHttpClient().newCall(request).enqueue((HttpCallback) response -> ImageUtility.getImageMessage(event, response).queue());
}
use of com.jockie.bot.core.argument.Argument in project Sx4 by sx4-discord-bot.
the class InvertCommand 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("invert")).addQuery("image", imageUrl).build(event.getConfig().getImageWebserver());
event.getHttpClient().newCall(request).enqueue((HttpCallback) response -> ImageUtility.getImageMessage(event, response).queue());
}
use of com.jockie.bot.core.argument.Argument in project Sx4 by sx4-discord-bot.
the class MostCommonColourCommand method onCommand.
public void onCommand(Sx4CommandEvent event, @Argument(value = "image url", acceptEmpty = true, endless = true) @ImageUrl String imageUrl) {
Request request = new ImageRequest(event.getConfig().getImageWebserverUrl("common-colour")).addQuery("image", imageUrl).build(event.getConfig().getImageWebserver());
event.getHttpClient().newCall(request).enqueue((HttpCallback) response -> {
if (!response.isSuccessful()) {
ImageUtility.getErrorMessage(event.getChannel(), response.code(), response.body().string()).queue();
return;
}
Document data = Document.parse(response.body().string());
Document common = data.getList("colours", Document.class).get(0);
int colour = common.getInteger("colour");
EmbedBuilder embed = new EmbedBuilder().setTitle("Most Common Colour").setThumbnail(imageUrl).setColor(ImageUtility.getEmbedColour(colour)).addField("Colour", String.format("Hex: #%s\nRGB: %s", ColourUtility.toHexString(colour), ColourUtility.toRGBString(colour)), true).addField("Pixels", String.format("Amount: %,d", common.getInteger("pixels")), true);
event.reply(embed.build()).queue();
});
}
Aggregations