Search in sources :

Example 11 with ImageUrl

use of com.sx4.bot.annotations.argument.ImageUrl in project Sx4 by sx4-discord-bot.

the class ResizeCommand method onCommand.

public void onCommand(Sx4CommandEvent event, @Argument(value = "image url") @ImageUrl String imageUrl, @Argument(value = "width") @Limit(min = 0, max = 5000) double width, @Argument(value = "height") @Limit(min = 0, max = 5000) @DefaultNumber(1) double height) {
    Request request = new ImageRequest(event.getConfig().getImageWebserverUrl("resize")).addQuery("w", width).addQuery("h", height).addQuery("image", imageUrl).build(event.getConfig().getImageWebserver());
    event.getHttpClient().newCall(request).enqueue((HttpCallback) response -> {
        ImageUtility.getImageMessage(event, response, (body, error) -> {
            if (error == ImageError.INVALID_QUERY_VALUE) {
                return event.replyFailure(body.getString("message"));
            }
            return null;
        }).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) ImageError(com.sx4.bot.entities.image.ImageError) Permission(net.dv8tion.jda.api.Permission) ModuleCategory(com.sx4.bot.category.ModuleCategory) DefaultNumber(com.sx4.bot.annotations.argument.DefaultNumber) Sx4CommandEvent(com.sx4.bot.core.Sx4CommandEvent) ImageUrl(com.sx4.bot.annotations.argument.ImageUrl) Argument(com.jockie.bot.core.argument.Argument) Limit(com.sx4.bot.annotations.argument.Limit) ImageRequest(com.sx4.bot.entities.image.ImageRequest) Request(okhttp3.Request) ImageRequest(com.sx4.bot.entities.image.ImageRequest)

Example 12 with ImageUrl

use of com.sx4.bot.annotations.argument.ImageUrl 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 13 with ImageUrl

use of com.sx4.bot.annotations.argument.ImageUrl 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 14 with ImageUrl

use of com.sx4.bot.annotations.argument.ImageUrl 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());
}
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 15 with ImageUrl

use of com.sx4.bot.annotations.argument.ImageUrl 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());
}
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) 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

Sx4Command (com.sx4.bot.core.Sx4Command)25 Argument (com.jockie.bot.core.argument.Argument)22 ModuleCategory (com.sx4.bot.category.ModuleCategory)22 Sx4CommandEvent (com.sx4.bot.core.Sx4CommandEvent)22 HttpCallback (com.sx4.bot.http.HttpCallback)22 Request (okhttp3.Request)22 ImageUrl (com.sx4.bot.annotations.argument.ImageUrl)21 ImageRequest (com.sx4.bot.entities.image.ImageRequest)21 ImageUtility (com.sx4.bot.utility.ImageUtility)21 Permission (net.dv8tion.jda.api.Permission)20 Command (com.jockie.bot.core.command.Command)3 ImageError (com.sx4.bot.entities.image.ImageError)3 Document (org.bson.Document)3 DefaultNumber (com.sx4.bot.annotations.argument.DefaultNumber)2 Limit (com.sx4.bot.annotations.argument.Limit)2 PagedResult (com.sx4.bot.paged.PagedResult)2 ColourUtility (com.sx4.bot.utility.ColourUtility)2 List (java.util.List)2 EmbedBuilder (net.dv8tion.jda.api.EmbedBuilder)2 BaseGuildMessageChannel (net.dv8tion.jda.api.entities.BaseGuildMessageChannel)2