use of com.sx4.bot.http.HttpCallback in project Sx4 by sx4-discord-bot.
the class StatusCommand method onCommand.
public void onCommand(Sx4CommandEvent event, @Argument(value = "status") Status status, @Argument(value = "user", endless = true, nullDefault = true) Member member) {
Request request = new ImageRequest(event.getConfig().getImageWebserverUrl("status")).addQuery("image", member == null ? event.getMember().getEffectiveAvatarUrl() : member.getEffectiveAvatarUrl()).addQuery("status", status.toString().toLowerCase()).build(event.getConfig().getImageWebserver());
event.getHttpClient().newCall(request).enqueue((HttpCallback) response -> ImageUtility.getImageMessage(event, response).queue());
}
use of com.sx4.bot.http.HttpCallback in project Sx4 by sx4-discord-bot.
the class TrashCommand 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("trash")).addQuery("image", imageUrl).build(event.getConfig().getImageWebserver());
event.getHttpClient().newCall(request).enqueue((HttpCallback) response -> ImageUtility.getImageMessage(event, response).queue());
}
use of com.sx4.bot.http.HttpCallback in project Sx4 by sx4-discord-bot.
the class TrumpTweetCommand method onCommand.
public void onCommand(Sx4CommandEvent event, @Argument(value = "text", endless = true) @Limit(max = 280) String text) {
Request request = new ImageRequest(event.getConfig().getImageWebserverUrl("trump")).addQuery("text", ImageUtility.escapeMentions(event.getGuild(), text)).build(event.getConfig().getImageWebserver());
event.getHttpClient().newCall(request).enqueue((HttpCallback) response -> ImageUtility.getImageMessage(event, response).queue());
}
use of com.sx4.bot.http.HttpCallback 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.http.HttpCallback 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.getChannel(), 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();
});
}
Aggregations