diff --git a/src/main/java/wtf/beatrice/hidekobot/listeners/ButtonInteractionListener.java b/src/main/java/wtf/beatrice/hidekobot/listeners/ButtonInteractionListener.java index 7a46038..928f826 100644 --- a/src/main/java/wtf/beatrice/hidekobot/listeners/ButtonInteractionListener.java +++ b/src/main/java/wtf/beatrice/hidekobot/listeners/ButtonInteractionListener.java @@ -2,6 +2,8 @@ package wtf.beatrice.hidekobot.listeners; import net.dv8tion.jda.api.events.interaction.component.ButtonInteractionEvent; import net.dv8tion.jda.api.hooks.ListenerAdapter; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import wtf.beatrice.hidekobot.commands.base.CoinFlip; import wtf.beatrice.hidekobot.commands.base.Trivia; import wtf.beatrice.hidekobot.commands.base.UrbanDictionary; @@ -10,6 +12,8 @@ import wtf.beatrice.hidekobot.util.CommandUtil; public class ButtonInteractionListener extends ListenerAdapter { + private static final Logger LOGGER = LoggerFactory.getLogger(ButtonInteractionListener.class); + @Override public void onButtonInteraction(ButtonInteractionEvent event) { @@ -31,6 +35,10 @@ public class ButtonInteractionListener extends ListenerAdapter case "trivia_wrong_1", "trivia_wrong_2", "trivia_wrong_3" -> Trivia.handleAnswer(event, Trivia.AnswerType.WRONG); + // error handling + default -> LOGGER.warn("Received unhandled {}", event.getClass().getSimpleName()); + + } } diff --git a/src/main/java/wtf/beatrice/hidekobot/listeners/SelectMenuInteractionListener.java b/src/main/java/wtf/beatrice/hidekobot/listeners/SelectMenuInteractionListener.java index b74b8bb..6a2c1f8 100644 --- a/src/main/java/wtf/beatrice/hidekobot/listeners/SelectMenuInteractionListener.java +++ b/src/main/java/wtf/beatrice/hidekobot/listeners/SelectMenuInteractionListener.java @@ -2,11 +2,15 @@ package wtf.beatrice.hidekobot.listeners; import net.dv8tion.jda.api.events.interaction.component.StringSelectInteractionEvent; import net.dv8tion.jda.api.hooks.ListenerAdapter; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import wtf.beatrice.hidekobot.commands.base.Trivia; public class SelectMenuInteractionListener extends ListenerAdapter { + private static final Logger LOGGER = LoggerFactory.getLogger(SelectMenuInteractionListener.class); + @Override public void onStringSelectInteraction(StringSelectInteractionEvent event) { @@ -14,6 +18,9 @@ public class SelectMenuInteractionListener extends ListenerAdapter // trivia case "trivia_categories" -> Trivia.handleMenuSelection(event); + + // error handling + default -> LOGGER.warn("Received unhandled {}", event.getClass().getSimpleName()); } } } diff --git a/src/main/java/wtf/beatrice/hidekobot/util/FormatUtil.java b/src/main/java/wtf/beatrice/hidekobot/util/FormatUtil.java index 2056dab..14ceca1 100644 --- a/src/main/java/wtf/beatrice/hidekobot/util/FormatUtil.java +++ b/src/main/java/wtf/beatrice/hidekobot/util/FormatUtil.java @@ -148,7 +148,7 @@ public class FormatUtil // we won't do any sanitization, because this is a private method, and // we are only accessing it with things that we know for sure are already sanitized. unitName = unitName.toLowerCase(); - TemporalUnit timeUnit = null; + TemporalUnit timeUnit; /* parsing table @@ -166,6 +166,7 @@ public class FormatUtil case "m", "mi", "min", "minute", "minutes" -> timeUnit = ChronoUnit.MINUTES; case "h", "ho", "hr", "hour", "hours" -> timeUnit = ChronoUnit.HOURS; case "d", "day", "days" -> timeUnit = ChronoUnit.DAYS; + default -> timeUnit = null; } return timeUnit;