From 2a7e2acc881190d17c3f96a180e2c01868d4bbd4 Mon Sep 17 00:00:00 2001 From: Liam Date: Sun, 7 Jul 2024 02:18:10 +0100 Subject: [PATCH] cleanup --- .../features/autorole/command/AddSubCommand.java | 7 +------ .../features/autorole/command/RemoveSubCommand.java | 7 +------ .../fascinated/bat/features/base/BaseFeature.java | 3 +-- .../base/commands/fun/EightBallCommand.java | 5 ++--- .../commands/general/avatar/GuildSubCommand.java | 1 - .../commands/general/avatar/UserSubCommand.java | 10 ++-------- .../commands/general/banner/UserSubCommand.java | 9 +-------- .../commands/utility/lookup/UserSubCommand.java | 1 - .../birthday/command/MessageSubCommand.java | 9 ++------- .../birthday/command/PrivateSubCommand.java | 9 ++------- .../features/birthday/command/SetSubCommand.java | 8 ++------ .../features/counter/command/RemoveSubCommand.java | 4 +--- .../counter/command/SetBreakingSubCommand.java | 6 +++--- .../bat/features/counter/command/SetSubCommand.java | 6 +++--- .../features/counter/command/SetupSubCommand.java | 5 ++--- .../features/drag/command/RequestSubCommand.java | 2 +- .../leveling/command/ChannelSubCommand.java | 5 ++--- .../features/leveling/command/ResetSubCommand.java | 5 ++--- .../features/logging/command/RemoveSubCommand.java | 5 ++--- .../bat/features/logging/command/SetSubCommand.java | 9 +++------ .../command/minecraft/LookupPlayerSubCommand.java | 6 ++---- .../command/minecraft/LookupServerSubCommand.java | 7 +++---- .../command/serverwatcher/AddSubCommand.java | 8 ++++---- .../command/serverwatcher/RemoveSubCommand.java | 6 +++--- .../features/moderation/command/PurgeCommand.java | 5 ++--- .../features/reminder/command/SetSubCommand.java | 8 ++------ .../command/scoresaber/LinkSubCommand.java | 13 +++---------- .../command/scoresaber/UserSubCommand.java | 9 ++++----- 28 files changed, 56 insertions(+), 122 deletions(-) diff --git a/src/main/java/cc/fascinated/bat/features/autorole/command/AddSubCommand.java b/src/main/java/cc/fascinated/bat/features/autorole/command/AddSubCommand.java index 5c2da44..708b014 100644 --- a/src/main/java/cc/fascinated/bat/features/autorole/command/AddSubCommand.java +++ b/src/main/java/cc/fascinated/bat/features/autorole/command/AddSubCommand.java @@ -43,12 +43,7 @@ public class AddSubCommand extends BatCommand { } OptionMapping option = event.getOption("role"); - if (option == null) { - event.replyEmbeds(EmbedUtils.errorEmbed() - .setDescription("Please provide a role to add") - .build()).queue(); - return; - } + assert option != null; Role role = option.getAsRole(); // Check if the role is already in the auto roles list diff --git a/src/main/java/cc/fascinated/bat/features/autorole/command/RemoveSubCommand.java b/src/main/java/cc/fascinated/bat/features/autorole/command/RemoveSubCommand.java index ec32401..e0d1b0a 100644 --- a/src/main/java/cc/fascinated/bat/features/autorole/command/RemoveSubCommand.java +++ b/src/main/java/cc/fascinated/bat/features/autorole/command/RemoveSubCommand.java @@ -32,12 +32,7 @@ public class RemoveSubCommand extends BatCommand { public void execute(BatGuild guild, @NonNull BatUser user, @NonNull MessageChannel channel, Member member, @NonNull SlashCommandInteraction event) { AutoRoleProfile profile = guild.getProfile(AutoRoleProfile.class); OptionMapping option = event.getOption("role"); - if (option == null) { - event.replyEmbeds(EmbedUtils.errorEmbed() - .setDescription("Please provide a role to remove") - .build()).queue(); - return; - } + assert option != null; Role role = option.getAsRole(); if (!profile.hasRole(role.getId())) { 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 ef95d16..4bcfcff 100644 --- a/src/main/java/cc/fascinated/bat/features/base/BaseFeature.java +++ b/src/main/java/cc/fascinated/bat/features/base/BaseFeature.java @@ -9,13 +9,12 @@ 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; import cc.fascinated.bat.features.base.commands.general.banner.BannerCommand; -import cc.fascinated.bat.features.base.commands.utility.lookup.LookupCommand; -import cc.fascinated.bat.features.base.commands.utility.lookup.UserSubCommand; import cc.fascinated.bat.features.base.commands.server.MemberCountCommand; import cc.fascinated.bat.features.base.commands.server.PremiumCommand; import cc.fascinated.bat.features.base.commands.server.channel.ChannelCommand; import cc.fascinated.bat.features.base.commands.server.feature.FeatureCommand; import cc.fascinated.bat.features.base.commands.utility.PastebinCommand; +import cc.fascinated.bat.features.base.commands.utility.lookup.LookupCommand; import cc.fascinated.bat.service.CommandService; import lombok.NonNull; import org.springframework.beans.factory.annotation.Autowired; diff --git a/src/main/java/cc/fascinated/bat/features/base/commands/fun/EightBallCommand.java b/src/main/java/cc/fascinated/bat/features/base/commands/fun/EightBallCommand.java index a84f4fd..f2ff0ca 100644 --- a/src/main/java/cc/fascinated/bat/features/base/commands/fun/EightBallCommand.java +++ b/src/main/java/cc/fascinated/bat/features/base/commands/fun/EightBallCommand.java @@ -51,11 +51,10 @@ public class EightBallCommand extends BatCommand { @Override public void execute(BatGuild guild, @NonNull BatUser user, @NonNull MessageChannel channel, Member member, @NonNull SlashCommandInteraction event) { OptionMapping questionOption = event.getOption("question"); - if (questionOption == null) { - return; - } + assert questionOption != null; String question = questionOption.getAsString(); String response = responses[(int) (Math.random() * responses.length)]; + event.replyEmbeds(EmbedUtils.successEmbed() .setDescription("You asked: `%s`\n\n:8ball: The magic 8ball says: `%s`".formatted(question, response)) .build()) diff --git a/src/main/java/cc/fascinated/bat/features/base/commands/general/avatar/GuildSubCommand.java b/src/main/java/cc/fascinated/bat/features/base/commands/general/avatar/GuildSubCommand.java index c7a7b9c..ec8dc71 100644 --- a/src/main/java/cc/fascinated/bat/features/base/commands/general/avatar/GuildSubCommand.java +++ b/src/main/java/cc/fascinated/bat/features/base/commands/general/avatar/GuildSubCommand.java @@ -22,7 +22,6 @@ public class GuildSubCommand extends BatCommand { @Override public void execute(BatGuild guild, @NonNull BatUser user, @NonNull MessageChannel channel, Member member, @NonNull SlashCommandInteraction event) { ImageProxy icon = guild.getDiscordGuild().getIcon(); - if (icon == null) { event.replyEmbeds(EmbedUtils.errorEmbed() .setDescription("**%s** does not have an avatar!".formatted(guild.getName())) diff --git a/src/main/java/cc/fascinated/bat/features/base/commands/general/avatar/UserSubCommand.java b/src/main/java/cc/fascinated/bat/features/base/commands/general/avatar/UserSubCommand.java index 9cc7365..40b9753 100644 --- a/src/main/java/cc/fascinated/bat/features/base/commands/general/avatar/UserSubCommand.java +++ b/src/main/java/cc/fascinated/bat/features/base/commands/general/avatar/UserSubCommand.java @@ -29,15 +29,9 @@ public class UserSubCommand extends BatCommand { @Override public void execute(BatGuild guild, @NonNull BatUser user, @NonNull MessageChannel channel, Member member, @NonNull SlashCommandInteraction event) { OptionMapping userOption = event.getOption("user"); - if (userOption == null) { - event.replyEmbeds(EmbedUtils.errorEmbed() - .setDescription("You must provide a user to view the avatar of!") - .build()) - .queue(); - return; - } - + assert userOption != null; User target = userOption.getAsUser(); + event.replyEmbeds(EmbedUtils.genericEmbed() .setAuthor("%s's Avatar".formatted(target.getName()), null, target.getEffectiveAvatarUrl()) .setImage(target.getEffectiveAvatarUrl()) diff --git a/src/main/java/cc/fascinated/bat/features/base/commands/general/banner/UserSubCommand.java b/src/main/java/cc/fascinated/bat/features/base/commands/general/banner/UserSubCommand.java index f873ca8..641d49d 100644 --- a/src/main/java/cc/fascinated/bat/features/base/commands/general/banner/UserSubCommand.java +++ b/src/main/java/cc/fascinated/bat/features/base/commands/general/banner/UserSubCommand.java @@ -30,14 +30,7 @@ public class UserSubCommand extends BatCommand { @Override public void execute(BatGuild guild, @NonNull BatUser user, @NonNull MessageChannel channel, Member member, @NonNull SlashCommandInteraction event) { OptionMapping userOption = event.getOption("user"); - if (userOption == null) { - event.replyEmbeds(EmbedUtils.errorEmbed() - .setDescription("You must provide a user to view the banner of!") - .build()) - .queue(); - return; - } - + assert userOption != null; User target = userOption.getAsUser(); ImageProxy banner = target.retrieveProfile().complete().getBanner(); if (banner == null) { diff --git a/src/main/java/cc/fascinated/bat/features/base/commands/utility/lookup/UserSubCommand.java b/src/main/java/cc/fascinated/bat/features/base/commands/utility/lookup/UserSubCommand.java index e00539d..7af6398 100644 --- a/src/main/java/cc/fascinated/bat/features/base/commands/utility/lookup/UserSubCommand.java +++ b/src/main/java/cc/fascinated/bat/features/base/commands/utility/lookup/UserSubCommand.java @@ -1,7 +1,6 @@ package cc.fascinated.bat.features.base.commands.utility.lookup; import cc.fascinated.bat.command.BatCommand; -import cc.fascinated.bat.command.Category; import cc.fascinated.bat.command.CommandInfo; import cc.fascinated.bat.common.EmbedDescriptionBuilder; import cc.fascinated.bat.common.EmbedUtils; diff --git a/src/main/java/cc/fascinated/bat/features/birthday/command/MessageSubCommand.java b/src/main/java/cc/fascinated/bat/features/birthday/command/MessageSubCommand.java index d4145ed..051456b 100644 --- a/src/main/java/cc/fascinated/bat/features/birthday/command/MessageSubCommand.java +++ b/src/main/java/cc/fascinated/bat/features/birthday/command/MessageSubCommand.java @@ -33,14 +33,9 @@ public class MessageSubCommand extends BatCommand { public void execute(BatGuild guild, @NonNull BatUser user, @NonNull MessageChannel channel, Member member, @NonNull SlashCommandInteraction event) { BirthdayProfile profile = guild.getBirthdayProfile(); OptionMapping messageOption = event.getOption("message"); - if (messageOption == null) { - event.replyEmbeds(EmbedUtils.errorEmbed() - .setDescription("You must provide a message") - .build()).queue(); - return; - } - + assert messageOption != null; String message = messageOption.getAsString(); + if (message.length() > 2000) { event.replyEmbeds(EmbedUtils.errorEmbed() .setDescription("The message must be less than 2000 characters") diff --git a/src/main/java/cc/fascinated/bat/features/birthday/command/PrivateSubCommand.java b/src/main/java/cc/fascinated/bat/features/birthday/command/PrivateSubCommand.java index 7c07259..ae27de4 100644 --- a/src/main/java/cc/fascinated/bat/features/birthday/command/PrivateSubCommand.java +++ b/src/main/java/cc/fascinated/bat/features/birthday/command/PrivateSubCommand.java @@ -33,14 +33,9 @@ public class PrivateSubCommand extends BatCommand { public void execute(BatGuild guild, @NonNull BatUser user, @NonNull MessageChannel channel, Member member, @NonNull SlashCommandInteraction event) { BirthdayProfile profile = guild.getBirthdayProfile(); OptionMapping enabledOption = event.getOption("enabled"); - if (enabledOption == null) { - event.replyEmbeds(EmbedUtils.errorEmbed() - .setDescription("You must provide whether your birthday is private or not") - .build()).queue(); - return; - } - + assert enabledOption != null; boolean enabled = enabledOption.getAsBoolean(); + UserBirthday birthday = profile.getBirthday(user.getId()); if (birthday == null) { event.replyEmbeds(EmbedUtils.errorEmbed() diff --git a/src/main/java/cc/fascinated/bat/features/birthday/command/SetSubCommand.java b/src/main/java/cc/fascinated/bat/features/birthday/command/SetSubCommand.java index 9c335a8..6cd3ce0 100644 --- a/src/main/java/cc/fascinated/bat/features/birthday/command/SetSubCommand.java +++ b/src/main/java/cc/fascinated/bat/features/birthday/command/SetSubCommand.java @@ -46,13 +46,9 @@ public class SetSubCommand extends BatCommand { } OptionMapping birthdayOption = event.getOption("birthday"); - if (birthdayOption == null) { - event.replyEmbeds(EmbedUtils.errorEmbed() - .setDescription("You must provide a birthday") - .build()).queue(); - return; - } + assert birthdayOption != null; String birthdayString = birthdayOption.getAsString(); + Date birthday = parseBirthday(birthdayString); if (birthday == null) { event.replyEmbeds(EmbedUtils.errorEmbed() diff --git a/src/main/java/cc/fascinated/bat/features/counter/command/RemoveSubCommand.java b/src/main/java/cc/fascinated/bat/features/counter/command/RemoveSubCommand.java index 01e400d..7b21beb 100644 --- a/src/main/java/cc/fascinated/bat/features/counter/command/RemoveSubCommand.java +++ b/src/main/java/cc/fascinated/bat/features/counter/command/RemoveSubCommand.java @@ -34,9 +34,7 @@ public class RemoveSubCommand extends BatCommand { @Override public void execute(BatGuild guild, @NonNull BatUser user, @NonNull MessageChannel channel, Member member, @NonNull SlashCommandInteraction event) { OptionMapping channelOption = event.getOption("channel"); - if (channelOption == null) { - return; - } + assert channelOption != null; GuildChannelUnion targetChannel = channelOption.getAsChannel(); if (targetChannel.getType() != ChannelType.TEXT) { event.replyEmbeds(EmbedUtils.errorEmbed() diff --git a/src/main/java/cc/fascinated/bat/features/counter/command/SetBreakingSubCommand.java b/src/main/java/cc/fascinated/bat/features/counter/command/SetBreakingSubCommand.java index 594cd79..d4aa1e7 100644 --- a/src/main/java/cc/fascinated/bat/features/counter/command/SetBreakingSubCommand.java +++ b/src/main/java/cc/fascinated/bat/features/counter/command/SetBreakingSubCommand.java @@ -34,10 +34,10 @@ public class SetBreakingSubCommand extends BatCommand { @Override public void execute(BatGuild guild, @NonNull BatUser user, @NonNull MessageChannel channel, Member member, @NonNull SlashCommandInteraction event) { OptionMapping channelOption = event.getOption("channel"); + assert channelOption != null; OptionMapping breakableOption = event.getOption("breakable"); - if (channelOption == null || breakableOption == null) { - return; - } + assert breakableOption != null; + GuildChannelUnion targetChannel = channelOption.getAsChannel(); if (targetChannel.getType() != ChannelType.TEXT) { event.replyEmbeds(EmbedUtils.errorEmbed() diff --git a/src/main/java/cc/fascinated/bat/features/counter/command/SetSubCommand.java b/src/main/java/cc/fascinated/bat/features/counter/command/SetSubCommand.java index 3baed77..637ef09 100644 --- a/src/main/java/cc/fascinated/bat/features/counter/command/SetSubCommand.java +++ b/src/main/java/cc/fascinated/bat/features/counter/command/SetSubCommand.java @@ -34,10 +34,10 @@ public class SetSubCommand extends BatCommand { @Override public void execute(BatGuild guild, @NonNull BatUser user, @NonNull MessageChannel channel, Member member, @NonNull SlashCommandInteraction event) { OptionMapping channelOption = event.getOption("channel"); + assert channelOption != null; OptionMapping countOption = event.getOption("count"); - if (channelOption == null || countOption == null) { - return; - } + assert countOption != null; + GuildChannelUnion targetChannel = channelOption.getAsChannel(); if (targetChannel.getType() != ChannelType.TEXT) { event.replyEmbeds(EmbedUtils.errorEmbed() diff --git a/src/main/java/cc/fascinated/bat/features/counter/command/SetupSubCommand.java b/src/main/java/cc/fascinated/bat/features/counter/command/SetupSubCommand.java index 9180637..ee64ac0 100644 --- a/src/main/java/cc/fascinated/bat/features/counter/command/SetupSubCommand.java +++ b/src/main/java/cc/fascinated/bat/features/counter/command/SetupSubCommand.java @@ -33,10 +33,9 @@ public class SetupSubCommand extends BatCommand { @Override public void execute(BatGuild guild, @NonNull BatUser user, @NonNull MessageChannel channel, Member member, @NonNull SlashCommandInteraction event) { OptionMapping channelOption = event.getOption("channel"); + assert channelOption != null; OptionMapping breakableOption = event.getOption("breakable"); - if (channelOption == null || breakableOption == null) { - return; - } + assert breakableOption != null; GuildChannelUnion targetChannel = channelOption.getAsChannel(); if (targetChannel.getType() != ChannelType.TEXT) { diff --git a/src/main/java/cc/fascinated/bat/features/drag/command/RequestSubCommand.java b/src/main/java/cc/fascinated/bat/features/drag/command/RequestSubCommand.java index f04caab..40be297 100644 --- a/src/main/java/cc/fascinated/bat/features/drag/command/RequestSubCommand.java +++ b/src/main/java/cc/fascinated/bat/features/drag/command/RequestSubCommand.java @@ -77,7 +77,7 @@ public class RequestSubCommand extends BatCommand implements EventListener { } OptionMapping userOption = event.getOption("user"); - if (userOption == null) return; + assert userOption != null; // Check if the user is in a voice channel Member target = userOption.getAsMember(); diff --git a/src/main/java/cc/fascinated/bat/features/leveling/command/ChannelSubCommand.java b/src/main/java/cc/fascinated/bat/features/leveling/command/ChannelSubCommand.java index fc9c92e..98bde4b 100644 --- a/src/main/java/cc/fascinated/bat/features/leveling/command/ChannelSubCommand.java +++ b/src/main/java/cc/fascinated/bat/features/leveling/command/ChannelSubCommand.java @@ -37,9 +37,8 @@ public class ChannelSubCommand extends BatCommand { @Override public void execute(BatGuild guild, @NonNull BatUser user, @NonNull MessageChannel channel, Member member, @NonNull SlashCommandInteraction event) { OptionMapping channelOption = event.getOption("channel"); - if (channelOption == null) { - return; - } + assert channelOption != null; + GuildChannelUnion channelUnion = channelOption.getAsChannel(); TextChannel textChannel = channelUnion.asTextChannel(); LevelingProfile profile = guild.getLevelingProfile(); diff --git a/src/main/java/cc/fascinated/bat/features/leveling/command/ResetSubCommand.java b/src/main/java/cc/fascinated/bat/features/leveling/command/ResetSubCommand.java index 999b2d3..33d2699 100644 --- a/src/main/java/cc/fascinated/bat/features/leveling/command/ResetSubCommand.java +++ b/src/main/java/cc/fascinated/bat/features/leveling/command/ResetSubCommand.java @@ -37,9 +37,8 @@ public class ResetSubCommand extends BatCommand { @Override public void execute(BatGuild guild, @NonNull BatUser user, @NonNull MessageChannel channel, Member member, @NonNull SlashCommandInteraction event) { OptionMapping userOption = event.getOption("user"); - if (userOption == null) { - return; - } + assert userOption != null; + User target = userOption.getAsUser(); LevelingProfile profile = guild.getLevelingProfile(); UserLevel level = profile.getUserLevel(target.getId()); diff --git a/src/main/java/cc/fascinated/bat/features/logging/command/RemoveSubCommand.java b/src/main/java/cc/fascinated/bat/features/logging/command/RemoveSubCommand.java index 5eb11b1..67b6afc 100644 --- a/src/main/java/cc/fascinated/bat/features/logging/command/RemoveSubCommand.java +++ b/src/main/java/cc/fascinated/bat/features/logging/command/RemoveSubCommand.java @@ -34,9 +34,8 @@ public class RemoveSubCommand extends BatCommand { @Override public void execute(BatGuild guild, @NonNull BatUser user, @NonNull MessageChannel channel, Member member, @NonNull SlashCommandInteraction event) { OptionMapping typeOption = event.getOption("type"); - if (typeOption == null) { - return; - } + assert typeOption != null; + String type = typeOption.getAsString(); LogProfile profile = guild.getLogProfile(); diff --git a/src/main/java/cc/fascinated/bat/features/logging/command/SetSubCommand.java b/src/main/java/cc/fascinated/bat/features/logging/command/SetSubCommand.java index 588c236..e0fb942 100644 --- a/src/main/java/cc/fascinated/bat/features/logging/command/SetSubCommand.java +++ b/src/main/java/cc/fascinated/bat/features/logging/command/SetSubCommand.java @@ -38,13 +38,10 @@ public class SetSubCommand extends BatCommand { @Override public void execute(BatGuild guild, @NonNull BatUser user, @NonNull MessageChannel channel, Member member, @NonNull SlashCommandInteraction event) { OptionMapping typeOption = event.getOption("type"); - if (typeOption == null) { - return; - } + assert typeOption != null; OptionMapping channelOption = event.getOption("channel"); - if (channelOption == null) { - return; - } + assert channelOption != null; + String type = typeOption.getAsString(); TextChannel targetChannel = channelOption.getAsChannel().asTextChannel(); LogProfile profile = guild.getLogProfile(); diff --git a/src/main/java/cc/fascinated/bat/features/minecraft/command/minecraft/LookupPlayerSubCommand.java b/src/main/java/cc/fascinated/bat/features/minecraft/command/minecraft/LookupPlayerSubCommand.java index 2f4905f..ff12224 100644 --- a/src/main/java/cc/fascinated/bat/features/minecraft/command/minecraft/LookupPlayerSubCommand.java +++ b/src/main/java/cc/fascinated/bat/features/minecraft/command/minecraft/LookupPlayerSubCommand.java @@ -36,11 +36,9 @@ public class LookupPlayerSubCommand extends BatCommand { @Override public void execute(BatGuild guild, @NonNull BatUser user, @NonNull MessageChannel channel, Member member, @NonNull SlashCommandInteraction event) { OptionMapping playerOption = event.getOption("player"); - if (playerOption == null) { - return; - } - String player = playerOption.getAsString(); + assert playerOption != null; + String player = playerOption.getAsString(); CachedPlayer cachedPlayer = McUtilsAPI.getPlayer(player); if (cachedPlayer == null) { event.reply("The player `%s` could not be found".formatted(player)).queue(); diff --git a/src/main/java/cc/fascinated/bat/features/minecraft/command/minecraft/LookupServerSubCommand.java b/src/main/java/cc/fascinated/bat/features/minecraft/command/minecraft/LookupServerSubCommand.java index d9323b2..df43db9 100644 --- a/src/main/java/cc/fascinated/bat/features/minecraft/command/minecraft/LookupServerSubCommand.java +++ b/src/main/java/cc/fascinated/bat/features/minecraft/command/minecraft/LookupServerSubCommand.java @@ -40,13 +40,12 @@ public class LookupServerSubCommand extends BatCommand { @Override public void execute(BatGuild guild, @NonNull BatUser user, @NonNull MessageChannel channel, Member member, @NonNull SlashCommandInteraction event) { OptionMapping platformOption = event.getOption("platform"); + assert platformOption != null; OptionMapping hostOption = event.getOption("host"); - if (platformOption == null || hostOption == null) { - return; - } + assert hostOption != null; + String platform = platformOption.getAsString(); String host = hostOption.getAsString(); - MinecraftServer server; try { if (platform.equalsIgnoreCase("java")) { diff --git a/src/main/java/cc/fascinated/bat/features/minecraft/command/serverwatcher/AddSubCommand.java b/src/main/java/cc/fascinated/bat/features/minecraft/command/serverwatcher/AddSubCommand.java index 6a3c8c8..156fc50 100644 --- a/src/main/java/cc/fascinated/bat/features/minecraft/command/serverwatcher/AddSubCommand.java +++ b/src/main/java/cc/fascinated/bat/features/minecraft/command/serverwatcher/AddSubCommand.java @@ -43,16 +43,16 @@ public class AddSubCommand extends BatCommand { @Override public void execute(BatGuild guild, @NonNull BatUser user, @NonNull MessageChannel channel, Member member, @NonNull SlashCommandInteraction event) { OptionMapping platformOption = event.getOption("platform"); + assert platformOption != null; OptionMapping hostOption = event.getOption("host"); + assert hostOption != null; OptionMapping channelOption = event.getOption("channel"); - if (platformOption == null || hostOption == null || channelOption == null) { - return; - } + assert channelOption != null; + String platform = platformOption.getAsString(); String host = hostOption.getAsString(); GuildChannelUnion channelUnion = channelOption.getAsChannel(); TextChannel textChannel = channelUnion.asTextChannel(); - MinecraftServer server; try { if (platform.equalsIgnoreCase("java")) { diff --git a/src/main/java/cc/fascinated/bat/features/minecraft/command/serverwatcher/RemoveSubCommand.java b/src/main/java/cc/fascinated/bat/features/minecraft/command/serverwatcher/RemoveSubCommand.java index 584c9a1..315b441 100644 --- a/src/main/java/cc/fascinated/bat/features/minecraft/command/serverwatcher/RemoveSubCommand.java +++ b/src/main/java/cc/fascinated/bat/features/minecraft/command/serverwatcher/RemoveSubCommand.java @@ -38,10 +38,10 @@ public class RemoveSubCommand extends BatCommand { @Override public void execute(BatGuild guild, @NonNull BatUser user, @NonNull MessageChannel channel, Member member, @NonNull SlashCommandInteraction event) { OptionMapping platformOption = event.getOption("platform"); + assert platformOption != null; OptionMapping hostOption = event.getOption("host"); - if (platformOption == null || hostOption == null) { - return; - } + assert hostOption != null; + String platform = platformOption.getAsString(); String host = hostOption.getAsString(); diff --git a/src/main/java/cc/fascinated/bat/features/moderation/command/PurgeCommand.java b/src/main/java/cc/fascinated/bat/features/moderation/command/PurgeCommand.java index 7fb074a..ac7c712 100644 --- a/src/main/java/cc/fascinated/bat/features/moderation/command/PurgeCommand.java +++ b/src/main/java/cc/fascinated/bat/features/moderation/command/PurgeCommand.java @@ -36,9 +36,8 @@ public class PurgeCommand extends BatCommand { @Override public void execute(BatGuild guild, @NonNull BatUser user, @NonNull MessageChannel channel, Member member, @NonNull SlashCommandInteraction event) { OptionMapping amountOption = event.getOption("amount"); - if (amountOption == null) { - return; - } + assert amountOption != null; + int amount = amountOption.getAsInt(); if (amount < 2 || amount > 100) { event.replyEmbeds(EmbedUtils.errorEmbed() diff --git a/src/main/java/cc/fascinated/bat/features/reminder/command/SetSubCommand.java b/src/main/java/cc/fascinated/bat/features/reminder/command/SetSubCommand.java index 61af6ef..b2c9cf3 100644 --- a/src/main/java/cc/fascinated/bat/features/reminder/command/SetSubCommand.java +++ b/src/main/java/cc/fascinated/bat/features/reminder/command/SetSubCommand.java @@ -45,13 +45,9 @@ public class SetSubCommand extends BatCommand { } OptionMapping reminderOption = event.getOption("reminder"); - if (reminderOption == null) { - return; - } + assert reminderOption != null; OptionMapping timeOption = event.getOption("time"); - if (timeOption == null) { - return; - } + assert timeOption != null; String reminderText = reminderOption.getAsString(); long time = TimeUtils.fromString(timeOption.getAsString()); diff --git a/src/main/java/cc/fascinated/bat/features/scoresaber/command/scoresaber/LinkSubCommand.java b/src/main/java/cc/fascinated/bat/features/scoresaber/command/scoresaber/LinkSubCommand.java index 0088231..8d1400e 100644 --- a/src/main/java/cc/fascinated/bat/features/scoresaber/command/scoresaber/LinkSubCommand.java +++ b/src/main/java/cc/fascinated/bat/features/scoresaber/command/scoresaber/LinkSubCommand.java @@ -33,17 +33,10 @@ public class LinkSubCommand extends BatCommand { @Override public void execute(BatGuild guild, @NonNull BatUser user, @NonNull MessageChannel channel, Member member, @NonNull SlashCommandInteraction event) { - OptionMapping option = event.getOption("link"); - if (option == null) { - event.replyEmbeds(EmbedUtils.errorEmbed() - .setDescription("Please provide a ScoreSaber profile link") - .build()) - .setEphemeral(true) - .queue(); - return; - } + OptionMapping linkOption = event.getOption("link"); + assert linkOption != null; - String link = option.getAsString(); + String link = linkOption.getAsString(); if (!link.contains("scoresaber.com/u/")) { event.replyEmbeds(EmbedUtils.errorEmbed() .setDescription("Invalid ScoreSaber profile link") diff --git a/src/main/java/cc/fascinated/bat/features/scoresaber/command/scoresaber/UserSubCommand.java b/src/main/java/cc/fascinated/bat/features/scoresaber/command/scoresaber/UserSubCommand.java index 889157d..46fd548 100644 --- a/src/main/java/cc/fascinated/bat/features/scoresaber/command/scoresaber/UserSubCommand.java +++ b/src/main/java/cc/fascinated/bat/features/scoresaber/command/scoresaber/UserSubCommand.java @@ -35,11 +35,10 @@ public class UserSubCommand extends BatCommand { @Override public void execute(BatGuild guild, @NonNull BatUser user, @NonNull MessageChannel channel, Member member, @NonNull SlashCommandInteraction event) { - OptionMapping option = event.getOption("user"); - if (option == null) { - return; - } - BatUser target = userService.getUser(option.getAsUser().getId()); + OptionMapping userOption = event.getOption("user"); + assert userOption != null; + + BatUser target = userService.getUser(userOption.getAsUser().getId()); if (target == null) { event.replyEmbeds(EmbedUtils.errorEmbed() .setDescription("Unknown user")