diff options
Diffstat (limited to 'src/main/java/net/tylermurphy/ken/command/nsfw/E621.java')
-rw-r--r-- | src/main/java/net/tylermurphy/ken/command/nsfw/E621.java | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/src/main/java/net/tylermurphy/ken/command/nsfw/E621.java b/src/main/java/net/tylermurphy/ken/command/nsfw/E621.java new file mode 100644 index 0000000..837cca9 --- /dev/null +++ b/src/main/java/net/tylermurphy/ken/command/nsfw/E621.java @@ -0,0 +1,36 @@ +package net.tylermurphy.ken.command.nsfw; + +import net.dv8tion.jda.api.entities.GuildMessageChannel; +import net.dv8tion.jda.api.entities.TextChannel; +import net.dv8tion.jda.api.interactions.commands.OptionType; +import net.tylermurphy.ken.Ken; +import net.tylermurphy.ken.api.E621API; +import net.tylermurphy.ken.command.Command; +import net.tylermurphy.ken.command.Option; +import net.tylermurphy.ken.command.Response; + +import java.util.List; + +public class E621 { + + @Command(name="e621",description=":underage: Searches for an image off of e621") + @Option(name="query",description="Search query for rule34",type= OptionType.STRING,required=true) + public Response execute(GuildMessageChannel channel, List<String> args){ + if(!(channel instanceof TextChannel)) { + return Response.error("This command can only be used in a text channel"); + } + TextChannel textChannel = (TextChannel) channel; + if(!textChannel.isNSFW()){ + return Response.error("This command can only be used in an NSFW channel"); + } + String url = E621API.request(args.get(0)); + if(url == null){ + return Response.error("Unable to find post with search: "+args.get(0)); + } else { + if(url.endsWith(".mp4") || url.endsWith(".webm")) + return Response.success(url); + return Response.success(Ken.getInstance().getDefaultEmbed().setImage(url).build()); + } + } + +} |