diff --git a/src/main/java/wtf/beatrice/hidekobot/listeners/SlashCommandListener.java b/src/main/java/wtf/beatrice/hidekobot/listeners/SlashCommandListener.java index bbab6c7..c055133 100644 --- a/src/main/java/wtf/beatrice/hidekobot/listeners/SlashCommandListener.java +++ b/src/main/java/wtf/beatrice/hidekobot/listeners/SlashCommandListener.java @@ -3,6 +3,7 @@ package wtf.beatrice.hidekobot.listeners; import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent; import net.dv8tion.jda.api.hooks.ListenerAdapter; import org.jetbrains.annotations.NotNull; +import wtf.beatrice.hidekobot.utils.RandomUtil; public class SlashCommandListener extends ListenerAdapter { @@ -10,9 +11,22 @@ public class SlashCommandListener extends ListenerAdapter @Override public void onSlashCommandInteraction(@NotNull SlashCommandInteractionEvent event) { - if(event.getName().equals("ping")) + if (event.getName().equals("ping")) { event.reply("Pong!").queue(); + } else if (event.getName().equals("coinflip")) + { + int rand = RandomUtil.getRandomNumber(0, 1); + String msg; + + if(rand == 1) + { + msg = ":coin: It's **Heads**!"; + } else { + msg = "It's **Tails**! :coin:"; + } + + event.reply(msg).queue(); } } diff --git a/src/main/java/wtf/beatrice/hidekobot/utils/SlashCommandsUtil.java b/src/main/java/wtf/beatrice/hidekobot/utils/SlashCommandsUtil.java index 51c7b50..6c88fae 100644 --- a/src/main/java/wtf/beatrice/hidekobot/utils/SlashCommandsUtil.java +++ b/src/main/java/wtf/beatrice/hidekobot/utils/SlashCommandsUtil.java @@ -17,6 +17,7 @@ public class SlashCommandsUtil static List allCommands = new ArrayList<>() {{ add(Commands.slash("ping", "Test if the bot is responsive.")); + add(Commands.slash("coinflip", "Flip a coin and get head or tails.")); }}; public static void updateSlashCommands(JDA jdaInstance)