From 7f935da4b4f34529f3a4e83d4aad3fe8019b6cb4 Mon Sep 17 00:00:00 2001 From: Lee Date: Wed, 15 Jan 2025 18:03:42 +0000 Subject: [PATCH] add nerddetector command --- .../cc/fascinated/bat/base/BaseFeature.java | 6 +-- .../commands/fun/NerdDetectorCommand.java | 52 +++++++++++++++++++ .../bat/base/commands/fun/PPSizeCommand.java | 5 +- 3 files changed, 56 insertions(+), 7 deletions(-) create mode 100644 src/main/java/cc/fascinated/bat/base/commands/fun/NerdDetectorCommand.java diff --git a/src/main/java/cc/fascinated/bat/base/BaseFeature.java b/src/main/java/cc/fascinated/bat/base/BaseFeature.java index 3e39fcc..48872e9 100644 --- a/src/main/java/cc/fascinated/bat/base/BaseFeature.java +++ b/src/main/java/cc/fascinated/bat/base/BaseFeature.java @@ -1,12 +1,9 @@ package cc.fascinated.bat.base; -import cc.fascinated.bat.base.commands.fun.HowGayCommand; +import cc.fascinated.bat.base.commands.fun.*; import cc.fascinated.bat.common.feature.Feature; import cc.fascinated.bat.common.feature.FeatureProfile; import cc.fascinated.bat.base.commands.botadmin.BotAdminCommand; -import cc.fascinated.bat.base.commands.fun.CoinFlipCommand; -import cc.fascinated.bat.base.commands.fun.EightBallCommand; -import cc.fascinated.bat.base.commands.fun.PPSizeCommand; import cc.fascinated.bat.base.commands.fun.image.ImageCommand; import cc.fascinated.bat.base.commands.general.*; import cc.fascinated.bat.base.commands.general.avatar.AvatarCommand; @@ -51,5 +48,6 @@ public class BaseFeature extends Feature { super.registerCommand(commandService, context.getBean(PastebinCommand.class)); super.registerCommand(commandService, context.getBean(CoinFlipCommand.class)); super.registerCommand(commandService, context.getBean(HowGayCommand.class)); + super.registerCommand(commandService, context.getBean(NerdDetectorCommand.class)); } } diff --git a/src/main/java/cc/fascinated/bat/base/commands/fun/NerdDetectorCommand.java b/src/main/java/cc/fascinated/bat/base/commands/fun/NerdDetectorCommand.java new file mode 100644 index 0000000..89b3c07 --- /dev/null +++ b/src/main/java/cc/fascinated/bat/base/commands/fun/NerdDetectorCommand.java @@ -0,0 +1,52 @@ +package cc.fascinated.bat.base.commands.fun; + +import cc.fascinated.bat.common.DescriptionBuilder; +import cc.fascinated.bat.common.EmbedUtils; +import cc.fascinated.bat.common.MathUtils; +import cc.fascinated.bat.common.command.BatCommand; +import cc.fascinated.bat.common.command.Category; +import cc.fascinated.bat.common.command.CommandInfo; +import cc.fascinated.bat.common.model.BatGuild; +import cc.fascinated.bat.common.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.User; +import net.dv8tion.jda.api.entities.channel.middleman.MessageChannel; +import net.dv8tion.jda.api.interactions.commands.OptionMapping; +import net.dv8tion.jda.api.interactions.commands.OptionType; +import net.dv8tion.jda.api.interactions.commands.SlashCommandInteraction; +import net.dv8tion.jda.api.interactions.commands.build.OptionData; +import org.springframework.stereotype.Component; + +/** + * @author Fascinated (fascinated7) + */ +@Component +@CommandInfo( + name = "nerddetector", + description = "Checks how much of a nerd someone is", + userInstall = true, + category = Category.FUN +) +public class NerdDetectorCommand extends BatCommand { + public NerdDetectorCommand() { + super.addOptions(new OptionData(OptionType.USER, "user", "The user you want to check how much of a nerd they are", true)); + } + + @Override + public void execute(BatGuild guild, @NonNull BatUser user, @NonNull MessageChannel channel, Member member, Message commandMessage, String[] arguments, SlashCommandInteraction event) { + OptionMapping userOption = event.getOption("user"); + assert userOption != null; // This should never be null + User target = userOption.getAsUser(); + + event.replyEmbeds(EmbedUtils.genericEmbed() + .setDescription(new DescriptionBuilder("Nerd Detector") + .appendLine("%s is %s%% nerd 🤓".formatted( + target.getAsMention(), + (int) MathUtils.random(0, 100) + ), false) + .build()) + .build()).queue(); + } +} diff --git a/src/main/java/cc/fascinated/bat/base/commands/fun/PPSizeCommand.java b/src/main/java/cc/fascinated/bat/base/commands/fun/PPSizeCommand.java index 2363e04..41c6ad3 100644 --- a/src/main/java/cc/fascinated/bat/base/commands/fun/PPSizeCommand.java +++ b/src/main/java/cc/fascinated/bat/base/commands/fun/PPSizeCommand.java @@ -30,8 +30,6 @@ import org.springframework.stereotype.Component; category = Category.FUN ) public class PPSizeCommand extends BatCommand { - private final int maxSize = 12; - private final int minSize = 1; public PPSizeCommand() { super.addOptions(new OptionData(OptionType.USER, "user", "The user you want to get the pp size of", true)); @@ -43,7 +41,8 @@ public class PPSizeCommand extends BatCommand { assert userOption != null; // This should never be null User target = userOption.getAsUser(); - int size = (int) MathUtils.random(minSize, maxSize); + int maxSize = 12; + int size = (int) MathUtils.random(1, maxSize); event.replyEmbeds(EmbedUtils.genericEmbed() .setDescription(new DescriptionBuilder("PP Size") .appendLine("""