From ad09706b77d0d99fea64296303923133ccf5e896 Mon Sep 17 00:00:00 2001 From: oko Date: Sun, 13 Nov 2022 03:58:18 -0800 Subject: [PATCH] Remove CatCommand will be replaced with DogCommand --- .../oko/Kiafumi/command/image/CatCommand.java | 71 ------------------- 1 file changed, 71 deletions(-) delete mode 100644 src/main/java/moe/oko/Kiafumi/command/image/CatCommand.java diff --git a/src/main/java/moe/oko/Kiafumi/command/image/CatCommand.java b/src/main/java/moe/oko/Kiafumi/command/image/CatCommand.java deleted file mode 100644 index 8d828cb..0000000 --- a/src/main/java/moe/oko/Kiafumi/command/image/CatCommand.java +++ /dev/null @@ -1,71 +0,0 @@ -package moe.oko.Kiafumi.command.image; - -import moe.oko.Kiafumi.command.CommandClass; -import moe.oko.Kiafumi.util.CommandInfo; -import moe.oko.Kiafumi.util.CommandType; -import moe.oko.Kiafumi.util.EmbedUI; -import net.dv8tion.jda.api.EmbedBuilder; -import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent; -import org.apache.http.client.methods.HttpGet; -import org.apache.http.impl.client.HttpClients; -import org.json.JSONArray; - -import java.net.URI; -import java.util.ArrayList; -import java.util.List; - -import static moe.oko.Kiafumi.util.LoggingManager.error; -import static moe.oko.Kiafumi.util.LoggingManager.slashLog; -import static moe.oko.Kiafumi.util.ResponseHandlers.STRING_RESPONSE_HANDLER; - -/** - * Mrow :3 - * @author Kay - */ -public class CatCommand extends CommandClass { - - private final URI catUrl = URI.create("https://api.thecatapi.com/v1/images/search"); - - @Override - public boolean isEnabled() { - return true; - } - - @Override - public String getName() { - return "Cat"; - } - - @Override - public void newCommand(String name, SlashCommandInteractionEvent e) { - switch (name) { - case "cat": - slashLog(e); - e.deferReply().queue(); - - var httpClient = HttpClients.createDefault(); - var httpGet = new HttpGet(catUrl); - try { - var responseBody = httpClient.execute(httpGet, STRING_RESPONSE_HANDLER); - var array = new JSONArray(responseBody); - var obj = array.getJSONObject(0); - var eb = new EmbedBuilder() - .setColor(EmbedUI.INFO) - .setTitle("meow") - .setImage(obj.getString("url")) - .setFooter(EmbedUI.BRAND); - e.getHook().sendMessageEmbeds(eb.build()).queue(); - } catch (Exception ex) { - ex.printStackTrace(); - error("Error using CatCommand."); - } - } - } - - @Override - public List getSlashCommandInfo() { - List cil = new ArrayList<>(); - cil.add(new CommandInfo("cat", "Provides a random cat!", CommandType.COMMAND)); - return cil; - } -}