cleanup
This commit is contained in:
parent
25dd6cb0dc
commit
2a7e2acc88
@ -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
|
||||
|
@ -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())) {
|
||||
|
@ -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;
|
||||
|
@ -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())
|
||||
|
@ -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()))
|
||||
|
@ -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())
|
||||
|
@ -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) {
|
||||
|
@ -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;
|
||||
|
@ -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")
|
||||
|
@ -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()
|
||||
|
@ -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()
|
||||
|
@ -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()
|
||||
|
@ -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()
|
||||
|
@ -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()
|
||||
|
@ -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) {
|
||||
|
@ -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();
|
||||
|
@ -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();
|
||||
|
@ -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());
|
||||
|
@ -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();
|
||||
|
||||
|
@ -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();
|
||||
|
@ -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();
|
||||
|
@ -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")) {
|
||||
|
@ -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")) {
|
||||
|
@ -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();
|
||||
|
||||
|
@ -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()
|
||||
|
@ -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());
|
||||
|
@ -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")
|
||||
|
@ -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")
|
||||
|
Loading…
Reference in New Issue
Block a user