Search in sources :

Example 6 with ImageRequest

use of com.sx4.bot.entities.image.ImageRequest in project Sx4 by sx4-discord-bot.

the class EdgeCommand 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("edge")).addQuery("image", imageUrl).build(event.getConfig().getImageWebserver());
    event.getHttpClient().newCall(request).enqueue((HttpCallback) response -> ImageUtility.getImageMessage(event, response).queue());
}
Also used : ModuleCategory(com.sx4.bot.category.ModuleCategory) Request(okhttp3.Request) ImageRequest(com.sx4.bot.entities.image.ImageRequest) HttpCallback(com.sx4.bot.http.HttpCallback) ImageUtility(com.sx4.bot.utility.ImageUtility) Sx4Command(com.sx4.bot.core.Sx4Command) Sx4CommandEvent(com.sx4.bot.core.Sx4CommandEvent) Permission(net.dv8tion.jda.api.Permission) ImageUrl(com.sx4.bot.annotations.argument.ImageUrl) Argument(com.jockie.bot.core.argument.Argument) ImageRequest(com.sx4.bot.entities.image.ImageRequest) Request(okhttp3.Request) ImageRequest(com.sx4.bot.entities.image.ImageRequest)

Example 7 with ImageRequest

use of com.sx4.bot.entities.image.ImageRequest in project Sx4 by sx4-discord-bot.

the class ShitCommand 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("shit")).addQuery("image", imageUrl).build(event.getConfig().getImageWebserver());
    event.getHttpClient().newCall(request).enqueue((HttpCallback) response -> ImageUtility.getImageMessage(event, response).queue());
}
Also used : ModuleCategory(com.sx4.bot.category.ModuleCategory) Request(okhttp3.Request) ImageRequest(com.sx4.bot.entities.image.ImageRequest) HttpCallback(com.sx4.bot.http.HttpCallback) ImageUtility(com.sx4.bot.utility.ImageUtility) Sx4Command(com.sx4.bot.core.Sx4Command) Sx4CommandEvent(com.sx4.bot.core.Sx4CommandEvent) Permission(net.dv8tion.jda.api.Permission) ImageUrl(com.sx4.bot.annotations.argument.ImageUrl) Argument(com.jockie.bot.core.argument.Argument) ImageRequest(com.sx4.bot.entities.image.ImageRequest) Request(okhttp3.Request) ImageRequest(com.sx4.bot.entities.image.ImageRequest)

Example 8 with ImageRequest

use of com.sx4.bot.entities.image.ImageRequest in project Sx4 by sx4-discord-bot.

the class TweetCommand method onCommand.

public void onCommand(Sx4CommandEvent event, @Argument(value = "user") Member member, @Argument(value = "text", endless = true) @Limit(max = 280) String text) {
    User user = member.getUser();
    Guild guild = event.getGuild();
    int memberCount = guild.getMemberCount();
    int likes = event.getRandom().nextInt(memberCount);
    List<Member> members = guild.getMembers();
    List<String> urls = new ArrayList<>();
    for (int i = 0; i < Math.min(10, likes); i++) {
        urls.add(members.get(event.getRandom().nextInt(memberCount)).getUser().getEffectiveAvatarUrl() + "?size=64");
    }
    Request request = new ImageRequest(event.getConfig().getImageWebserverUrl("tweet")).addField("display_name", member.getEffectiveName()).addField("name", user.getName()).addField("avatar", user.getEffectiveAvatarUrl() + "?size=128").addField("retweets", event.getRandom().nextInt(memberCount)).addField("likes", likes).addField("text", ImageUtility.escapeMentions(guild, text)).addField("urls", urls).build(event.getConfig().getImageWebserver());
    event.getHttpClient().newCall(request).enqueue((HttpCallback) response -> ImageUtility.getImageMessage(event, response).queue());
}
Also used : Request(okhttp3.Request) ImageRequest(com.sx4.bot.entities.image.ImageRequest) HttpCallback(com.sx4.bot.http.HttpCallback) ImageUtility(com.sx4.bot.utility.ImageUtility) Sx4Command(com.sx4.bot.core.Sx4Command) Permission(net.dv8tion.jda.api.Permission) Member(net.dv8tion.jda.api.entities.Member) User(net.dv8tion.jda.api.entities.User) ArrayList(java.util.ArrayList) ModuleCategory(com.sx4.bot.category.ModuleCategory) List(java.util.List) Guild(net.dv8tion.jda.api.entities.Guild) Sx4CommandEvent(com.sx4.bot.core.Sx4CommandEvent) Argument(com.jockie.bot.core.argument.Argument) Limit(com.sx4.bot.annotations.argument.Limit) User(net.dv8tion.jda.api.entities.User) ImageRequest(com.sx4.bot.entities.image.ImageRequest) ArrayList(java.util.ArrayList) Request(okhttp3.Request) ImageRequest(com.sx4.bot.entities.image.ImageRequest) Guild(net.dv8tion.jda.api.entities.Guild) Member(net.dv8tion.jda.api.entities.Member)

