Add coinflip slash command
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
fb69dcd863
commit
b43b882cab
@ -3,6 +3,7 @@ package wtf.beatrice.hidekobot.listeners;
|
|||||||
import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent;
|
import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent;
|
||||||
import net.dv8tion.jda.api.hooks.ListenerAdapter;
|
import net.dv8tion.jda.api.hooks.ListenerAdapter;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import wtf.beatrice.hidekobot.utils.RandomUtil;
|
||||||
|
|
||||||
public class SlashCommandListener extends ListenerAdapter
|
public class SlashCommandListener extends ListenerAdapter
|
||||||
{
|
{
|
||||||
@ -13,6 +14,19 @@ public class SlashCommandListener extends ListenerAdapter
|
|||||||
if (event.getName().equals("ping"))
|
if (event.getName().equals("ping"))
|
||||||
{
|
{
|
||||||
event.reply("Pong!").queue();
|
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();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -17,6 +17,7 @@ public class SlashCommandsUtil
|
|||||||
static List<CommandData> allCommands = new ArrayList<>()
|
static List<CommandData> allCommands = new ArrayList<>()
|
||||||
{{
|
{{
|
||||||
add(Commands.slash("ping", "Test if the bot is responsive."));
|
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)
|
public static void updateSlashCommands(JDA jdaInstance)
|
||||||
|
Loading…
Reference in New Issue
Block a user