diff --git a/src/main/java/moe/oko/Kiafumi/command/DuckCommand.java b/src/main/java/moe/oko/Kiafumi/command/DuckCommand.java index cb1e92c..397b83d 100644 --- a/src/main/java/moe/oko/Kiafumi/command/DuckCommand.java +++ b/src/main/java/moe/oko/Kiafumi/command/DuckCommand.java @@ -35,16 +35,29 @@ public class DuckCommand extends CommandClass{ public void newCommand(String name, SlashCommandInteractionEvent e) { switch (name) { case "search": - String option = e.getOption("Query").getAsString(); + e.deferReply().queue(); + String option = e.getOption("query").getAsString(); WebSearch ws = WebSearch.instanceOf(); - SearchResult sr = ws.instantAnswerSearch(option); + SearchResult sr; + try { + sr = ws.instantAnswerSearch(option); + } catch (Exception ex) { + EmbedBuilder eb = new EmbedBuilder() + .setColor(Color.RED) + .setTitle("Query Failed") + .setDescription("Couldn't find any results for " + option) + .setFooter("Kiafumi - Maintained by oko.moe") + .setTimestamp(ZonedDateTime.now()); + e.getHook().sendMessageEmbeds(eb.build()).queue(); + return; + } EmbedBuilder eb = new EmbedBuilder() .setColor(Color.PINK) .setTitle(sr.getTitle(), sr.getUrl().toString()) .setDescription(sr.getDescription()) .setFooter("Kiafumi - Maintained by oko.moe") .setTimestamp(ZonedDateTime.now()); - e.replyEmbeds(eb.build()).queue(); + e.getHook().sendMessageEmbeds(eb.build()).queue(); return; //unnecessary, but there. } } @@ -58,7 +71,8 @@ public class DuckCommand extends CommandClass{ public List getSlashCommandInfo() { List cil = new ArrayList<>(); CommandInfo ci = new CommandInfo("search", "Looks up with DuckDuckGo your query!"); - ci.addOption("Query", "The query to be searched", OptionType.STRING, true); + ci.addOption("query", "The query to be searched", OptionType.STRING, true); + cil.add(ci); return cil; } } diff --git a/src/main/java/moe/oko/Kiafumi/command/PingCommand.java b/src/main/java/moe/oko/Kiafumi/command/PingCommand.java index f3fe2c3..7ff251b 100644 --- a/src/main/java/moe/oko/Kiafumi/command/PingCommand.java +++ b/src/main/java/moe/oko/Kiafumi/command/PingCommand.java @@ -42,13 +42,13 @@ public class PingCommand extends CommandClass{ @Override public void newCommand(String name, SlashCommandInteractionEvent e) { - e.deferReply().queue(); switch(name.toLowerCase(Locale.ROOT)) { case "ping": + e.deferReply().queue(); long sentMs = e.getTimeCreated().toInstant().toEpochMilli(); long recMs = System.currentTimeMillis(); long ping = sentMs - recMs; - EmbedBuilder eb = new EmbedBuilder().setColor(new Color(0x6271c1)) + EmbedBuilder eb = new EmbedBuilder().setColor(Color.PINK) .setFooter("ping pong :)").setTitle(getComedy()).setDescription("Pinged " + ping + "ms"); e.getHook().sendMessageEmbeds(eb.build()).queue(); return; diff --git a/src/main/java/moe/oko/Kiafumi/command/SettingCommand.java b/src/main/java/moe/oko/Kiafumi/command/SettingCommand.java index 2d2e52b..187451e 100644 --- a/src/main/java/moe/oko/Kiafumi/command/SettingCommand.java +++ b/src/main/java/moe/oko/Kiafumi/command/SettingCommand.java @@ -48,7 +48,7 @@ public class SettingCommand extends CommandClass { return; case "setting": e.deferReply().queue(); - String opt = e.getOption("Setting Name").getAsString(); + String opt = e.getOption("setting_name").getAsString(); EmbedBuilder eb1 = new EmbedBuilder() .setColor(Color.PINK) .setTitle(opt + " Value") @@ -57,10 +57,10 @@ public class SettingCommand extends CommandClass { .setDescription(server.getOptionByString(opt)); e.getHook().sendMessageEmbeds(eb1.build()).queue(); return; - case "setting set": + case "setting_set": e.deferReply().queue(); - String opt1 = e.getOption("Setting Name").getAsString(); - String opt2 = e.getOption("Setting Value").getAsString(); + String opt1 = e.getOption("setting_name").getAsString(); + String opt2 = e.getOption("setting_value").getAsString(); String response = server.setOptionByString(opt1, opt2); EmbedBuilder eb2 = new EmbedBuilder() .setColor(Color.PINK) @@ -70,9 +70,9 @@ public class SettingCommand extends CommandClass { .setDescription(response); e.getHook().sendMessageEmbeds(eb2.build()).queue(); return; - case "setting clear": + case "setting_clear": e.deferReply().queue(); - String opt3 = e.getOption("Setting Name").getAsString(); + String opt3 = e.getOption("setting_name").getAsString(); String response1 = server.resetOptionByString(opt3); EmbedBuilder eb3 = new EmbedBuilder() .setColor(Color.PINK) @@ -103,16 +103,16 @@ public class SettingCommand extends CommandClass { si.add(ci); CommandInfo ci2 = new CommandInfo("setting", "views the current value for the setting"); - ci2.addOption("Setting Name", "The name of the setting to view", OptionType.STRING, true); + ci2.addOption("setting_name", "The name of the setting to view", OptionType.STRING, true); si.add(ci2); - CommandInfo ci3 = new CommandInfo("setting set", "sets a setting for the guild you are in"); - ci3.addOption("Setting Name", "The name of the setting to modify", OptionType.STRING, true); - ci3.addOption("Setting Value", "The value to set the setting to", OptionType.STRING, true); + CommandInfo ci3 = new CommandInfo("setting_set", "sets a setting for the guild you are in"); + ci3.addOption("setting_name", "The name of the setting to modify", OptionType.STRING, true); + ci3.addOption("setting_value", "The value to set the setting to", OptionType.STRING, true); si.add(ci3); - CommandInfo ci4 = new CommandInfo("setting clear", "reverts a setting back to its default value"); - ci4.addOption("Setting Name", "Name of the setting to clear", OptionType.STRING, true); + CommandInfo ci4 = new CommandInfo("setting_clear", "reverts a setting back to its default value"); + ci4.addOption("setting_name", "Name of the setting to clear", OptionType.STRING, true); si.add(ci4); return si; } diff --git a/src/main/java/moe/oko/Kiafumi/model/KiafumiDB.java b/src/main/java/moe/oko/Kiafumi/model/KiafumiDB.java index 07abfa5..5a3e25b 100644 --- a/src/main/java/moe/oko/Kiafumi/model/KiafumiDB.java +++ b/src/main/java/moe/oko/Kiafumi/model/KiafumiDB.java @@ -121,7 +121,7 @@ public class KiafumiDB { info("Loaded: " + server); servers.add(server); } - return null; + return servers; } catch (Exception ex) { ex.printStackTrace(); error("Failed to load server information, check stack.");