Example 9 with ImageRequest

use of com.sx4.bot.entities.image.ImageRequest in project Sx4 by sx4-discord-bot.

the class VrCommand 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("vr")).addQuery("image", imageUrl).build(event.getConfig().getImageWebserver());
    event.getHttpClient().newCall(request).enqueue((HttpCallback) response -> ImageUtility.getImageMessage(event, response).queue());
}
Also used : ModuleCategory(com.sx4.bot.category.ModuleCategory) Request(okhttp3.Request) ImageRequest(com.sx4.bot.entities.image.ImageRequest) HttpCallback(com.sx4.bot.http.HttpCallback) ImageUtility(com.sx4.bot.utility.ImageUtility) Sx4Command(com.sx4.bot.core.Sx4Command) Sx4CommandEvent(com.sx4.bot.core.Sx4CommandEvent) Permission(net.dv8tion.jda.api.Permission) ImageUrl(com.sx4.bot.annotations.argument.ImageUrl) Argument(com.jockie.bot.core.argument.Argument) ImageRequest(com.sx4.bot.entities.image.ImageRequest) Request(okhttp3.Request) ImageRequest(com.sx4.bot.entities.image.ImageRequest)

Example 10 with ImageRequest

use of com.sx4.bot.entities.image.ImageRequest in project Sx4 by sx4-discord-bot.

the class EmbossCommand 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("emboss")).addQuery("image", imageUrl).build(event.getConfig().getImageWebserver());
    event.getHttpClient().newCall(request).enqueue((HttpCallback) response -> ImageUtility.getImageMessage(event, response).queue());
}
Also used : ModuleCategory(com.sx4.bot.category.ModuleCategory) Request(okhttp3.Request) ImageRequest(com.sx4.bot.entities.image.ImageRequest) HttpCallback(com.sx4.bot.http.HttpCallback) ImageUtility(com.sx4.bot.utility.ImageUtility) Sx4Command(com.sx4.bot.core.Sx4Command) Sx4CommandEvent(com.sx4.bot.core.Sx4CommandEvent) Permission(net.dv8tion.jda.api.Permission) ImageUrl(com.sx4.bot.annotations.argument.ImageUrl) Argument(com.jockie.bot.core.argument.Argument) ImageRequest(com.sx4.bot.entities.image.ImageRequest) Request(okhttp3.Request) ImageRequest(com.sx4.bot.entities.image.ImageRequest)

Aggregations

ImageRequest (com.sx4.bot.entities.image.ImageRequest)35 HttpCallback (com.sx4.bot.http.HttpCallback)35 ModuleCategory (com.sx4.bot.category.ModuleCategory)34 Sx4Command (com.sx4.bot.core.Sx4Command)34 Sx4CommandEvent (com.sx4.bot.core.Sx4CommandEvent)34 Argument (com.jockie.bot.core.argument.Argument)33 ImageUtility (com.sx4.bot.utility.ImageUtility)33 Request (okhttp3.Request)33 Permission (net.dv8tion.jda.api.Permission)31 ImageUrl (com.sx4.bot.annotations.argument.ImageUrl)21 Limit (com.sx4.bot.annotations.argument.Limit)8 Member (net.dv8tion.jda.api.entities.Member)8 Document (org.bson.Document)8 User (net.dv8tion.jda.api.entities.User)6 EmbedBuilder (net.dv8tion.jda.api.EmbedBuilder)5 DefaultNumber (com.sx4.bot.annotations.argument.DefaultNumber)3 ImageError (com.sx4.bot.entities.image.ImageError)3 ColourUtility (com.sx4.bot.utility.ColourUtility)3 Option (com.jockie.bot.core.option.Option)2 Colour (com.sx4.bot.annotations.argument.Colour)2