HidekoBot/src/main/java/wtf/beatrice/hidekobot/listeners/ButtonInteractionListener.java

47 lines
1.6 KiB
Java
Raw Permalink Normal View History

package wtf.beatrice.hidekobot.listeners;
import net.dv8tion.jda.api.events.interaction.component.ButtonInteractionEvent;
import net.dv8tion.jda.api.hooks.ListenerAdapter;
2023-01-16 07:20:49 +01:00
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import wtf.beatrice.hidekobot.commands.base.CoinFlip;
2022-12-24 14:48:17 +01:00
import wtf.beatrice.hidekobot.commands.base.Trivia;
2022-12-20 02:17:27 +01:00
import wtf.beatrice.hidekobot.commands.base.UrbanDictionary;
2022-12-20 14:49:44 +01:00
import wtf.beatrice.hidekobot.util.CommandUtil;
public class ButtonInteractionListener extends ListenerAdapter
{
2023-01-16 07:20:49 +01:00
private static final Logger LOGGER = LoggerFactory.getLogger(ButtonInteractionListener.class);
@Override
public void onButtonInteraction(ButtonInteractionEvent event)
{
switch (event.getComponentId().toLowerCase()) {
// coinflip
case "coinflip_reflip" -> CoinFlip.buttonReFlip(event);
2022-11-20 22:23:14 +01:00
2022-12-20 15:04:39 +01:00
// generic dismiss button
case "generic_dismiss" -> CommandUtil.delete(event);
// urban dictionary navigation
case "urban_nextpage" -> UrbanDictionary.changePage(event, UrbanDictionary.ChangeType.NEXT);
case "urban_previouspage" -> UrbanDictionary.changePage(event, UrbanDictionary.ChangeType.PREVIOUS);
2022-12-21 14:24:07 +01:00
// trivia
2022-12-21 23:31:12 +01:00
case "trivia_correct" -> Trivia.handleAnswer(event, Trivia.AnswerType.CORRECT);
2022-12-21 14:24:07 +01:00
case "trivia_wrong_1", "trivia_wrong_2", "trivia_wrong_3" ->
2022-12-21 23:31:12 +01:00
Trivia.handleAnswer(event, Trivia.AnswerType.WRONG);
2022-12-21 14:24:07 +01:00
2023-01-16 07:20:49 +01:00
// error handling
default -> LOGGER.warn("Received unhandled {}", event.getClass().getSimpleName());
}
}
}