Add coinflip slash command
continuous-integration/drone/push Build is passing Details

This commit is contained in:
Bea 2022-11-20 03:07:43 +01:00
parent fb69dcd863
commit b43b882cab
2 changed files with 16 additions and 1 deletions

View File

@ -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();
}
}

View File

@ -17,6 +17,7 @@ public class SlashCommandsUtil
static List<CommandData> 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)