use of com.sx4.bot.entities.image.ImageRequest in project Sx4 by sx4-discord-bot.
the class ScrollCommand method onCommand.
public void onCommand(Sx4CommandEvent event, @Argument(value = "text", endless = true) @Limit(max = 45) String text) {
Request request = new ImageRequest(event.getConfig().getImageWebserverUrl("scroll")).addQuery("text", text).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 ShipCommand method onCommand.
public void onCommand(Sx4CommandEvent event, @Argument(value = "first user") Member firstMember, @Argument(value = "second user", endless = true, nullDefault = true) Member secondMember) {
User firstUser = firstMember.getUser();
User secondUser = secondMember == null ? event.getAuthor() : secondMember.getUser();
this.random.setSeed(firstUser.getIdLong() + secondUser.getIdLong());
int percent = this.random.nextInt(100) + 1;
String firstName = firstUser.getName(), secondName = secondUser.getName();
String shipName = firstName.substring(0, (int) Math.ceil((double) firstName.length() / 2)) + secondName.substring((int) Math.ceil((double) secondName.length() / 2));
String message = String.format("Ship Name: **%s**\nLove Percentage: **%d%%**", shipName, percent);
Request request = new ImageRequest(event.getConfig().getImageWebserverUrl("ship")).addQuery("first_image", firstUser.getEffectiveAvatarUrl()).addQuery("second_image", secondUser.getEffectiveAvatarUrl()).addQuery("percent", percent).build(event.getConfig().getImageWebserver());
if (event.getSelfMember().hasPermission(event.getTextChannel(), Permission.MESSAGE_ATTACH_FILES)) {
event.getHttpClient().newCall(request).enqueue((HttpCallback) response -> {
MessageAction action = ImageUtility.getImageMessage(event, response);
if (response.isSuccessful()) {
action.content(message);
}
action.queue();
});
} else {
event.reply(message).queue();
}
}
use of com.sx4.bot.entities.image.ImageRequest 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.entities.image.ImageRequest 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.entities.image.ImageRequest 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());
}
Aggregations