From 16bbda57f617cd764dd9406ea2f417629d568fb7 Mon Sep 17 00:00:00 2001 From: Liam Date: Sat, 6 Jul 2024 19:34:03 +0100 Subject: [PATCH] add ppsize command --- .../bat/features/base/BaseFeature.java | 2 + .../base/commands/fun/PPSizeCommand.java | 46 +++++++++++++++++++ 2 files changed, 48 insertions(+) create mode 100644 src/main/java/cc/fascinated/bat/features/base/commands/fun/PPSizeCommand.java 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 07faad2..14bdc9c 100644 --- a/src/main/java/cc/fascinated/bat/features/base/BaseFeature.java +++ b/src/main/java/cc/fascinated/bat/features/base/BaseFeature.java @@ -4,6 +4,7 @@ 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.EightBallCommand; +import cc.fascinated.bat.features.base.commands.fun.PPSizeCommand; import cc.fascinated.bat.features.base.commands.fun.image.ImageCommand; import cc.fascinated.bat.features.base.commands.general.*; import cc.fascinated.bat.features.base.commands.general.avatar.AvatarCommand; @@ -42,5 +43,6 @@ public class BaseFeature extends Feature { super.registerCommand(commandService, context.getBean(FeatureCommand.class)); super.registerCommand(commandService, context.getBean(EightBallCommand.class)); super.registerCommand(commandService, context.getBean(LookupUserCommand.class)); + super.registerCommand(commandService, context.getBean(PPSizeCommand.class)); } } diff --git a/src/main/java/cc/fascinated/bat/features/base/commands/fun/PPSizeCommand.java b/src/main/java/cc/fascinated/bat/features/base/commands/fun/PPSizeCommand.java new file mode 100644 index 0000000..e6042c2 --- /dev/null +++ b/src/main/java/cc/fascinated/bat/features/base/commands/fun/PPSizeCommand.java @@ -0,0 +1,46 @@ +package cc.fascinated.bat.features.base.commands.fun; + +import cc.fascinated.bat.command.BatCommand; +import cc.fascinated.bat.command.CommandInfo; +import cc.fascinated.bat.common.EmbedDescriptionBuilder; +import cc.fascinated.bat.common.EmbedUtils; +import cc.fascinated.bat.common.MathUtils; +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.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 = "ppsize", + description = "Get the size of your pp", + userInstall = true +) +public class PPSizeCommand extends BatCommand { + public PPSizeCommand() { + super.addOptions(new OptionData(OptionType.USER, "user", "The user you want to get the pp size of", true)); + } + + @Override + public void execute(BatGuild guild, @NonNull BatUser user, @NonNull MessageChannel channel, Member member, @NonNull SlashCommandInteraction event) { + OptionMapping userOption = event.getOption("user"); + assert userOption != null; // This should never be null + Member targetMember = userOption.getAsMember(); + assert targetMember != null; // This should never be null + + event.replyEmbeds(EmbedUtils.genericEmbed() + .setDescription(new EmbedDescriptionBuilder("PP Size") + .appendLine("The size of " + targetMember.getAsMention() + "'s pp is " + (int) (MathUtils.random(1, 8)) + " inches", false) + .build()) + .build()).queue(); + } +}