2022-11-20 22:09:58 +01:00
|
|
|
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;
|
2022-11-22 20:50:37 +01:00
|
|
|
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;
|
2022-11-20 22:09:58 +01:00
|
|
|
|
|
|
|
public class ButtonInteractionListener extends ListenerAdapter
|
|
|
|
{
|
|
|
|
|
2023-01-16 07:20:49 +01:00
|
|
|
private static final Logger LOGGER = LoggerFactory.getLogger(ButtonInteractionListener.class);
|
|
|
|
|
2022-11-20 22:09:58 +01:00
|
|
|
@Override
|
|
|
|
public void onButtonInteraction(ButtonInteractionEvent event)
|
|
|
|
{
|
|
|
|
|
|
|
|
switch (event.getComponentId().toLowerCase()) {
|
|
|
|
|
|
|
|
// coinflip
|
2022-11-22 20:50:37 +01:00
|
|
|
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);
|
2022-11-20 22:09:58 +01:00
|
|
|
|
2022-12-20 00:34:49 +01:00
|
|
|
// urban dictionary navigation
|
2022-12-20 15:09:35 +01:00
|
|
|
case "urban_nextpage" -> UrbanDictionary.changePage(event, UrbanDictionary.ChangeType.NEXT);
|
|
|
|
case "urban_previouspage" -> UrbanDictionary.changePage(event, UrbanDictionary.ChangeType.PREVIOUS);
|
2022-12-20 00:34:49 +01:00
|
|
|
|
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());
|
|
|
|
|
|
|
|
|
2022-11-20 22:09:58 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|