diff --git a/src/main/java/cc/fascinated/bat/features/base/BaseFeature.java b/src/main/java/cc/fascinated/bat/features/base/BaseFeature.java index 4bcfcff..5f9c594 100644 --- a/src/main/java/cc/fascinated/bat/features/base/BaseFeature.java +++ b/src/main/java/cc/fascinated/bat/features/base/BaseFeature.java @@ -3,6 +3,7 @@ package cc.fascinated.bat.features.base; import cc.fascinated.bat.features.Feature; import cc.fascinated.bat.features.FeatureProfile; import cc.fascinated.bat.features.base.commands.botadmin.BotAdminCommand; +import cc.fascinated.bat.features.base.commands.fun.CoinFlipCommand; import cc.fascinated.bat.features.base.commands.fun.EightBallCommand; import cc.fascinated.bat.features.base.commands.fun.PPSizeCommand; import cc.fascinated.bat.features.base.commands.fun.image.ImageCommand; @@ -47,5 +48,6 @@ public class BaseFeature extends Feature { super.registerCommand(commandService, context.getBean(LookupCommand.class)); super.registerCommand(commandService, context.getBean(PPSizeCommand.class)); super.registerCommand(commandService, context.getBean(PastebinCommand.class)); + super.registerCommand(commandService, context.getBean(CoinFlipCommand.class)); } } diff --git a/src/main/java/cc/fascinated/bat/features/base/commands/fun/CoinFlipCommand.java b/src/main/java/cc/fascinated/bat/features/base/commands/fun/CoinFlipCommand.java new file mode 100644 index 0000000..c3397a9 --- /dev/null +++ b/src/main/java/cc/fascinated/bat/features/base/commands/fun/CoinFlipCommand.java @@ -0,0 +1,38 @@ +package cc.fascinated.bat.features.base.commands.fun; + +import cc.fascinated.bat.command.BatCommand; +import cc.fascinated.bat.command.CommandInfo; +import cc.fascinated.bat.model.BatGuild; +import cc.fascinated.bat.model.BatUser; +import lombok.NonNull; +import net.dv8tion.jda.api.entities.Member; +import net.dv8tion.jda.api.entities.Message; +import net.dv8tion.jda.api.entities.channel.middleman.MessageChannel; +import net.dv8tion.jda.api.interactions.commands.SlashCommandInteraction; + +import java.util.Random; + +/** + * @author Fascinated (fascinated7) + */ +@CommandInfo( + name = "coinflip", + description = "Flips a coin", + userInstall = true +) +public class CoinFlipCommand extends BatCommand { + @Override + public void execute(BatGuild guild, @NonNull BatUser user, @NonNull MessageChannel channel, Member member, + Message commandMessage, String[] arguments, SlashCommandInteraction event) { + event.reply("%s, you flipped a coin and got **%s**!".formatted(user.getDiscordUser().getAsMention(), flip())).queue(); + } + + /** + * Flips a coin + * + * @return The result of the coin flip + */ + public String flip() { + return new Random().nextBoolean() ? "heads" : "tails"; + } +}