fix pp size for not in guild

This commit is contained in:
Lee 2024-07-06 19:41:16 +01:00
parent b63b25f8ab
commit d0ba6e72a4

@ -9,6 +9,7 @@ import cc.fascinated.bat.model.BatGuild;
import cc.fascinated.bat.model.BatUser; import cc.fascinated.bat.model.BatUser;
import lombok.NonNull; import lombok.NonNull;
import net.dv8tion.jda.api.entities.Member; import net.dv8tion.jda.api.entities.Member;
import net.dv8tion.jda.api.entities.User;
import net.dv8tion.jda.api.entities.channel.middleman.MessageChannel; import net.dv8tion.jda.api.entities.channel.middleman.MessageChannel;
import net.dv8tion.jda.api.interactions.commands.OptionMapping; import net.dv8tion.jda.api.interactions.commands.OptionMapping;
import net.dv8tion.jda.api.interactions.commands.OptionType; import net.dv8tion.jda.api.interactions.commands.OptionType;
@ -34,8 +35,7 @@ public class PPSizeCommand extends BatCommand {
public void execute(BatGuild guild, @NonNull BatUser user, @NonNull MessageChannel channel, Member member, @NonNull SlashCommandInteraction event) { public void execute(BatGuild guild, @NonNull BatUser user, @NonNull MessageChannel channel, Member member, @NonNull SlashCommandInteraction event) {
OptionMapping userOption = event.getOption("user"); OptionMapping userOption = event.getOption("user");
assert userOption != null; // This should never be null assert userOption != null; // This should never be null
Member targetMember = userOption.getAsMember(); User target = userOption.getAsUser();
assert targetMember != null; // This should never be null
int size = (int) MathUtils.random(1, 12); int size = (int) MathUtils.random(1, 12);
event.replyEmbeds(EmbedUtils.genericEmbed() event.replyEmbeds(EmbedUtils.genericEmbed()
@ -44,7 +44,7 @@ public class PPSizeCommand extends BatCommand {
The size of %s's pp is %s inches The size of %s's pp is %s inches
**8%sD** **8%sD**
""".formatted( """.formatted(
targetMember.getAsMention(), target.getAsMention(),
size, size,
"=".repeat(size) "=".repeat(size)
), false) ), false)