diff --git a/Dockerfile b/Dockerfile index cc04acf..73acdb4 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,5 @@ # Stage 1: Build the application -FROM maven:3.9.9-eclipse-temurin-17-alpine AS builder +FROM 3.9.9-eclipse-temurin-21-alpine AS builder # Set the working directory WORKDIR /home/container diff --git a/pom.xml b/pom.xml index 5c941a7..6921d95 100644 --- a/pom.xml +++ b/pom.xml @@ -16,57 +16,31 @@ Bat Bot for Discord - 17 + 21 + ${project.artifactId} - + - org.apache.maven.plugins - maven-compiler-plugin - 3.13.0 - - ${java.version} - ${java.version} - - - - false - - - - - - org.apache.maven.plugins - maven-shade-plugin - 3.6.0 - - false - + org.springframework.boot + spring-boot-maven-plugin - package + build-info - shade + build-info + + + ${project.description} + + - - - - org.apache.maven.plugins - maven-jar-plugin - - - - cc.fascinated.bat.BatApplication - - - - diff --git a/src/main/java/cc/fascinated/bat/afk/AfkFeature.java b/src/main/java/cc/fascinated/bat/afk/AfkFeature.java index 7187e5f..99fbfe1 100644 --- a/src/main/java/cc/fascinated/bat/afk/AfkFeature.java +++ b/src/main/java/cc/fascinated/bat/afk/AfkFeature.java @@ -3,7 +3,7 @@ package cc.fascinated.bat.afk; import cc.fascinated.bat.common.feature.Feature; import cc.fascinated.bat.common.feature.FeatureProfile; import cc.fascinated.bat.afk.command.AfkCommand; -import cc.fascinated.bat.service.CommandService; +import cc.fascinated.bat.service.OldCommandService; import lombok.NonNull; import org.springframework.context.ApplicationContext; import org.springframework.stereotype.Component; @@ -13,7 +13,7 @@ import org.springframework.stereotype.Component; */ @Component public class AfkFeature extends Feature { - public AfkFeature(@NonNull ApplicationContext context, @NonNull CommandService commandService) { + public AfkFeature(@NonNull ApplicationContext context, @NonNull OldCommandService commandService) { super("AFK", FeatureProfile.FeatureState.DISABLED, true); registerCommand(commandService, context.getBean(AfkCommand.class)); diff --git a/src/main/java/cc/fascinated/bat/afk/command/AfkCommand.java b/src/main/java/cc/fascinated/bat/afk/command/AfkCommand.java index cb926ec..27bd339 100644 --- a/src/main/java/cc/fascinated/bat/afk/command/AfkCommand.java +++ b/src/main/java/cc/fascinated/bat/afk/command/AfkCommand.java @@ -1,8 +1,8 @@ package cc.fascinated.bat.afk.command; -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.oldcommand.BatCommand; +import cc.fascinated.bat.common.oldcommand.Category; +import cc.fascinated.bat.common.oldcommand.CommandInfo; import cc.fascinated.bat.common.MemberUtils; import cc.fascinated.bat.afk.profile.AfkProfile; import cc.fascinated.bat.common.model.BatGuild; diff --git a/src/main/java/cc/fascinated/bat/autorole/AutoRoleFeature.java b/src/main/java/cc/fascinated/bat/autorole/AutoRoleFeature.java index 8cf5ac8..b385219 100644 --- a/src/main/java/cc/fascinated/bat/autorole/AutoRoleFeature.java +++ b/src/main/java/cc/fascinated/bat/autorole/AutoRoleFeature.java @@ -3,7 +3,7 @@ package cc.fascinated.bat.autorole; import cc.fascinated.bat.common.feature.Feature; import cc.fascinated.bat.common.feature.FeatureProfile; import cc.fascinated.bat.autorole.command.AutoRoleCommand; -import cc.fascinated.bat.service.CommandService; +import cc.fascinated.bat.service.OldCommandService; import lombok.NonNull; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.ApplicationContext; @@ -15,7 +15,7 @@ import org.springframework.stereotype.Component; @Component public class AutoRoleFeature extends Feature { @Autowired - public AutoRoleFeature(@NonNull ApplicationContext context, @NonNull CommandService commandService) { + public AutoRoleFeature(@NonNull ApplicationContext context, @NonNull OldCommandService commandService) { super("Auto Role", FeatureProfile.FeatureState.DISABLED, true); registerCommand(commandService, context.getBean(AutoRoleCommand.class)); diff --git a/src/main/java/cc/fascinated/bat/autorole/command/AddSubCommand.java b/src/main/java/cc/fascinated/bat/autorole/command/AddSubCommand.java index 9e02a8e..125f328 100644 --- a/src/main/java/cc/fascinated/bat/autorole/command/AddSubCommand.java +++ b/src/main/java/cc/fascinated/bat/autorole/command/AddSubCommand.java @@ -1,7 +1,7 @@ package cc.fascinated.bat.autorole.command; -import cc.fascinated.bat.common.command.BatCommand; -import cc.fascinated.bat.common.command.CommandInfo; +import cc.fascinated.bat.common.oldcommand.BatCommand; +import cc.fascinated.bat.common.oldcommand.CommandInfo; import cc.fascinated.bat.common.EmbedUtils; import cc.fascinated.bat.common.RoleUtils; import cc.fascinated.bat.autorole.profile.AutoRoleProfile; diff --git a/src/main/java/cc/fascinated/bat/autorole/command/AutoRoleCommand.java b/src/main/java/cc/fascinated/bat/autorole/command/AutoRoleCommand.java index 9fc7b49..690e7a6 100644 --- a/src/main/java/cc/fascinated/bat/autorole/command/AutoRoleCommand.java +++ b/src/main/java/cc/fascinated/bat/autorole/command/AutoRoleCommand.java @@ -1,8 +1,8 @@ package cc.fascinated.bat.autorole.command; -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.oldcommand.BatCommand; +import cc.fascinated.bat.common.oldcommand.Category; +import cc.fascinated.bat.common.oldcommand.CommandInfo; import lombok.NonNull; import net.dv8tion.jda.api.Permission; import org.springframework.context.ApplicationContext; diff --git a/src/main/java/cc/fascinated/bat/autorole/command/ClearSubCommand.java b/src/main/java/cc/fascinated/bat/autorole/command/ClearSubCommand.java index d286f7c..bf3a4f1 100644 --- a/src/main/java/cc/fascinated/bat/autorole/command/ClearSubCommand.java +++ b/src/main/java/cc/fascinated/bat/autorole/command/ClearSubCommand.java @@ -1,7 +1,7 @@ package cc.fascinated.bat.autorole.command; -import cc.fascinated.bat.common.command.BatCommand; -import cc.fascinated.bat.common.command.CommandInfo; +import cc.fascinated.bat.common.oldcommand.BatCommand; +import cc.fascinated.bat.common.oldcommand.CommandInfo; import cc.fascinated.bat.common.EmbedUtils; import cc.fascinated.bat.autorole.profile.AutoRoleProfile; import cc.fascinated.bat.common.model.BatGuild; diff --git a/src/main/java/cc/fascinated/bat/autorole/command/ListSubCommand.java b/src/main/java/cc/fascinated/bat/autorole/command/ListSubCommand.java index 2a38290..144bc05 100644 --- a/src/main/java/cc/fascinated/bat/autorole/command/ListSubCommand.java +++ b/src/main/java/cc/fascinated/bat/autorole/command/ListSubCommand.java @@ -1,7 +1,7 @@ package cc.fascinated.bat.autorole.command; -import cc.fascinated.bat.common.command.BatCommand; -import cc.fascinated.bat.common.command.CommandInfo; +import cc.fascinated.bat.common.oldcommand.BatCommand; +import cc.fascinated.bat.common.oldcommand.CommandInfo; import cc.fascinated.bat.common.EmbedUtils; import cc.fascinated.bat.autorole.profile.AutoRoleProfile; import cc.fascinated.bat.common.model.BatGuild; diff --git a/src/main/java/cc/fascinated/bat/autorole/command/RemoveSubCommand.java b/src/main/java/cc/fascinated/bat/autorole/command/RemoveSubCommand.java index 721d4c0..2a54a90 100644 --- a/src/main/java/cc/fascinated/bat/autorole/command/RemoveSubCommand.java +++ b/src/main/java/cc/fascinated/bat/autorole/command/RemoveSubCommand.java @@ -1,7 +1,7 @@ package cc.fascinated.bat.autorole.command; -import cc.fascinated.bat.common.command.BatCommand; -import cc.fascinated.bat.common.command.CommandInfo; +import cc.fascinated.bat.common.oldcommand.BatCommand; +import cc.fascinated.bat.common.oldcommand.CommandInfo; import cc.fascinated.bat.common.EmbedUtils; import cc.fascinated.bat.autorole.profile.AutoRoleProfile; import cc.fascinated.bat.common.model.BatGuild; diff --git a/src/main/java/cc/fascinated/bat/autorole/command/SyncSubCommand.java b/src/main/java/cc/fascinated/bat/autorole/command/SyncSubCommand.java index 9031599..6be6cfb 100644 --- a/src/main/java/cc/fascinated/bat/autorole/command/SyncSubCommand.java +++ b/src/main/java/cc/fascinated/bat/autorole/command/SyncSubCommand.java @@ -1,7 +1,7 @@ package cc.fascinated.bat.autorole.command; -import cc.fascinated.bat.common.command.BatCommand; -import cc.fascinated.bat.common.command.CommandInfo; +import cc.fascinated.bat.common.oldcommand.BatCommand; +import cc.fascinated.bat.common.oldcommand.CommandInfo; import cc.fascinated.bat.common.DescriptionBuilder; import cc.fascinated.bat.common.EmbedUtils; import cc.fascinated.bat.autorole.profile.AutoRoleProfile; diff --git a/src/main/java/cc/fascinated/bat/base/BaseFeature.java b/src/main/java/cc/fascinated/bat/base/BaseFeature.java index e6a38db..a41fc4d 100644 --- a/src/main/java/cc/fascinated/bat/base/BaseFeature.java +++ b/src/main/java/cc/fascinated/bat/base/BaseFeature.java @@ -16,7 +16,7 @@ import cc.fascinated.bat.base.commands.server.channel.ChannelCommand; import cc.fascinated.bat.base.commands.server.feature.FeatureCommand; import cc.fascinated.bat.base.commands.utility.PastebinCommand; import cc.fascinated.bat.base.commands.utility.lookup.LookupCommand; -import cc.fascinated.bat.service.CommandService; +import cc.fascinated.bat.service.OldCommandService; import lombok.NonNull; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.ApplicationContext; @@ -28,7 +28,7 @@ import org.springframework.stereotype.Component; @Component public class BaseFeature extends Feature { @Autowired - public BaseFeature(@NonNull ApplicationContext context, @NonNull CommandService commandService) { + public BaseFeature(@NonNull ApplicationContext context, @NonNull OldCommandService commandService) { super("Base", FeatureProfile.FeatureState.ENABLED, false); super.registerCommand(commandService, context.getBean(PremiumCommand.class)); @@ -38,7 +38,6 @@ public class BaseFeature extends Feature { super.registerCommand(commandService, context.getBean(VoteCommand.class)); super.registerCommand(commandService, context.getBean(PingCommand.class)); super.registerCommand(commandService, context.getBean(InviteCommand.class)); - super.registerCommand(commandService, context.getBean(HelpCommand.class)); super.registerCommand(commandService, context.getBean(BotStatsCommand.class)); super.registerCommand(commandService, context.getBean(BannerCommand.class)); super.registerCommand(commandService, context.getBean(AvatarCommand.class)); diff --git a/src/main/java/cc/fascinated/bat/base/commands/botadmin/BotAdminCommand.java b/src/main/java/cc/fascinated/bat/base/commands/botadmin/BotAdminCommand.java index 14c5bea..38528f9 100644 --- a/src/main/java/cc/fascinated/bat/base/commands/botadmin/BotAdminCommand.java +++ b/src/main/java/cc/fascinated/bat/base/commands/botadmin/BotAdminCommand.java @@ -1,7 +1,7 @@ package cc.fascinated.bat.base.commands.botadmin; -import cc.fascinated.bat.common.command.BatCommand; -import cc.fascinated.bat.common.command.CommandInfo; +import cc.fascinated.bat.common.oldcommand.BatCommand; +import cc.fascinated.bat.common.oldcommand.CommandInfo; import cc.fascinated.bat.base.commands.botadmin.premium.PremiumRemoveSubCommand; import cc.fascinated.bat.base.commands.botadmin.premium.PremiumSetSubCommand; import lombok.NonNull; diff --git a/src/main/java/cc/fascinated/bat/base/commands/botadmin/premium/PremiumRemoveSubCommand.java b/src/main/java/cc/fascinated/bat/base/commands/botadmin/premium/PremiumRemoveSubCommand.java index 617b1ca..8a9e7f2 100644 --- a/src/main/java/cc/fascinated/bat/base/commands/botadmin/premium/PremiumRemoveSubCommand.java +++ b/src/main/java/cc/fascinated/bat/base/commands/botadmin/premium/PremiumRemoveSubCommand.java @@ -1,7 +1,7 @@ package cc.fascinated.bat.base.commands.botadmin.premium; -import cc.fascinated.bat.common.command.BatCommand; -import cc.fascinated.bat.common.command.CommandInfo; +import cc.fascinated.bat.common.oldcommand.BatCommand; +import cc.fascinated.bat.common.oldcommand.CommandInfo; import cc.fascinated.bat.common.model.BatGuild; import cc.fascinated.bat.common.model.BatUser; import cc.fascinated.bat.premium.PremiumProfile; diff --git a/src/main/java/cc/fascinated/bat/base/commands/botadmin/premium/PremiumSetSubCommand.java b/src/main/java/cc/fascinated/bat/base/commands/botadmin/premium/PremiumSetSubCommand.java index 4646f2c..489d33a 100644 --- a/src/main/java/cc/fascinated/bat/base/commands/botadmin/premium/PremiumSetSubCommand.java +++ b/src/main/java/cc/fascinated/bat/base/commands/botadmin/premium/PremiumSetSubCommand.java @@ -1,7 +1,7 @@ package cc.fascinated.bat.base.commands.botadmin.premium; -import cc.fascinated.bat.common.command.BatCommand; -import cc.fascinated.bat.common.command.CommandInfo; +import cc.fascinated.bat.common.oldcommand.BatCommand; +import cc.fascinated.bat.common.oldcommand.CommandInfo; import cc.fascinated.bat.common.model.BatGuild; import cc.fascinated.bat.common.model.BatUser; import cc.fascinated.bat.premium.PremiumProfile; diff --git a/src/main/java/cc/fascinated/bat/base/commands/fun/CoinFlipCommand.java b/src/main/java/cc/fascinated/bat/base/commands/fun/CoinFlipCommand.java index af73fdb..2aeb603 100644 --- a/src/main/java/cc/fascinated/bat/base/commands/fun/CoinFlipCommand.java +++ b/src/main/java/cc/fascinated/bat/base/commands/fun/CoinFlipCommand.java @@ -1,7 +1,7 @@ package cc.fascinated.bat.base.commands.fun; -import cc.fascinated.bat.common.command.BatCommand; -import cc.fascinated.bat.common.command.CommandInfo; +import cc.fascinated.bat.common.oldcommand.BatCommand; +import cc.fascinated.bat.common.oldcommand.CommandInfo; import cc.fascinated.bat.common.model.BatGuild; import cc.fascinated.bat.common.model.BatUser; import lombok.NonNull; diff --git a/src/main/java/cc/fascinated/bat/base/commands/fun/EightBallCommand.java b/src/main/java/cc/fascinated/bat/base/commands/fun/EightBallCommand.java index 00c0306..15c1aab 100644 --- a/src/main/java/cc/fascinated/bat/base/commands/fun/EightBallCommand.java +++ b/src/main/java/cc/fascinated/bat/base/commands/fun/EightBallCommand.java @@ -1,8 +1,8 @@ package cc.fascinated.bat.base.commands.fun; -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.oldcommand.BatCommand; +import cc.fascinated.bat.common.oldcommand.Category; +import cc.fascinated.bat.common.oldcommand.CommandInfo; import cc.fascinated.bat.common.EmbedUtils; import cc.fascinated.bat.common.model.BatGuild; import cc.fascinated.bat.common.model.BatUser; 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 51a5147..f305327 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 @@ -1,8 +1,8 @@ package cc.fascinated.bat.base.commands.fun; -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.oldcommand.BatCommand; +import cc.fascinated.bat.common.oldcommand.Category; +import cc.fascinated.bat.common.oldcommand.CommandInfo; import cc.fascinated.bat.common.DescriptionBuilder; import cc.fascinated.bat.common.EmbedUtils; import cc.fascinated.bat.common.MathUtils; diff --git a/src/main/java/cc/fascinated/bat/base/commands/fun/image/CatSubCommand.java b/src/main/java/cc/fascinated/bat/base/commands/fun/image/CatSubCommand.java index 3e74be3..e38a237 100644 --- a/src/main/java/cc/fascinated/bat/base/commands/fun/image/CatSubCommand.java +++ b/src/main/java/cc/fascinated/bat/base/commands/fun/image/CatSubCommand.java @@ -1,7 +1,7 @@ package cc.fascinated.bat.base.commands.fun.image; -import cc.fascinated.bat.common.command.BatCommand; -import cc.fascinated.bat.common.command.CommandInfo; +import cc.fascinated.bat.common.oldcommand.BatCommand; +import cc.fascinated.bat.common.oldcommand.CommandInfo; import cc.fascinated.bat.common.EmbedUtils; import cc.fascinated.bat.common.WebRequest; import cc.fascinated.bat.common.model.BatGuild; diff --git a/src/main/java/cc/fascinated/bat/base/commands/fun/image/DogSubCommand.java b/src/main/java/cc/fascinated/bat/base/commands/fun/image/DogSubCommand.java index cfe0be3..616cd3b 100644 --- a/src/main/java/cc/fascinated/bat/base/commands/fun/image/DogSubCommand.java +++ b/src/main/java/cc/fascinated/bat/base/commands/fun/image/DogSubCommand.java @@ -1,7 +1,7 @@ package cc.fascinated.bat.base.commands.fun.image; -import cc.fascinated.bat.common.command.BatCommand; -import cc.fascinated.bat.common.command.CommandInfo; +import cc.fascinated.bat.common.oldcommand.BatCommand; +import cc.fascinated.bat.common.oldcommand.CommandInfo; import cc.fascinated.bat.common.EmbedUtils; import cc.fascinated.bat.common.WebRequest; import cc.fascinated.bat.common.model.BatGuild; diff --git a/src/main/java/cc/fascinated/bat/base/commands/fun/image/DuckSubCommand.java b/src/main/java/cc/fascinated/bat/base/commands/fun/image/DuckSubCommand.java index 9f207b5..5c4f455 100644 --- a/src/main/java/cc/fascinated/bat/base/commands/fun/image/DuckSubCommand.java +++ b/src/main/java/cc/fascinated/bat/base/commands/fun/image/DuckSubCommand.java @@ -1,7 +1,7 @@ package cc.fascinated.bat.base.commands.fun.image; -import cc.fascinated.bat.common.command.BatCommand; -import cc.fascinated.bat.common.command.CommandInfo; +import cc.fascinated.bat.common.oldcommand.BatCommand; +import cc.fascinated.bat.common.oldcommand.CommandInfo; import cc.fascinated.bat.common.EmbedUtils; import cc.fascinated.bat.common.WebRequest; import cc.fascinated.bat.common.model.BatGuild; diff --git a/src/main/java/cc/fascinated/bat/base/commands/fun/image/FoxSubCommand.java b/src/main/java/cc/fascinated/bat/base/commands/fun/image/FoxSubCommand.java index 4a5dcd8..9136a70 100644 --- a/src/main/java/cc/fascinated/bat/base/commands/fun/image/FoxSubCommand.java +++ b/src/main/java/cc/fascinated/bat/base/commands/fun/image/FoxSubCommand.java @@ -1,7 +1,7 @@ package cc.fascinated.bat.base.commands.fun.image; -import cc.fascinated.bat.common.command.BatCommand; -import cc.fascinated.bat.common.command.CommandInfo; +import cc.fascinated.bat.common.oldcommand.BatCommand; +import cc.fascinated.bat.common.oldcommand.CommandInfo; import cc.fascinated.bat.common.EmbedUtils; import cc.fascinated.bat.common.WebRequest; import cc.fascinated.bat.common.model.BatGuild; diff --git a/src/main/java/cc/fascinated/bat/base/commands/fun/image/ImageCommand.java b/src/main/java/cc/fascinated/bat/base/commands/fun/image/ImageCommand.java index b8541a0..246f032 100644 --- a/src/main/java/cc/fascinated/bat/base/commands/fun/image/ImageCommand.java +++ b/src/main/java/cc/fascinated/bat/base/commands/fun/image/ImageCommand.java @@ -1,8 +1,8 @@ package cc.fascinated.bat.base.commands.fun.image; -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.oldcommand.BatCommand; +import cc.fascinated.bat.common.oldcommand.Category; +import cc.fascinated.bat.common.oldcommand.CommandInfo; import lombok.NonNull; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.ApplicationContext; diff --git a/src/main/java/cc/fascinated/bat/base/commands/general/BotStatsCommand.java b/src/main/java/cc/fascinated/bat/base/commands/general/BotStatsCommand.java index 52c970a..e28340d 100644 --- a/src/main/java/cc/fascinated/bat/base/commands/general/BotStatsCommand.java +++ b/src/main/java/cc/fascinated/bat/base/commands/general/BotStatsCommand.java @@ -1,8 +1,8 @@ package cc.fascinated.bat.base.commands.general; -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.oldcommand.BatCommand; +import cc.fascinated.bat.common.oldcommand.Category; +import cc.fascinated.bat.common.oldcommand.CommandInfo; import cc.fascinated.bat.common.*; import cc.fascinated.bat.common.model.BatGuild; import cc.fascinated.bat.common.model.BatUser; diff --git a/src/main/java/cc/fascinated/bat/base/commands/general/HelpCommand.java b/src/main/java/cc/fascinated/bat/base/commands/general/HelpCommand.java deleted file mode 100644 index d98f803..0000000 --- a/src/main/java/cc/fascinated/bat/base/commands/general/HelpCommand.java +++ /dev/null @@ -1,127 +0,0 @@ -package cc.fascinated.bat.base.commands.general; - -import cc.fascinated.bat.Consts; -import cc.fascinated.bat.Emojis; -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.DescriptionBuilder; -import cc.fascinated.bat.common.EmbedUtils; -import cc.fascinated.bat.common.InteractionBuilder; -import cc.fascinated.bat.event.EventListener; -import cc.fascinated.bat.common.model.BatGuild; -import cc.fascinated.bat.common.model.BatUser; -import cc.fascinated.bat.service.CommandService; -import lombok.NonNull; -import net.dv8tion.jda.api.entities.Member; -import net.dv8tion.jda.api.entities.Message; -import net.dv8tion.jda.api.entities.MessageEmbed; -import net.dv8tion.jda.api.entities.channel.middleman.MessageChannel; -import net.dv8tion.jda.api.interactions.commands.SlashCommandInteraction; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; - -import java.util.List; - -/** - * @author Fascinated (fascinated7) - */ -@Component -@CommandInfo( - name = "help", - description = "View the bots command categories", - userInstall = true, - category = Category.GENERAL -) -public class HelpCommand extends BatCommand implements EventListener { - private final CommandService commandService; - - @Autowired - public HelpCommand(@NonNull CommandService commandService) { - this.commandService = commandService; - } - - @Override - public void execute(BatGuild guild, @NonNull BatUser user, @NonNull MessageChannel channel, Member member, Message commandMessage, String[] arguments, SlashCommandInteraction event) { - InteractionBuilder interactionBuilder = new InteractionBuilder(); - interactionBuilder.addUrlButton("Invite Me", Consts.INVITE_URL, null); - interactionBuilder.addUrlButton("Support Server", Consts.SUPPORT_INVITE_URL, null); - interactionBuilder.addStringSelect("Home", "Return Home", Emojis.HOME_EMOJI, (buttonEvent) -> { - buttonEvent.editMessageEmbeds(createHomeEmbed(event.isFromGuild())).queue(); - }); - for (Category category : Category.getSortedByName()) { - List categoryCommands = commandService.getCommandsByCategory(category, event.isFromGuild()); - if (categoryCommands.isEmpty()) { - continue; - } - - interactionBuilder.addStringSelect( - category.getName(), - "View commands in the %s category".formatted(category.getName()), - category.getEmoji(), - (buttonEvent) -> { - DescriptionBuilder description = new DescriptionBuilder(null); - description.appendLine("Commands in the **%s** Category".formatted(category.getName()), false); - description.emptyLine(); - - for (BatCommand command : categoryCommands) { - if (!command.getSubCommands().isEmpty()) { - for (BatCommand subCommand : command.getSubCommands().values()) { - description.appendLine("`%s %s` - %s".formatted( - command.getInfo().getName(), - subCommand.getInfo().getName(), - subCommand.getInfo().getDescription() - ), true); - } - continue; - } - description.appendLine("`%s` - %s".formatted( - command.getInfo().getName(), - command.getInfo().getDescription() - ), true); - } - - buttonEvent.editMessageEmbeds(EmbedUtils.genericEmbed() - .setDescription(description.build()) - .build()).queue(); - }); - } - - - event.replyEmbeds(createHomeEmbed(event.isFromGuild())).addComponents(interactionBuilder.build()).queue(); - } - - /** - * Creates the home embed for the help command - * - * @return The home embed - */ - private MessageEmbed createHomeEmbed(boolean ranInsideGuild) { - StringBuilder categories = new StringBuilder(); - for (Category category : Category.values()) { - if (commandService.getCommandsByCategory(category, ranInsideGuild).isEmpty()) { - continue; - } - long commandCount = commandService.getCommandsByCategory(category, ranInsideGuild).size(); - categories.append("➜ %s - **%s Command%s**\n".formatted( - category.getName(), - commandCount, - commandCount == 1 ? "" : "s" - )); - } - - return EmbedUtils.genericEmbed() - .setDescription(""" - **Welcome to the Bat Help Menu!**%s - - %s - *View our [TOS](%s) and [Privacy Policy](%s) for more information.* - """.formatted( - !ranInsideGuild ? "\n*guild only commands won't be shown here*" : "", - categories.toString(), - Consts.TERMS_OF_SERVICE_URL, - Consts.PRIVACY_POLICY_URL - )) - .build(); - } -} diff --git a/src/main/java/cc/fascinated/bat/base/commands/general/InviteCommand.java b/src/main/java/cc/fascinated/bat/base/commands/general/InviteCommand.java index 14f0b40..72c61a8 100644 --- a/src/main/java/cc/fascinated/bat/base/commands/general/InviteCommand.java +++ b/src/main/java/cc/fascinated/bat/base/commands/general/InviteCommand.java @@ -1,9 +1,9 @@ package cc.fascinated.bat.base.commands.general; import cc.fascinated.bat.Consts; -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.oldcommand.BatCommand; +import cc.fascinated.bat.common.oldcommand.Category; +import cc.fascinated.bat.common.oldcommand.CommandInfo; import cc.fascinated.bat.common.EmbedUtils; import cc.fascinated.bat.common.model.BatGuild; import cc.fascinated.bat.common.model.BatUser; diff --git a/src/main/java/cc/fascinated/bat/base/commands/general/PingCommand.java b/src/main/java/cc/fascinated/bat/base/commands/general/PingCommand.java index 0d3515a..c1198f7 100644 --- a/src/main/java/cc/fascinated/bat/base/commands/general/PingCommand.java +++ b/src/main/java/cc/fascinated/bat/base/commands/general/PingCommand.java @@ -1,8 +1,8 @@ package cc.fascinated.bat.base.commands.general; -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.oldcommand.BatCommand; +import cc.fascinated.bat.common.oldcommand.Category; +import cc.fascinated.bat.common.oldcommand.CommandInfo; import cc.fascinated.bat.common.model.BatGuild; import cc.fascinated.bat.common.model.BatUser; import cc.fascinated.bat.service.DiscordService; diff --git a/src/main/java/cc/fascinated/bat/base/commands/general/VoteCommand.java b/src/main/java/cc/fascinated/bat/base/commands/general/VoteCommand.java index 390f58d..2b6a23e 100644 --- a/src/main/java/cc/fascinated/bat/base/commands/general/VoteCommand.java +++ b/src/main/java/cc/fascinated/bat/base/commands/general/VoteCommand.java @@ -1,8 +1,8 @@ package cc.fascinated.bat.base.commands.general; -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.oldcommand.BatCommand; +import cc.fascinated.bat.common.oldcommand.Category; +import cc.fascinated.bat.common.oldcommand.CommandInfo; import cc.fascinated.bat.common.DescriptionBuilder; import cc.fascinated.bat.common.EmbedUtils; import cc.fascinated.bat.common.model.BatGuild; diff --git a/src/main/java/cc/fascinated/bat/base/commands/general/avatar/AvatarCommand.java b/src/main/java/cc/fascinated/bat/base/commands/general/avatar/AvatarCommand.java index 1126cfc..33659b3 100644 --- a/src/main/java/cc/fascinated/bat/base/commands/general/avatar/AvatarCommand.java +++ b/src/main/java/cc/fascinated/bat/base/commands/general/avatar/AvatarCommand.java @@ -1,8 +1,8 @@ package cc.fascinated.bat.base.commands.general.avatar; -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.oldcommand.BatCommand; +import cc.fascinated.bat.common.oldcommand.Category; +import cc.fascinated.bat.common.oldcommand.CommandInfo; import lombok.NonNull; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.ApplicationContext; diff --git a/src/main/java/cc/fascinated/bat/base/commands/general/avatar/GuildSubCommand.java b/src/main/java/cc/fascinated/bat/base/commands/general/avatar/GuildSubCommand.java index ac4a399..7988de3 100644 --- a/src/main/java/cc/fascinated/bat/base/commands/general/avatar/GuildSubCommand.java +++ b/src/main/java/cc/fascinated/bat/base/commands/general/avatar/GuildSubCommand.java @@ -1,8 +1,8 @@ package cc.fascinated.bat.base.commands.general.avatar; -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.oldcommand.BatCommand; +import cc.fascinated.bat.common.oldcommand.Category; +import cc.fascinated.bat.common.oldcommand.CommandInfo; import cc.fascinated.bat.common.EmbedUtils; import cc.fascinated.bat.common.model.BatGuild; import cc.fascinated.bat.common.model.BatUser; diff --git a/src/main/java/cc/fascinated/bat/base/commands/general/avatar/UserSubCommand.java b/src/main/java/cc/fascinated/bat/base/commands/general/avatar/UserSubCommand.java index d7696ac..6fc478f 100644 --- a/src/main/java/cc/fascinated/bat/base/commands/general/avatar/UserSubCommand.java +++ b/src/main/java/cc/fascinated/bat/base/commands/general/avatar/UserSubCommand.java @@ -1,8 +1,8 @@ package cc.fascinated.bat.base.commands.general.avatar; -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.oldcommand.BatCommand; +import cc.fascinated.bat.common.oldcommand.Category; +import cc.fascinated.bat.common.oldcommand.CommandInfo; import cc.fascinated.bat.common.EmbedUtils; import cc.fascinated.bat.common.model.BatGuild; import cc.fascinated.bat.common.model.BatUser; diff --git a/src/main/java/cc/fascinated/bat/base/commands/general/banner/BannerCommand.java b/src/main/java/cc/fascinated/bat/base/commands/general/banner/BannerCommand.java index 8b81a19..a96f451 100644 --- a/src/main/java/cc/fascinated/bat/base/commands/general/banner/BannerCommand.java +++ b/src/main/java/cc/fascinated/bat/base/commands/general/banner/BannerCommand.java @@ -1,8 +1,8 @@ package cc.fascinated.bat.base.commands.general.banner; -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.oldcommand.BatCommand; +import cc.fascinated.bat.common.oldcommand.Category; +import cc.fascinated.bat.common.oldcommand.CommandInfo; import lombok.NonNull; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.ApplicationContext; diff --git a/src/main/java/cc/fascinated/bat/base/commands/general/banner/GuildSubCommand.java b/src/main/java/cc/fascinated/bat/base/commands/general/banner/GuildSubCommand.java index a6af726..748f004 100644 --- a/src/main/java/cc/fascinated/bat/base/commands/general/banner/GuildSubCommand.java +++ b/src/main/java/cc/fascinated/bat/base/commands/general/banner/GuildSubCommand.java @@ -1,8 +1,8 @@ package cc.fascinated.bat.base.commands.general.banner; -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.oldcommand.BatCommand; +import cc.fascinated.bat.common.oldcommand.Category; +import cc.fascinated.bat.common.oldcommand.CommandInfo; import cc.fascinated.bat.common.EmbedUtils; import cc.fascinated.bat.common.model.BatGuild; import cc.fascinated.bat.common.model.BatUser; diff --git a/src/main/java/cc/fascinated/bat/base/commands/general/banner/UserSubCommand.java b/src/main/java/cc/fascinated/bat/base/commands/general/banner/UserSubCommand.java index 369c11b..fd84aac 100644 --- a/src/main/java/cc/fascinated/bat/base/commands/general/banner/UserSubCommand.java +++ b/src/main/java/cc/fascinated/bat/base/commands/general/banner/UserSubCommand.java @@ -1,8 +1,8 @@ package cc.fascinated.bat.base.commands.general.banner; -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.oldcommand.BatCommand; +import cc.fascinated.bat.common.oldcommand.Category; +import cc.fascinated.bat.common.oldcommand.CommandInfo; import cc.fascinated.bat.common.EmbedUtils; import cc.fascinated.bat.common.model.BatGuild; import cc.fascinated.bat.common.model.BatUser; diff --git a/src/main/java/cc/fascinated/bat/base/commands/server/MemberCountCommand.java b/src/main/java/cc/fascinated/bat/base/commands/server/MemberCountCommand.java index a36b740..b162377 100644 --- a/src/main/java/cc/fascinated/bat/base/commands/server/MemberCountCommand.java +++ b/src/main/java/cc/fascinated/bat/base/commands/server/MemberCountCommand.java @@ -1,7 +1,7 @@ package cc.fascinated.bat.base.commands.server; -import cc.fascinated.bat.common.command.BatCommand; -import cc.fascinated.bat.common.command.CommandInfo; +import cc.fascinated.bat.common.oldcommand.BatCommand; +import cc.fascinated.bat.common.oldcommand.CommandInfo; import cc.fascinated.bat.common.EmbedUtils; import cc.fascinated.bat.common.NumberFormatter; import cc.fascinated.bat.common.model.BatGuild; diff --git a/src/main/java/cc/fascinated/bat/base/commands/server/PremiumCommand.java b/src/main/java/cc/fascinated/bat/base/commands/server/PremiumCommand.java index 1c383df..ad6b426 100644 --- a/src/main/java/cc/fascinated/bat/base/commands/server/PremiumCommand.java +++ b/src/main/java/cc/fascinated/bat/base/commands/server/PremiumCommand.java @@ -1,7 +1,7 @@ package cc.fascinated.bat.base.commands.server; -import cc.fascinated.bat.common.command.BatCommand; -import cc.fascinated.bat.common.command.CommandInfo; +import cc.fascinated.bat.common.oldcommand.BatCommand; +import cc.fascinated.bat.common.oldcommand.CommandInfo; import cc.fascinated.bat.common.EmbedUtils; import cc.fascinated.bat.common.model.BatGuild; import cc.fascinated.bat.common.model.BatUser; diff --git a/src/main/java/cc/fascinated/bat/base/commands/server/channel/ChannelCommand.java b/src/main/java/cc/fascinated/bat/base/commands/server/channel/ChannelCommand.java index 877d1d3..72d5351 100644 --- a/src/main/java/cc/fascinated/bat/base/commands/server/channel/ChannelCommand.java +++ b/src/main/java/cc/fascinated/bat/base/commands/server/channel/ChannelCommand.java @@ -1,8 +1,8 @@ package cc.fascinated.bat.base.commands.server.channel; -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.oldcommand.BatCommand; +import cc.fascinated.bat.common.oldcommand.Category; +import cc.fascinated.bat.common.oldcommand.CommandInfo; import lombok.NonNull; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.ApplicationContext; diff --git a/src/main/java/cc/fascinated/bat/base/commands/server/channel/RemoveTopicSubCommand.java b/src/main/java/cc/fascinated/bat/base/commands/server/channel/RemoveTopicSubCommand.java index fa38f7d..9fd3dd7 100644 --- a/src/main/java/cc/fascinated/bat/base/commands/server/channel/RemoveTopicSubCommand.java +++ b/src/main/java/cc/fascinated/bat/base/commands/server/channel/RemoveTopicSubCommand.java @@ -1,7 +1,7 @@ package cc.fascinated.bat.base.commands.server.channel; -import cc.fascinated.bat.common.command.BatCommand; -import cc.fascinated.bat.common.command.CommandInfo; +import cc.fascinated.bat.common.oldcommand.BatCommand; +import cc.fascinated.bat.common.oldcommand.CommandInfo; import cc.fascinated.bat.common.EmbedUtils; import cc.fascinated.bat.common.model.BatGuild; import cc.fascinated.bat.common.model.BatUser; diff --git a/src/main/java/cc/fascinated/bat/base/commands/server/channel/SetTopicSubCommand.java b/src/main/java/cc/fascinated/bat/base/commands/server/channel/SetTopicSubCommand.java index c372d4c..e4cd9b9 100644 --- a/src/main/java/cc/fascinated/bat/base/commands/server/channel/SetTopicSubCommand.java +++ b/src/main/java/cc/fascinated/bat/base/commands/server/channel/SetTopicSubCommand.java @@ -1,7 +1,7 @@ package cc.fascinated.bat.base.commands.server.channel; -import cc.fascinated.bat.common.command.BatCommand; -import cc.fascinated.bat.common.command.CommandInfo; +import cc.fascinated.bat.common.oldcommand.BatCommand; +import cc.fascinated.bat.common.oldcommand.CommandInfo; import cc.fascinated.bat.common.EmbedUtils; import cc.fascinated.bat.common.model.BatGuild; import cc.fascinated.bat.common.model.BatUser; diff --git a/src/main/java/cc/fascinated/bat/base/commands/server/channel/ViewTopicSubCommand.java b/src/main/java/cc/fascinated/bat/base/commands/server/channel/ViewTopicSubCommand.java index 2f1ca56..4bbb3bd 100644 --- a/src/main/java/cc/fascinated/bat/base/commands/server/channel/ViewTopicSubCommand.java +++ b/src/main/java/cc/fascinated/bat/base/commands/server/channel/ViewTopicSubCommand.java @@ -1,7 +1,7 @@ package cc.fascinated.bat.base.commands.server.channel; -import cc.fascinated.bat.common.command.BatCommand; -import cc.fascinated.bat.common.command.CommandInfo; +import cc.fascinated.bat.common.oldcommand.BatCommand; +import cc.fascinated.bat.common.oldcommand.CommandInfo; import cc.fascinated.bat.common.EmbedUtils; import cc.fascinated.bat.common.model.BatGuild; import cc.fascinated.bat.common.model.BatUser; diff --git a/src/main/java/cc/fascinated/bat/base/commands/server/feature/DisableSubCommand.java b/src/main/java/cc/fascinated/bat/base/commands/server/feature/DisableSubCommand.java index f832640..4879864 100644 --- a/src/main/java/cc/fascinated/bat/base/commands/server/feature/DisableSubCommand.java +++ b/src/main/java/cc/fascinated/bat/base/commands/server/feature/DisableSubCommand.java @@ -1,7 +1,7 @@ package cc.fascinated.bat.base.commands.server.feature; -import cc.fascinated.bat.common.command.BatCommand; -import cc.fascinated.bat.common.command.CommandInfo; +import cc.fascinated.bat.common.oldcommand.BatCommand; +import cc.fascinated.bat.common.oldcommand.CommandInfo; import cc.fascinated.bat.common.EmbedUtils; import cc.fascinated.bat.common.feature.Feature; import cc.fascinated.bat.common.feature.FeatureProfile; diff --git a/src/main/java/cc/fascinated/bat/base/commands/server/feature/EnableSubCommand.java b/src/main/java/cc/fascinated/bat/base/commands/server/feature/EnableSubCommand.java index 596882e..ac4ebcb 100644 --- a/src/main/java/cc/fascinated/bat/base/commands/server/feature/EnableSubCommand.java +++ b/src/main/java/cc/fascinated/bat/base/commands/server/feature/EnableSubCommand.java @@ -1,7 +1,7 @@ package cc.fascinated.bat.base.commands.server.feature; -import cc.fascinated.bat.common.command.BatCommand; -import cc.fascinated.bat.common.command.CommandInfo; +import cc.fascinated.bat.common.oldcommand.BatCommand; +import cc.fascinated.bat.common.oldcommand.CommandInfo; import cc.fascinated.bat.common.EmbedUtils; import cc.fascinated.bat.common.feature.Feature; import cc.fascinated.bat.common.feature.FeatureProfile; diff --git a/src/main/java/cc/fascinated/bat/base/commands/server/feature/FeatureCommand.java b/src/main/java/cc/fascinated/bat/base/commands/server/feature/FeatureCommand.java index 43c0e78..ca3070c 100644 --- a/src/main/java/cc/fascinated/bat/base/commands/server/feature/FeatureCommand.java +++ b/src/main/java/cc/fascinated/bat/base/commands/server/feature/FeatureCommand.java @@ -1,8 +1,8 @@ package cc.fascinated.bat.base.commands.server.feature; -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.oldcommand.BatCommand; +import cc.fascinated.bat.common.oldcommand.Category; +import cc.fascinated.bat.common.oldcommand.CommandInfo; import lombok.NonNull; import net.dv8tion.jda.api.Permission; import org.springframework.beans.factory.annotation.Autowired; diff --git a/src/main/java/cc/fascinated/bat/base/commands/server/feature/ListSubCommand.java b/src/main/java/cc/fascinated/bat/base/commands/server/feature/ListSubCommand.java index 3e301d1..daa9e25 100644 --- a/src/main/java/cc/fascinated/bat/base/commands/server/feature/ListSubCommand.java +++ b/src/main/java/cc/fascinated/bat/base/commands/server/feature/ListSubCommand.java @@ -1,7 +1,7 @@ package cc.fascinated.bat.base.commands.server.feature; -import cc.fascinated.bat.common.command.BatCommand; -import cc.fascinated.bat.common.command.CommandInfo; +import cc.fascinated.bat.common.oldcommand.BatCommand; +import cc.fascinated.bat.common.oldcommand.CommandInfo; import cc.fascinated.bat.common.EmbedUtils; import cc.fascinated.bat.common.feature.Feature; import cc.fascinated.bat.common.feature.FeatureProfile; diff --git a/src/main/java/cc/fascinated/bat/base/commands/utility/PastebinCommand.java b/src/main/java/cc/fascinated/bat/base/commands/utility/PastebinCommand.java index 0967b93..e724541 100644 --- a/src/main/java/cc/fascinated/bat/base/commands/utility/PastebinCommand.java +++ b/src/main/java/cc/fascinated/bat/base/commands/utility/PastebinCommand.java @@ -1,8 +1,8 @@ package cc.fascinated.bat.base.commands.utility; -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.oldcommand.BatCommand; +import cc.fascinated.bat.common.oldcommand.Category; +import cc.fascinated.bat.common.oldcommand.CommandInfo; import cc.fascinated.bat.common.DescriptionBuilder; import cc.fascinated.bat.common.EmbedUtils; import cc.fascinated.bat.common.PasteUtils; diff --git a/src/main/java/cc/fascinated/bat/base/commands/utility/lookup/LookupCommand.java b/src/main/java/cc/fascinated/bat/base/commands/utility/lookup/LookupCommand.java index 675442d..98a679f 100644 --- a/src/main/java/cc/fascinated/bat/base/commands/utility/lookup/LookupCommand.java +++ b/src/main/java/cc/fascinated/bat/base/commands/utility/lookup/LookupCommand.java @@ -1,8 +1,8 @@ package cc.fascinated.bat.base.commands.utility.lookup; -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.oldcommand.BatCommand; +import cc.fascinated.bat.common.oldcommand.Category; +import cc.fascinated.bat.common.oldcommand.CommandInfo; import lombok.NonNull; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.ApplicationContext; diff --git a/src/main/java/cc/fascinated/bat/base/commands/utility/lookup/UserSubCommand.java b/src/main/java/cc/fascinated/bat/base/commands/utility/lookup/UserSubCommand.java index c25c86f..6df078e 100644 --- a/src/main/java/cc/fascinated/bat/base/commands/utility/lookup/UserSubCommand.java +++ b/src/main/java/cc/fascinated/bat/base/commands/utility/lookup/UserSubCommand.java @@ -1,7 +1,7 @@ package cc.fascinated.bat.base.commands.utility.lookup; -import cc.fascinated.bat.common.command.BatCommand; -import cc.fascinated.bat.common.command.CommandInfo; +import cc.fascinated.bat.common.oldcommand.BatCommand; +import cc.fascinated.bat.common.oldcommand.CommandInfo; import cc.fascinated.bat.common.DescriptionBuilder; import cc.fascinated.bat.common.EmbedUtils; import cc.fascinated.bat.common.model.BatGuild; diff --git a/src/main/java/cc/fascinated/bat/birthday/BirthdayFeature.java b/src/main/java/cc/fascinated/bat/birthday/BirthdayFeature.java index 3bc3d52..2e65d62 100644 --- a/src/main/java/cc/fascinated/bat/birthday/BirthdayFeature.java +++ b/src/main/java/cc/fascinated/bat/birthday/BirthdayFeature.java @@ -6,7 +6,7 @@ import cc.fascinated.bat.common.feature.FeatureProfile; import cc.fascinated.bat.birthday.command.BirthdayCommand; import cc.fascinated.bat.birthday.profile.BirthdayProfile; import cc.fascinated.bat.common.model.BatGuild; -import cc.fascinated.bat.service.CommandService; +import cc.fascinated.bat.service.OldCommandService; import cc.fascinated.bat.service.DiscordService; import cc.fascinated.bat.service.GuildService; import lombok.NonNull; @@ -22,7 +22,7 @@ import org.springframework.stereotype.Component; public class BirthdayFeature extends Feature implements EventListener { private final GuildService guildService; - public BirthdayFeature(@NonNull ApplicationContext context, @NonNull CommandService commandService, @NonNull GuildService guildService) { + public BirthdayFeature(@NonNull ApplicationContext context, @NonNull OldCommandService commandService, @NonNull GuildService guildService) { super("Birthday", FeatureProfile.FeatureState.DISABLED, true); this.guildService = guildService; diff --git a/src/main/java/cc/fascinated/bat/birthday/command/BirthdayCommand.java b/src/main/java/cc/fascinated/bat/birthday/command/BirthdayCommand.java index 000b244..965a4af 100644 --- a/src/main/java/cc/fascinated/bat/birthday/command/BirthdayCommand.java +++ b/src/main/java/cc/fascinated/bat/birthday/command/BirthdayCommand.java @@ -1,8 +1,8 @@ package cc.fascinated.bat.birthday.command; -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.oldcommand.BatCommand; +import cc.fascinated.bat.common.oldcommand.Category; +import cc.fascinated.bat.common.oldcommand.CommandInfo; import lombok.NonNull; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.ApplicationContext; diff --git a/src/main/java/cc/fascinated/bat/birthday/command/ChannelSubCommand.java b/src/main/java/cc/fascinated/bat/birthday/command/ChannelSubCommand.java index 831d32c..1ca2ae2 100644 --- a/src/main/java/cc/fascinated/bat/birthday/command/ChannelSubCommand.java +++ b/src/main/java/cc/fascinated/bat/birthday/command/ChannelSubCommand.java @@ -1,7 +1,7 @@ package cc.fascinated.bat.birthday.command; -import cc.fascinated.bat.common.command.BatCommand; -import cc.fascinated.bat.common.command.CommandInfo; +import cc.fascinated.bat.common.oldcommand.BatCommand; +import cc.fascinated.bat.common.oldcommand.CommandInfo; import cc.fascinated.bat.common.EmbedUtils; import cc.fascinated.bat.common.TextChannelUtils; import cc.fascinated.bat.birthday.profile.BirthdayProfile; diff --git a/src/main/java/cc/fascinated/bat/birthday/command/MessageSubCommand.java b/src/main/java/cc/fascinated/bat/birthday/command/MessageSubCommand.java index 1554e09..2641b53 100644 --- a/src/main/java/cc/fascinated/bat/birthday/command/MessageSubCommand.java +++ b/src/main/java/cc/fascinated/bat/birthday/command/MessageSubCommand.java @@ -1,7 +1,7 @@ package cc.fascinated.bat.birthday.command; -import cc.fascinated.bat.common.command.BatCommand; -import cc.fascinated.bat.common.command.CommandInfo; +import cc.fascinated.bat.common.oldcommand.BatCommand; +import cc.fascinated.bat.common.oldcommand.CommandInfo; import cc.fascinated.bat.common.EmbedUtils; import cc.fascinated.bat.birthday.profile.BirthdayProfile; import cc.fascinated.bat.common.model.BatGuild; diff --git a/src/main/java/cc/fascinated/bat/birthday/command/PrivateSubCommand.java b/src/main/java/cc/fascinated/bat/birthday/command/PrivateSubCommand.java index 1488d7e..a56549d 100644 --- a/src/main/java/cc/fascinated/bat/birthday/command/PrivateSubCommand.java +++ b/src/main/java/cc/fascinated/bat/birthday/command/PrivateSubCommand.java @@ -1,7 +1,7 @@ package cc.fascinated.bat.birthday.command; -import cc.fascinated.bat.common.command.BatCommand; -import cc.fascinated.bat.common.command.CommandInfo; +import cc.fascinated.bat.common.oldcommand.BatCommand; +import cc.fascinated.bat.common.oldcommand.CommandInfo; import cc.fascinated.bat.common.EmbedUtils; import cc.fascinated.bat.birthday.UserBirthday; import cc.fascinated.bat.birthday.profile.BirthdayProfile; diff --git a/src/main/java/cc/fascinated/bat/birthday/command/RemoveSubCommand.java b/src/main/java/cc/fascinated/bat/birthday/command/RemoveSubCommand.java index b169d7a..fcad296 100644 --- a/src/main/java/cc/fascinated/bat/birthday/command/RemoveSubCommand.java +++ b/src/main/java/cc/fascinated/bat/birthday/command/RemoveSubCommand.java @@ -1,7 +1,7 @@ package cc.fascinated.bat.birthday.command; -import cc.fascinated.bat.common.command.BatCommand; -import cc.fascinated.bat.common.command.CommandInfo; +import cc.fascinated.bat.common.oldcommand.BatCommand; +import cc.fascinated.bat.common.oldcommand.CommandInfo; import cc.fascinated.bat.common.EmbedUtils; import cc.fascinated.bat.birthday.profile.BirthdayProfile; import cc.fascinated.bat.common.model.BatGuild; diff --git a/src/main/java/cc/fascinated/bat/birthday/command/SetSubCommand.java b/src/main/java/cc/fascinated/bat/birthday/command/SetSubCommand.java index 1e2086b..1c150ac 100644 --- a/src/main/java/cc/fascinated/bat/birthday/command/SetSubCommand.java +++ b/src/main/java/cc/fascinated/bat/birthday/command/SetSubCommand.java @@ -1,7 +1,7 @@ package cc.fascinated.bat.birthday.command; -import cc.fascinated.bat.common.command.BatCommand; -import cc.fascinated.bat.common.command.CommandInfo; +import cc.fascinated.bat.common.oldcommand.BatCommand; +import cc.fascinated.bat.common.oldcommand.CommandInfo; import cc.fascinated.bat.common.EmbedUtils; import cc.fascinated.bat.birthday.UserBirthday; import cc.fascinated.bat.birthday.profile.BirthdayProfile; diff --git a/src/main/java/cc/fascinated/bat/birthday/command/ViewSubCommand.java b/src/main/java/cc/fascinated/bat/birthday/command/ViewSubCommand.java index d8d9564..1fa1bf0 100644 --- a/src/main/java/cc/fascinated/bat/birthday/command/ViewSubCommand.java +++ b/src/main/java/cc/fascinated/bat/birthday/command/ViewSubCommand.java @@ -1,7 +1,7 @@ package cc.fascinated.bat.birthday.command; -import cc.fascinated.bat.common.command.BatCommand; -import cc.fascinated.bat.common.command.CommandInfo; +import cc.fascinated.bat.common.oldcommand.BatCommand; +import cc.fascinated.bat.common.oldcommand.CommandInfo; import cc.fascinated.bat.common.EmbedUtils; import cc.fascinated.bat.birthday.UserBirthday; import cc.fascinated.bat.birthday.profile.BirthdayProfile; diff --git a/src/main/java/cc/fascinated/bat/common/BatEmoji.java b/src/main/java/cc/fascinated/bat/common/BatEmoji.java new file mode 100644 index 0000000..2d3b55b --- /dev/null +++ b/src/main/java/cc/fascinated/bat/common/BatEmoji.java @@ -0,0 +1,44 @@ +package cc.fascinated.bat.common; + +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NonNull; +import lombok.RequiredArgsConstructor; + +/** + * Emojis used by Rufus. + * + * @author Braydon + */ +@AllArgsConstructor @RequiredArgsConstructor @Getter +public enum BatEmoji { + RUFUS("rufus", "1319317309608689674"), + LOADING("loading", "1319483685787013212", true), + SUCCESS("success", "1319483459781132410"), + CROSS("cross", "1319483437928677446"); + + /** + * The name of this emoji. + */ + @NonNull private final String name; + + /** + * The ID of this emoji. + */ + @NonNull private final String id; + + /** + * Whether this emoji is animated. + */ + private boolean animated; + + /** + * Get the formatted emoji. + * + * @return the formatted emoji + */ + @Override @NonNull + public String toString() { + return (animated ? ""; + } +} \ No newline at end of file diff --git a/src/main/java/cc/fascinated/bat/common/InteractionResponder.java b/src/main/java/cc/fascinated/bat/common/InteractionResponder.java new file mode 100644 index 0000000..c0c2d70 --- /dev/null +++ b/src/main/java/cc/fascinated/bat/common/InteractionResponder.java @@ -0,0 +1,294 @@ +package cc.fascinated.bat.common; + +import cc.fascinated.bat.Consts; +import lombok.AllArgsConstructor; +import lombok.NonNull; +import net.dv8tion.jda.api.EmbedBuilder; +import net.dv8tion.jda.api.entities.Message; +import net.dv8tion.jda.api.entities.MessageEmbed; +import net.dv8tion.jda.api.interactions.InteractionHook; +import net.dv8tion.jda.api.interactions.callbacks.IReplyCallback; +import net.dv8tion.jda.api.interactions.components.LayoutComponent; +import net.dv8tion.jda.api.requests.RestAction; +import net.dv8tion.jda.api.requests.restaction.WebhookMessageCreateAction; +import net.dv8tion.jda.api.requests.restaction.interactions.ReplyCallbackAction; + +import java.awt.*; + +/** + * A simple utility class to make + * responding to interactions easier. + * + * @author Braydon + */ +@AllArgsConstructor +public final class InteractionResponder { + /** + * The interaction event to respond to. + */ + @NonNull private final IReplyCallback event; + + /** + * Respond to the interaction with a generic embed. + * + * @param content the content to respond with + * @param args the optional arguments to format the content with + * @return the reply action + */ + @NonNull + public RestAction replyGenericEmbed(@NonNull String content, Object... args) { + return replyGenericEmbed(content, args, (LayoutComponent[]) null); + } + + /** + * Respond to the interaction with a generic embed. + * + * @param content the content to respond with + * @param args the optional arguments to format the content with + * @param components the optional components to add to the message + * @return the reply action + */ + @NonNull + public RestAction replyGenericEmbed(@NonNull String content, Object[] args, LayoutComponent... components) { + return replyGenericEmbed(false, content, args, components); + } + + /** + * Respond to the interaction with a generic embed. + * + * @param ephemeral whether the message should be ephemeral + * @param content the content to respond with + * @param args the optional arguments to format the content with + * @return the reply action + */ + @NonNull + public RestAction replyGenericEmbed(boolean ephemeral, @NonNull String content, Object... args) { + return replyGenericEmbed(ephemeral, content, args, (LayoutComponent[]) null); + } + + /** + * Respond to the interaction with a generic embed. + * + * @param ephemeral whether the message should be ephemeral + * @param content the content to respond with + * @param components the optional components to add to the message + * @return the reply action + */ + @NonNull + public RestAction replyGenericEmbed(boolean ephemeral, @NonNull String content, LayoutComponent... components) { + return replyGenericEmbed(ephemeral, content, null, components); + } + + /** + * Respond to the interaction with a generic embed. + * + * @param ephemeral whether the message should be ephemeral + * @param content the content to respond with + * @param args the optional arguments to format the content with + * @param components the optional components to add to the message + * @return the reply action + */ + @NonNull + public RestAction replyGenericEmbed(boolean ephemeral, @NonNull String content, Object[] args, LayoutComponent... components) { + content = format(content, args); + return reply(ephemeral, buildGenericEmbed(content, args), components); + } + + /** + * Build a generic embed. + * + * @param content the content to respond with + * @param args the optional arguments to format the content with + * @return the embed + */ + @NonNull + public MessageEmbed buildGenericEmbed(@NonNull String content, Object... args) { + content = format(content, args); + return new EmbedBuilder() + .setColor(Colors.DEFAULT) + .setDescription(format(content, args)) + .build(); + } + + /** + * Respond to the interaction with a success embed. + * + * @param content the content to respond with + * @param args the optional arguments to format the content with + * @return the reply action + */ + @NonNull + public RestAction replySuccess(@NonNull String content, Object... args) { + return replySuccess(false, content, args); + } + + /** + * Respond to the interaction with a success embed. + * + * @param content the content to respond with + * @param args the optional arguments to format the content with + * @param components the optional components to add to the message + * @return the reply action + */ + @NonNull + public RestAction replySuccess(@NonNull String content, Object[] args, LayoutComponent... components) { + return replySuccess(false, content, args, components); + } + + /** + * Respond to the interaction with a success embed. + * + * @param ephemeral whether the message should be ephemeral + * @param content the content to respond with + * @param args the optional arguments to format the content with + * @return the reply action + */ + @NonNull + public RestAction replySuccess(boolean ephemeral, @NonNull String content, Object... args) { + return replySuccess(ephemeral, content, args, (LayoutComponent[]) null); + } + + /** + * Respond to the interaction with a success embed. + * + * @param ephemeral whether the message should be ephemeral + * @param content the content to respond with + * @param args the optional arguments to format the content with + * @param components the optional components to add to the message + * @return the reply action + */ + @NonNull + public RestAction replySuccess(boolean ephemeral, @NonNull String content, Object[] args, LayoutComponent... components) { + content = format(content, args); + return reply(ephemeral, new EmbedBuilder() + .setColor(Color.GREEN) + .setDescription(BatEmoji.SUCCESS + " " + content) + .build(), components); + } + + /** + * Respond to the interaction with an error embed. + * + * @param error the error to respond with + * @param args the optional arguments to format the error with + * @return the reply action + */ + @NonNull + public RestAction replyError(@NonNull String error, Object... args) { + return replyError(false, error, args); + } + + /** + * Respond to the interaction with an error embed. + * + * @param ephemeral whether the message should be ephemeral + * @param error the error to respond with + * @param args the optional arguments to format the error with + * @return the reply action + */ + @NonNull + public RestAction replyError(boolean ephemeral, @NonNull String error, Object... args) { + error = format(error, args); + return reply(ephemeral, new EmbedBuilder() + .setColor(Color.RED) + .setDescription(BatEmoji.CROSS + " " + error) + .build()); + } + + /** + * Respond to the interaction with an embed. + * + * @param embed the embed to respond with + * @return the reply action + */ + @NonNull + public RestAction reply(@NonNull MessageEmbed embed) { + return reply(false, embed); + } + + /** + * Respond to the interaction with an embed. + * + * @param embed the embed to respond with + * @param components the optional components to add to the message + * @return the reply action + */ + @NonNull + public RestAction reply(@NonNull MessageEmbed embed, LayoutComponent... components) { + return reply(false, embed, components); + } + + /** + * Respond to the interaction with an embed. + * + * @param ephemeral whether the message should be ephemeral + * @param embed the embed to respond with + * @return the reply action + */ + @NonNull + public RestAction reply(boolean ephemeral, @NonNull MessageEmbed embed) { + return reply(ephemeral, embed, (LayoutComponent[]) null); + } + + /** + * Respond to the interaction with an embed. + * + * @param ephemeral whether the message should be ephemeral + * @param embed the embed to respond with + * @param components the optional components to add to the message + * @return the reply action + */ + @NonNull + public RestAction reply(boolean ephemeral, @NonNull MessageEmbed embed, LayoutComponent... components) { + boolean hasComponents = components != null && (components.length > 0); + if (event.isAcknowledged()) { + WebhookMessageCreateAction action = event.getHook() + .setEphemeral(ephemeral) + .sendMessageEmbeds(embed); + return hasComponents ? action.setComponents(components) : action; + } + ReplyCallbackAction action = event.replyEmbeds(embed).setEphemeral(ephemeral); + return (hasComponents ? action.setComponents(components) : action).flatMap(InteractionHook::retrieveOriginal); + } + + /** + * Respond to the interaction with a message. + * + * @param content the message to respond with + * @param args the optional arguments to format the message with + * @return the reply action + */ + @NonNull + public RestAction reply(@NonNull String content, Object... args) { + return reply(false, content, args); + } + + /** + * Respond to the interaction with a message. + * + * @param ephemeral whether the message should be ephemeral + * @param content the message to respond with + * @param args the optional arguments to format the message with + * @return the reply action + */ + @NonNull + public RestAction reply(boolean ephemeral, @NonNull String content, Object... args) { + content = format(content, args); + if (event.isAcknowledged()) { + return event.getHook().setEphemeral(ephemeral).sendMessage(content); + } + return event.reply(content).setEphemeral(ephemeral).flatMap(InteractionHook::retrieveOriginal); + } + + /** + * Format the given content with the given arguments. + * + * @param content the content to format + * @param args the arguments to format with + * @return the formatted content + */ + @NonNull + private String format(@NonNull String content, Object... args) { + return args != null && (args.length > 0) ? content.formatted(args) : content; + } +} \ No newline at end of file diff --git a/src/main/java/cc/fascinated/bat/common/MiscUtils.java b/src/main/java/cc/fascinated/bat/common/MiscUtils.java new file mode 100644 index 0000000..a94c603 --- /dev/null +++ b/src/main/java/cc/fascinated/bat/common/MiscUtils.java @@ -0,0 +1,96 @@ +package cc.fascinated.bat.common; + +import lombok.NonNull; +import lombok.experimental.UtilityClass; +import net.dv8tion.jda.api.JDA; + +import java.util.Arrays; +import java.util.Objects; +import java.util.stream.Collectors; + +@UtilityClass +public final class MiscUtils { + /** + * Get the invite url for the bot. + * + * @param jda the JDA instance + * @return the invite url + */ + @NonNull + public static String getInviteUrl(@NonNull JDA jda) { + return "https://discord.com/oauth2/authorize?client_id=" + jda.getSelfUser().getId(); + } + + /** + * Convert an array of strings to a single string. + * + * @param lines the lines to convert + * @return the string + */ + @NonNull + public static String arrayToString(String... lines) { + return Arrays.stream(lines) + .filter(Objects::nonNull) + .collect(Collectors.joining("\n")); + } + + /** + * Capitalize the first letter of + * every word in the given string. + * + * @param input the input to capitalize + * @return the capitalized string + */ + @NonNull + public static String capitalize(@NonNull String input) { + input = input.toLowerCase().replace('_', ' '); + StringBuilder result = new StringBuilder(); + boolean capitalizeNext = true; + for (char character : input.toCharArray()) { + if (Character.isSpaceChar(character)) { + capitalizeNext = true; + result.append(character); + } else if (capitalizeNext) { + result.append(Character.toUpperCase(character)); + capitalizeNext = false; + } else { + result.append(character); + } + } + return result.toString(); + } + + /** + * Get the enum constant with the given + * name from the given enum class. + * + * @param enumClass the enum class + * @param enumName the enum name + * @param the enum type + * @return the enum constant, null if not found + */ + public static > T getEnum(@NonNull Class enumClass, String enumName) { + return getEnum(enumClass, enumName, null); + } + + /** + * Get the enum constant with the given + * name from the given enum class. + * + * @param enumClass the enum class + * @param enumName the enum name + * @param defaultValue the default value + * @param the enum type + * @return the enum constant, default value if not found + */ + public static > T getEnum(@NonNull Class enumClass, String enumName, T defaultValue) { + if (enumName == null) { + return defaultValue; + } + try { + return Enum.valueOf(enumClass, enumName); + } catch (IllegalArgumentException ex) { + return defaultValue; + } + } +} diff --git a/src/main/java/cc/fascinated/bat/common/feature/Feature.java b/src/main/java/cc/fascinated/bat/common/feature/Feature.java index 5f9837b..803be01 100644 --- a/src/main/java/cc/fascinated/bat/common/feature/Feature.java +++ b/src/main/java/cc/fascinated/bat/common/feature/Feature.java @@ -1,7 +1,7 @@ package cc.fascinated.bat.common.feature; -import cc.fascinated.bat.common.command.BatCommand; -import cc.fascinated.bat.service.CommandService; +import cc.fascinated.bat.common.oldcommand.BatCommand; +import cc.fascinated.bat.service.OldCommandService; import lombok.Getter; import lombok.NonNull; import lombok.RequiredArgsConstructor; @@ -35,7 +35,7 @@ public abstract class Feature { * @param commandService The command service * @param command The command to register */ - public void registerCommand(@NonNull CommandService commandService, @NonNull BatCommand command) { + public void registerCommand(@NonNull OldCommandService commandService, @NonNull BatCommand command) { command.setFeature(this); for (BatCommand subCommand : command.getSubCommands().values()) { subCommand.setFeature(this); diff --git a/src/main/java/cc/fascinated/bat/common/command/BatCommand.java b/src/main/java/cc/fascinated/bat/common/oldcommand/BatCommand.java similarity index 99% rename from src/main/java/cc/fascinated/bat/common/command/BatCommand.java rename to src/main/java/cc/fascinated/bat/common/oldcommand/BatCommand.java index d1adc8f..e60da20 100644 --- a/src/main/java/cc/fascinated/bat/common/command/BatCommand.java +++ b/src/main/java/cc/fascinated/bat/common/oldcommand/BatCommand.java @@ -1,4 +1,4 @@ -package cc.fascinated.bat.common.command; +package cc.fascinated.bat.common.oldcommand; import cc.fascinated.bat.common.feature.Feature; import cc.fascinated.bat.common.model.BatGuild; diff --git a/src/main/java/cc/fascinated/bat/common/command/Category.java b/src/main/java/cc/fascinated/bat/common/oldcommand/Category.java similarity index 97% rename from src/main/java/cc/fascinated/bat/common/command/Category.java rename to src/main/java/cc/fascinated/bat/common/oldcommand/Category.java index adf1c5b..142ba46 100644 --- a/src/main/java/cc/fascinated/bat/common/command/Category.java +++ b/src/main/java/cc/fascinated/bat/common/oldcommand/Category.java @@ -1,4 +1,4 @@ -package cc.fascinated.bat.common.command; +package cc.fascinated.bat.common.oldcommand; import lombok.AllArgsConstructor; import lombok.Getter; diff --git a/src/main/java/cc/fascinated/bat/common/command/CommandInfo.java b/src/main/java/cc/fascinated/bat/common/oldcommand/CommandInfo.java similarity index 97% rename from src/main/java/cc/fascinated/bat/common/command/CommandInfo.java rename to src/main/java/cc/fascinated/bat/common/oldcommand/CommandInfo.java index 778eb2b..a1b9d4e 100644 --- a/src/main/java/cc/fascinated/bat/common/command/CommandInfo.java +++ b/src/main/java/cc/fascinated/bat/common/oldcommand/CommandInfo.java @@ -1,4 +1,4 @@ -package cc.fascinated.bat.common.command; +package cc.fascinated.bat.common.oldcommand; import net.dv8tion.jda.api.Permission; diff --git a/src/main/java/cc/fascinated/bat/common/command/InternalCommandInfo.java b/src/main/java/cc/fascinated/bat/common/oldcommand/InternalCommandInfo.java similarity index 97% rename from src/main/java/cc/fascinated/bat/common/command/InternalCommandInfo.java rename to src/main/java/cc/fascinated/bat/common/oldcommand/InternalCommandInfo.java index e5bf044..cc4f919 100644 --- a/src/main/java/cc/fascinated/bat/common/command/InternalCommandInfo.java +++ b/src/main/java/cc/fascinated/bat/common/oldcommand/InternalCommandInfo.java @@ -1,4 +1,4 @@ -package cc.fascinated.bat.common.command; +package cc.fascinated.bat.common.oldcommand; import lombok.AccessLevel; import lombok.Getter; diff --git a/src/main/java/cc/fascinated/bat/counter/CounterFeature.java b/src/main/java/cc/fascinated/bat/counter/CounterFeature.java index 9243351..6ad5bbe 100644 --- a/src/main/java/cc/fascinated/bat/counter/CounterFeature.java +++ b/src/main/java/cc/fascinated/bat/counter/CounterFeature.java @@ -3,7 +3,7 @@ package cc.fascinated.bat.counter; import cc.fascinated.bat.common.feature.Feature; import cc.fascinated.bat.common.feature.FeatureProfile; import cc.fascinated.bat.counter.command.CounterCommand; -import cc.fascinated.bat.service.CommandService; +import cc.fascinated.bat.service.OldCommandService; import lombok.NonNull; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.ApplicationContext; @@ -15,7 +15,7 @@ import org.springframework.stereotype.Component; @Component public class CounterFeature extends Feature { @Autowired - public CounterFeature(@NonNull ApplicationContext context, @NonNull CommandService commandService) { + public CounterFeature(@NonNull ApplicationContext context, @NonNull OldCommandService commandService) { super("Counter", FeatureProfile.FeatureState.DISABLED, true); super.registerCommand(commandService, context.getBean(CounterCommand.class)); diff --git a/src/main/java/cc/fascinated/bat/counter/command/CounterCommand.java b/src/main/java/cc/fascinated/bat/counter/command/CounterCommand.java index e8f6182..b270757 100644 --- a/src/main/java/cc/fascinated/bat/counter/command/CounterCommand.java +++ b/src/main/java/cc/fascinated/bat/counter/command/CounterCommand.java @@ -1,7 +1,7 @@ package cc.fascinated.bat.counter.command; -import cc.fascinated.bat.common.command.BatCommand; -import cc.fascinated.bat.common.command.CommandInfo; +import cc.fascinated.bat.common.oldcommand.BatCommand; +import cc.fascinated.bat.common.oldcommand.CommandInfo; import lombok.NonNull; import net.dv8tion.jda.api.Permission; import org.springframework.beans.factory.annotation.Autowired; diff --git a/src/main/java/cc/fascinated/bat/counter/command/RemoveSubCommand.java b/src/main/java/cc/fascinated/bat/counter/command/RemoveSubCommand.java index 07967b0..4b89abd 100644 --- a/src/main/java/cc/fascinated/bat/counter/command/RemoveSubCommand.java +++ b/src/main/java/cc/fascinated/bat/counter/command/RemoveSubCommand.java @@ -1,8 +1,8 @@ package cc.fascinated.bat.counter.command; import cc.fascinated.bat.Emojis; -import cc.fascinated.bat.common.command.BatCommand; -import cc.fascinated.bat.common.command.CommandInfo; +import cc.fascinated.bat.common.oldcommand.BatCommand; +import cc.fascinated.bat.common.oldcommand.CommandInfo; import cc.fascinated.bat.common.EmbedUtils; import cc.fascinated.bat.common.NumberFormatter; import cc.fascinated.bat.counter.CounterChannel; diff --git a/src/main/java/cc/fascinated/bat/counter/command/SetBreakingSubCommand.java b/src/main/java/cc/fascinated/bat/counter/command/SetBreakingSubCommand.java index 3445f85..702b21a 100644 --- a/src/main/java/cc/fascinated/bat/counter/command/SetBreakingSubCommand.java +++ b/src/main/java/cc/fascinated/bat/counter/command/SetBreakingSubCommand.java @@ -1,8 +1,8 @@ package cc.fascinated.bat.counter.command; import cc.fascinated.bat.Emojis; -import cc.fascinated.bat.common.command.BatCommand; -import cc.fascinated.bat.common.command.CommandInfo; +import cc.fascinated.bat.common.oldcommand.BatCommand; +import cc.fascinated.bat.common.oldcommand.CommandInfo; import cc.fascinated.bat.common.EmbedUtils; import cc.fascinated.bat.counter.CounterChannel; import cc.fascinated.bat.counter.CounterProfile; diff --git a/src/main/java/cc/fascinated/bat/counter/command/SetSubCommand.java b/src/main/java/cc/fascinated/bat/counter/command/SetSubCommand.java index e391d48..a13a37c 100644 --- a/src/main/java/cc/fascinated/bat/counter/command/SetSubCommand.java +++ b/src/main/java/cc/fascinated/bat/counter/command/SetSubCommand.java @@ -1,8 +1,8 @@ package cc.fascinated.bat.counter.command; import cc.fascinated.bat.Emojis; -import cc.fascinated.bat.common.command.BatCommand; -import cc.fascinated.bat.common.command.CommandInfo; +import cc.fascinated.bat.common.oldcommand.BatCommand; +import cc.fascinated.bat.common.oldcommand.CommandInfo; import cc.fascinated.bat.common.EmbedUtils; import cc.fascinated.bat.counter.CounterChannel; import cc.fascinated.bat.counter.CounterProfile; diff --git a/src/main/java/cc/fascinated/bat/counter/command/SetupSubCommand.java b/src/main/java/cc/fascinated/bat/counter/command/SetupSubCommand.java index 78e009f..bb5e0c7 100644 --- a/src/main/java/cc/fascinated/bat/counter/command/SetupSubCommand.java +++ b/src/main/java/cc/fascinated/bat/counter/command/SetupSubCommand.java @@ -1,8 +1,8 @@ package cc.fascinated.bat.counter.command; import cc.fascinated.bat.Emojis; -import cc.fascinated.bat.common.command.BatCommand; -import cc.fascinated.bat.common.command.CommandInfo; +import cc.fascinated.bat.common.oldcommand.BatCommand; +import cc.fascinated.bat.common.oldcommand.CommandInfo; import cc.fascinated.bat.common.EmbedUtils; import cc.fascinated.bat.counter.CounterProfile; import cc.fascinated.bat.common.model.BatGuild; diff --git a/src/main/java/cc/fascinated/bat/leveling/LevelingFeature.java b/src/main/java/cc/fascinated/bat/leveling/LevelingFeature.java index 8ab90d5..a6228ee 100644 --- a/src/main/java/cc/fascinated/bat/leveling/LevelingFeature.java +++ b/src/main/java/cc/fascinated/bat/leveling/LevelingFeature.java @@ -3,7 +3,7 @@ package cc.fascinated.bat.leveling; import cc.fascinated.bat.common.feature.Feature; import cc.fascinated.bat.common.feature.FeatureProfile; import cc.fascinated.bat.leveling.command.LevelingCommand; -import cc.fascinated.bat.service.CommandService; +import cc.fascinated.bat.service.OldCommandService; import lombok.NonNull; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.ApplicationContext; @@ -23,7 +23,7 @@ public class LevelingFeature extends Feature { public static final Map xpRequiredCache = new HashMap<>(); @Autowired - public LevelingFeature(@NonNull ApplicationContext context, @NonNull CommandService commandService) { + public LevelingFeature(@NonNull ApplicationContext context, @NonNull OldCommandService commandService) { super("Leveling", FeatureProfile.FeatureState.DISABLED, true); super.registerCommand(commandService, context.getBean(LevelingCommand.class)); diff --git a/src/main/java/cc/fascinated/bat/leveling/command/ChannelSubCommand.java b/src/main/java/cc/fascinated/bat/leveling/command/ChannelSubCommand.java index 8c11421..841d8ac 100644 --- a/src/main/java/cc/fascinated/bat/leveling/command/ChannelSubCommand.java +++ b/src/main/java/cc/fascinated/bat/leveling/command/ChannelSubCommand.java @@ -1,7 +1,7 @@ package cc.fascinated.bat.leveling.command; -import cc.fascinated.bat.common.command.BatCommand; -import cc.fascinated.bat.common.command.CommandInfo; +import cc.fascinated.bat.common.oldcommand.BatCommand; +import cc.fascinated.bat.common.oldcommand.CommandInfo; import cc.fascinated.bat.common.EmbedUtils; import cc.fascinated.bat.leveling.LevelingProfile; import cc.fascinated.bat.common.model.BatGuild; diff --git a/src/main/java/cc/fascinated/bat/leveling/command/CurrentSubCommand.java b/src/main/java/cc/fascinated/bat/leveling/command/CurrentSubCommand.java index b86854f..c5efafd 100644 --- a/src/main/java/cc/fascinated/bat/leveling/command/CurrentSubCommand.java +++ b/src/main/java/cc/fascinated/bat/leveling/command/CurrentSubCommand.java @@ -1,7 +1,7 @@ package cc.fascinated.bat.leveling.command; -import cc.fascinated.bat.common.command.BatCommand; -import cc.fascinated.bat.common.command.CommandInfo; +import cc.fascinated.bat.common.oldcommand.BatCommand; +import cc.fascinated.bat.common.oldcommand.CommandInfo; import cc.fascinated.bat.common.DescriptionBuilder; import cc.fascinated.bat.common.EmbedUtils; import cc.fascinated.bat.common.NumberFormatter; diff --git a/src/main/java/cc/fascinated/bat/leveling/command/LevelingCommand.java b/src/main/java/cc/fascinated/bat/leveling/command/LevelingCommand.java index e9cb06d..41d6911 100644 --- a/src/main/java/cc/fascinated/bat/leveling/command/LevelingCommand.java +++ b/src/main/java/cc/fascinated/bat/leveling/command/LevelingCommand.java @@ -1,7 +1,7 @@ package cc.fascinated.bat.leveling.command; -import cc.fascinated.bat.common.command.BatCommand; -import cc.fascinated.bat.common.command.CommandInfo; +import cc.fascinated.bat.common.oldcommand.BatCommand; +import cc.fascinated.bat.common.oldcommand.CommandInfo; import lombok.NonNull; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.ApplicationContext; diff --git a/src/main/java/cc/fascinated/bat/leveling/command/ResetSubCommand.java b/src/main/java/cc/fascinated/bat/leveling/command/ResetSubCommand.java index d049205..ef08520 100644 --- a/src/main/java/cc/fascinated/bat/leveling/command/ResetSubCommand.java +++ b/src/main/java/cc/fascinated/bat/leveling/command/ResetSubCommand.java @@ -1,7 +1,7 @@ package cc.fascinated.bat.leveling.command; -import cc.fascinated.bat.common.command.BatCommand; -import cc.fascinated.bat.common.command.CommandInfo; +import cc.fascinated.bat.common.oldcommand.BatCommand; +import cc.fascinated.bat.common.oldcommand.CommandInfo; import cc.fascinated.bat.common.EmbedUtils; import cc.fascinated.bat.leveling.LevelingProfile; import cc.fascinated.bat.leveling.UserLevel; diff --git a/src/main/java/cc/fascinated/bat/logging/LogFeature.java b/src/main/java/cc/fascinated/bat/logging/LogFeature.java index 2194220..245349b 100644 --- a/src/main/java/cc/fascinated/bat/logging/LogFeature.java +++ b/src/main/java/cc/fascinated/bat/logging/LogFeature.java @@ -7,7 +7,7 @@ import cc.fascinated.bat.common.feature.FeatureProfile; import cc.fascinated.bat.logging.command.LogsCommand; import cc.fascinated.bat.common.model.BatGuild; import cc.fascinated.bat.common.model.DiscordMessage; -import cc.fascinated.bat.service.CommandService; +import cc.fascinated.bat.service.OldCommandService; import lombok.NonNull; import net.dv8tion.jda.api.entities.MessageEmbed; import net.dv8tion.jda.api.entities.channel.concrete.TextChannel; @@ -27,7 +27,7 @@ public class LogFeature extends Feature { public static LogFeature INSTANCE; @Autowired - public LogFeature(@NonNull ApplicationContext context, @NonNull CommandService commandService) { + public LogFeature(@NonNull ApplicationContext context, @NonNull OldCommandService commandService) { super("Logging", FeatureProfile.FeatureState.DISABLED, true); INSTANCE = this; diff --git a/src/main/java/cc/fascinated/bat/logging/command/ListSubCommand.java b/src/main/java/cc/fascinated/bat/logging/command/ListSubCommand.java index 0c65dce..26c78db 100644 --- a/src/main/java/cc/fascinated/bat/logging/command/ListSubCommand.java +++ b/src/main/java/cc/fascinated/bat/logging/command/ListSubCommand.java @@ -1,8 +1,8 @@ package cc.fascinated.bat.logging.command; import cc.fascinated.bat.Emojis; -import cc.fascinated.bat.common.command.BatCommand; -import cc.fascinated.bat.common.command.CommandInfo; +import cc.fascinated.bat.common.oldcommand.BatCommand; +import cc.fascinated.bat.common.oldcommand.CommandInfo; import cc.fascinated.bat.common.DescriptionBuilder; import cc.fascinated.bat.common.EmbedUtils; import cc.fascinated.bat.common.InteractionBuilder; diff --git a/src/main/java/cc/fascinated/bat/logging/command/LogsCommand.java b/src/main/java/cc/fascinated/bat/logging/command/LogsCommand.java index e989674..ee85666 100644 --- a/src/main/java/cc/fascinated/bat/logging/command/LogsCommand.java +++ b/src/main/java/cc/fascinated/bat/logging/command/LogsCommand.java @@ -1,8 +1,8 @@ package cc.fascinated.bat.logging.command; -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.oldcommand.BatCommand; +import cc.fascinated.bat.common.oldcommand.Category; +import cc.fascinated.bat.common.oldcommand.CommandInfo; import lombok.NonNull; import net.dv8tion.jda.api.Permission; import org.springframework.beans.factory.annotation.Autowired; diff --git a/src/main/java/cc/fascinated/bat/logging/command/RemoveSubCommand.java b/src/main/java/cc/fascinated/bat/logging/command/RemoveSubCommand.java index 1874599..22d457b 100644 --- a/src/main/java/cc/fascinated/bat/logging/command/RemoveSubCommand.java +++ b/src/main/java/cc/fascinated/bat/logging/command/RemoveSubCommand.java @@ -1,8 +1,8 @@ package cc.fascinated.bat.logging.command; import cc.fascinated.bat.Emojis; -import cc.fascinated.bat.common.command.BatCommand; -import cc.fascinated.bat.common.command.CommandInfo; +import cc.fascinated.bat.common.oldcommand.BatCommand; +import cc.fascinated.bat.common.oldcommand.CommandInfo; import cc.fascinated.bat.common.DescriptionBuilder; import cc.fascinated.bat.common.EmbedUtils; import cc.fascinated.bat.logging.LogCategory; diff --git a/src/main/java/cc/fascinated/bat/logging/command/SetSubCommand.java b/src/main/java/cc/fascinated/bat/logging/command/SetSubCommand.java index fa2abc3..e5358e2 100644 --- a/src/main/java/cc/fascinated/bat/logging/command/SetSubCommand.java +++ b/src/main/java/cc/fascinated/bat/logging/command/SetSubCommand.java @@ -1,8 +1,8 @@ package cc.fascinated.bat.logging.command; import cc.fascinated.bat.Emojis; -import cc.fascinated.bat.common.command.BatCommand; -import cc.fascinated.bat.common.command.CommandInfo; +import cc.fascinated.bat.common.oldcommand.BatCommand; +import cc.fascinated.bat.common.oldcommand.CommandInfo; import cc.fascinated.bat.common.DescriptionBuilder; import cc.fascinated.bat.common.EmbedUtils; import cc.fascinated.bat.logging.LogCategory; diff --git a/src/main/java/cc/fascinated/bat/messagesnipe/MessageSnipeFeature.java b/src/main/java/cc/fascinated/bat/messagesnipe/MessageSnipeFeature.java index 805fa92..aad447f 100644 --- a/src/main/java/cc/fascinated/bat/messagesnipe/MessageSnipeFeature.java +++ b/src/main/java/cc/fascinated/bat/messagesnipe/MessageSnipeFeature.java @@ -7,7 +7,7 @@ import cc.fascinated.bat.messagesnipe.command.MessageSnipeCommand; import cc.fascinated.bat.common.model.BatGuild; import cc.fascinated.bat.common.model.BatUser; import cc.fascinated.bat.common.model.DiscordMessage; -import cc.fascinated.bat.service.CommandService; +import cc.fascinated.bat.service.OldCommandService; import lombok.NonNull; import net.dv8tion.jda.api.events.message.MessageDeleteEvent; import net.dv8tion.jda.api.events.message.MessageReceivedEvent; @@ -31,7 +31,7 @@ public class MessageSnipeFeature extends Feature implements EventListener { private static final long SNIPED_MESSAGE_EXPIRATION = TimeUnit.HOURS.toMillis(1); @Autowired - public MessageSnipeFeature(@NonNull ApplicationContext context, @NonNull CommandService commandService) { + public MessageSnipeFeature(@NonNull ApplicationContext context, @NonNull OldCommandService commandService) { super("Message Snipe", FeatureProfile.FeatureState.DISABLED, true); super.registerCommand(commandService, context.getBean(MessageSnipeCommand.class)); diff --git a/src/main/java/cc/fascinated/bat/messagesnipe/command/ClearSubCommand.java b/src/main/java/cc/fascinated/bat/messagesnipe/command/ClearSubCommand.java index 92fb072..d758387 100644 --- a/src/main/java/cc/fascinated/bat/messagesnipe/command/ClearSubCommand.java +++ b/src/main/java/cc/fascinated/bat/messagesnipe/command/ClearSubCommand.java @@ -1,7 +1,7 @@ package cc.fascinated.bat.messagesnipe.command; -import cc.fascinated.bat.common.command.BatCommand; -import cc.fascinated.bat.common.command.CommandInfo; +import cc.fascinated.bat.common.oldcommand.BatCommand; +import cc.fascinated.bat.common.oldcommand.CommandInfo; import cc.fascinated.bat.common.EmbedUtils; import cc.fascinated.bat.messagesnipe.MessageSnipeFeature; import cc.fascinated.bat.common.model.BatGuild; diff --git a/src/main/java/cc/fascinated/bat/messagesnipe/command/DeletedSubCommand.java b/src/main/java/cc/fascinated/bat/messagesnipe/command/DeletedSubCommand.java index 8f045a3..4c728c5 100644 --- a/src/main/java/cc/fascinated/bat/messagesnipe/command/DeletedSubCommand.java +++ b/src/main/java/cc/fascinated/bat/messagesnipe/command/DeletedSubCommand.java @@ -1,7 +1,7 @@ package cc.fascinated.bat.messagesnipe.command; -import cc.fascinated.bat.common.command.BatCommand; -import cc.fascinated.bat.common.command.CommandInfo; +import cc.fascinated.bat.common.oldcommand.BatCommand; +import cc.fascinated.bat.common.oldcommand.CommandInfo; import cc.fascinated.bat.common.DescriptionBuilder; import cc.fascinated.bat.common.EmbedUtils; import cc.fascinated.bat.common.PasteUtils; diff --git a/src/main/java/cc/fascinated/bat/messagesnipe/command/MessageSnipeCommand.java b/src/main/java/cc/fascinated/bat/messagesnipe/command/MessageSnipeCommand.java index 3e6fd65..1516981 100644 --- a/src/main/java/cc/fascinated/bat/messagesnipe/command/MessageSnipeCommand.java +++ b/src/main/java/cc/fascinated/bat/messagesnipe/command/MessageSnipeCommand.java @@ -1,8 +1,8 @@ package cc.fascinated.bat.messagesnipe.command; -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.oldcommand.BatCommand; +import cc.fascinated.bat.common.oldcommand.Category; +import cc.fascinated.bat.common.oldcommand.CommandInfo; import lombok.NonNull; import org.springframework.context.ApplicationContext; import org.springframework.stereotype.Component; diff --git a/src/main/java/cc/fascinated/bat/moderation/ModerationFeature.java b/src/main/java/cc/fascinated/bat/moderation/ModerationFeature.java index 880563a..13df9e2 100644 --- a/src/main/java/cc/fascinated/bat/moderation/ModerationFeature.java +++ b/src/main/java/cc/fascinated/bat/moderation/ModerationFeature.java @@ -8,7 +8,7 @@ import cc.fascinated.bat.moderation.punish.Punishment; import cc.fascinated.bat.moderation.punish.PunishmentProfile; import cc.fascinated.bat.common.model.BatGuild; import cc.fascinated.bat.common.model.BatUser; -import cc.fascinated.bat.service.CommandService; +import cc.fascinated.bat.service.OldCommandService; import cc.fascinated.bat.service.DiscordService; import cc.fascinated.bat.service.GuildService; import cc.fascinated.bat.service.UserService; @@ -37,7 +37,7 @@ public class ModerationFeature extends Feature implements EventListener { private final UserService userService; @Autowired - public ModerationFeature(@NonNull ApplicationContext context, @NonNull CommandService commandService, @NonNull GuildService guildService, + public ModerationFeature(@NonNull ApplicationContext context, @NonNull OldCommandService commandService, @NonNull GuildService guildService, @NonNull UserService userService) { super("Moderation", FeatureProfile.FeatureState.DISABLED, true); this.guildService = guildService; diff --git a/src/main/java/cc/fascinated/bat/moderation/command/BanCommand.java b/src/main/java/cc/fascinated/bat/moderation/command/BanCommand.java index 286ce56..b92f4b3 100644 --- a/src/main/java/cc/fascinated/bat/moderation/command/BanCommand.java +++ b/src/main/java/cc/fascinated/bat/moderation/command/BanCommand.java @@ -1,7 +1,7 @@ package cc.fascinated.bat.moderation.command; -import cc.fascinated.bat.common.command.BatCommand; -import cc.fascinated.bat.common.command.CommandInfo; +import cc.fascinated.bat.common.oldcommand.BatCommand; +import cc.fascinated.bat.common.oldcommand.CommandInfo; import cc.fascinated.bat.common.EmbedUtils; import cc.fascinated.bat.common.TimeUtils; import cc.fascinated.bat.moderation.punish.PunishmentProfile; diff --git a/src/main/java/cc/fascinated/bat/moderation/command/KickCommand.java b/src/main/java/cc/fascinated/bat/moderation/command/KickCommand.java index 4de28bf..32f045c 100644 --- a/src/main/java/cc/fascinated/bat/moderation/command/KickCommand.java +++ b/src/main/java/cc/fascinated/bat/moderation/command/KickCommand.java @@ -1,7 +1,7 @@ package cc.fascinated.bat.moderation.command; -import cc.fascinated.bat.common.command.BatCommand; -import cc.fascinated.bat.common.command.CommandInfo; +import cc.fascinated.bat.common.oldcommand.BatCommand; +import cc.fascinated.bat.common.oldcommand.CommandInfo; import cc.fascinated.bat.common.EmbedUtils; import cc.fascinated.bat.moderation.punish.PunishmentProfile; import cc.fascinated.bat.moderation.punish.PunishmentType; diff --git a/src/main/java/cc/fascinated/bat/moderation/command/MuteCommand.java b/src/main/java/cc/fascinated/bat/moderation/command/MuteCommand.java index 078cbbd..b695d80 100644 --- a/src/main/java/cc/fascinated/bat/moderation/command/MuteCommand.java +++ b/src/main/java/cc/fascinated/bat/moderation/command/MuteCommand.java @@ -1,7 +1,7 @@ package cc.fascinated.bat.moderation.command; -import cc.fascinated.bat.common.command.BatCommand; -import cc.fascinated.bat.common.command.CommandInfo; +import cc.fascinated.bat.common.oldcommand.BatCommand; +import cc.fascinated.bat.common.oldcommand.CommandInfo; import cc.fascinated.bat.common.EmbedUtils; import cc.fascinated.bat.common.TimeUtils; import cc.fascinated.bat.moderation.punish.PunishmentProfile; diff --git a/src/main/java/cc/fascinated/bat/moderation/command/PunishHistoryCommand.java b/src/main/java/cc/fascinated/bat/moderation/command/PunishHistoryCommand.java index 49cac09..22680a4 100644 --- a/src/main/java/cc/fascinated/bat/moderation/command/PunishHistoryCommand.java +++ b/src/main/java/cc/fascinated/bat/moderation/command/PunishHistoryCommand.java @@ -1,7 +1,7 @@ package cc.fascinated.bat.moderation.command; -import cc.fascinated.bat.common.command.BatCommand; -import cc.fascinated.bat.common.command.CommandInfo; +import cc.fascinated.bat.common.oldcommand.BatCommand; +import cc.fascinated.bat.common.oldcommand.CommandInfo; import cc.fascinated.bat.common.DescriptionBuilder; import cc.fascinated.bat.common.EmbedUtils; import cc.fascinated.bat.moderation.punish.Punishment; diff --git a/src/main/java/cc/fascinated/bat/moderation/command/PurgeCommand.java b/src/main/java/cc/fascinated/bat/moderation/command/PurgeCommand.java index a93e20d..4969dbf 100644 --- a/src/main/java/cc/fascinated/bat/moderation/command/PurgeCommand.java +++ b/src/main/java/cc/fascinated/bat/moderation/command/PurgeCommand.java @@ -1,8 +1,8 @@ package cc.fascinated.bat.moderation.command; -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.oldcommand.BatCommand; +import cc.fascinated.bat.common.oldcommand.Category; +import cc.fascinated.bat.common.oldcommand.CommandInfo; import cc.fascinated.bat.common.DescriptionBuilder; import cc.fascinated.bat.common.EmbedUtils; import cc.fascinated.bat.common.NumberFormatter; diff --git a/src/main/java/cc/fascinated/bat/moderation/command/UnbanCommand.java b/src/main/java/cc/fascinated/bat/moderation/command/UnbanCommand.java index 60b225e..cbe518e 100644 --- a/src/main/java/cc/fascinated/bat/moderation/command/UnbanCommand.java +++ b/src/main/java/cc/fascinated/bat/moderation/command/UnbanCommand.java @@ -1,7 +1,7 @@ package cc.fascinated.bat.moderation.command; -import cc.fascinated.bat.common.command.BatCommand; -import cc.fascinated.bat.common.command.CommandInfo; +import cc.fascinated.bat.common.oldcommand.BatCommand; +import cc.fascinated.bat.common.oldcommand.CommandInfo; import cc.fascinated.bat.common.EmbedUtils; import cc.fascinated.bat.moderation.punish.Punishment; import cc.fascinated.bat.moderation.punish.PunishmentProfile; diff --git a/src/main/java/cc/fascinated/bat/moderation/command/UnmuteCommand.java b/src/main/java/cc/fascinated/bat/moderation/command/UnmuteCommand.java index 58de7ff..7d0e2aa 100644 --- a/src/main/java/cc/fascinated/bat/moderation/command/UnmuteCommand.java +++ b/src/main/java/cc/fascinated/bat/moderation/command/UnmuteCommand.java @@ -1,7 +1,7 @@ package cc.fascinated.bat.moderation.command; -import cc.fascinated.bat.common.command.BatCommand; -import cc.fascinated.bat.common.command.CommandInfo; +import cc.fascinated.bat.common.oldcommand.BatCommand; +import cc.fascinated.bat.common.oldcommand.CommandInfo; import cc.fascinated.bat.common.EmbedUtils; import cc.fascinated.bat.moderation.punish.Punishment; import cc.fascinated.bat.moderation.punish.PunishmentProfile; diff --git a/src/main/java/cc/fascinated/bat/moderation/command/WarnCommand.java b/src/main/java/cc/fascinated/bat/moderation/command/WarnCommand.java index 133e409..00b0517 100644 --- a/src/main/java/cc/fascinated/bat/moderation/command/WarnCommand.java +++ b/src/main/java/cc/fascinated/bat/moderation/command/WarnCommand.java @@ -1,7 +1,7 @@ package cc.fascinated.bat.moderation.command; -import cc.fascinated.bat.common.command.BatCommand; -import cc.fascinated.bat.common.command.CommandInfo; +import cc.fascinated.bat.common.oldcommand.BatCommand; +import cc.fascinated.bat.common.oldcommand.CommandInfo; import cc.fascinated.bat.common.EmbedUtils; import cc.fascinated.bat.moderation.punish.PunishmentProfile; import cc.fascinated.bat.moderation.punish.PunishmentType; diff --git a/src/main/java/cc/fascinated/bat/namehistory/NameHistoryFeature.java b/src/main/java/cc/fascinated/bat/namehistory/NameHistoryFeature.java index 669b18d..2aa87d2 100644 --- a/src/main/java/cc/fascinated/bat/namehistory/NameHistoryFeature.java +++ b/src/main/java/cc/fascinated/bat/namehistory/NameHistoryFeature.java @@ -3,7 +3,7 @@ package cc.fascinated.bat.namehistory; import cc.fascinated.bat.common.feature.Feature; import cc.fascinated.bat.common.feature.FeatureProfile; import cc.fascinated.bat.namehistory.command.NameHistoryCommand; -import cc.fascinated.bat.service.CommandService; +import cc.fascinated.bat.service.OldCommandService; import lombok.NonNull; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.ApplicationContext; @@ -17,7 +17,7 @@ public class NameHistoryFeature extends Feature { public static final int NAME_HISTORY_SIZE = 25; @Autowired - public NameHistoryFeature(@NonNull ApplicationContext context, @NonNull CommandService commandService) { + public NameHistoryFeature(@NonNull ApplicationContext context, @NonNull OldCommandService commandService) { super("Name History", FeatureProfile.FeatureState.DISABLED, true); super.registerCommand(commandService, context.getBean(NameHistoryCommand.class)); diff --git a/src/main/java/cc/fascinated/bat/namehistory/command/GuildSubCommand.java b/src/main/java/cc/fascinated/bat/namehistory/command/GuildSubCommand.java index c8d6fe2..28a4d96 100644 --- a/src/main/java/cc/fascinated/bat/namehistory/command/GuildSubCommand.java +++ b/src/main/java/cc/fascinated/bat/namehistory/command/GuildSubCommand.java @@ -1,7 +1,7 @@ package cc.fascinated.bat.namehistory.command; -import cc.fascinated.bat.common.command.BatCommand; -import cc.fascinated.bat.common.command.CommandInfo; +import cc.fascinated.bat.common.oldcommand.BatCommand; +import cc.fascinated.bat.common.oldcommand.CommandInfo; import cc.fascinated.bat.common.EmbedUtils; import cc.fascinated.bat.namehistory.TrackedName; import cc.fascinated.bat.namehistory.profile.guild.NameHistoryProfile; diff --git a/src/main/java/cc/fascinated/bat/namehistory/command/NameHistoryCommand.java b/src/main/java/cc/fascinated/bat/namehistory/command/NameHistoryCommand.java index 6f6177d..9283b89 100644 --- a/src/main/java/cc/fascinated/bat/namehistory/command/NameHistoryCommand.java +++ b/src/main/java/cc/fascinated/bat/namehistory/command/NameHistoryCommand.java @@ -1,8 +1,8 @@ package cc.fascinated.bat.namehistory.command; -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.oldcommand.BatCommand; +import cc.fascinated.bat.common.oldcommand.Category; +import cc.fascinated.bat.common.oldcommand.CommandInfo; import lombok.NonNull; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.ApplicationContext; diff --git a/src/main/java/cc/fascinated/bat/namehistory/command/UserSubCommand.java b/src/main/java/cc/fascinated/bat/namehistory/command/UserSubCommand.java index ad156c0..0da336a 100644 --- a/src/main/java/cc/fascinated/bat/namehistory/command/UserSubCommand.java +++ b/src/main/java/cc/fascinated/bat/namehistory/command/UserSubCommand.java @@ -1,7 +1,7 @@ package cc.fascinated.bat.namehistory.command; -import cc.fascinated.bat.common.command.BatCommand; -import cc.fascinated.bat.common.command.CommandInfo; +import cc.fascinated.bat.common.oldcommand.BatCommand; +import cc.fascinated.bat.common.oldcommand.CommandInfo; import cc.fascinated.bat.common.EmbedUtils; import cc.fascinated.bat.namehistory.TrackedName; import cc.fascinated.bat.namehistory.profile.user.NameHistoryProfile; diff --git a/src/main/java/cc/fascinated/bat/reminder/ReminderFeature.java b/src/main/java/cc/fascinated/bat/reminder/ReminderFeature.java index ace4929..58a402d 100644 --- a/src/main/java/cc/fascinated/bat/reminder/ReminderFeature.java +++ b/src/main/java/cc/fascinated/bat/reminder/ReminderFeature.java @@ -4,7 +4,7 @@ import cc.fascinated.bat.common.feature.Feature; import cc.fascinated.bat.common.feature.FeatureProfile; import cc.fascinated.bat.reminder.command.ReminderCommand; import cc.fascinated.bat.common.model.BatGuild; -import cc.fascinated.bat.service.CommandService; +import cc.fascinated.bat.service.OldCommandService; import cc.fascinated.bat.service.DiscordService; import cc.fascinated.bat.service.GuildService; import lombok.NonNull; @@ -36,7 +36,7 @@ public class ReminderFeature extends Feature { private final GuildService guildService; @Autowired - public ReminderFeature(@NonNull ApplicationContext context, @NonNull CommandService commandService, @NonNull GuildService guildService) { + public ReminderFeature(@NonNull ApplicationContext context, @NonNull OldCommandService commandService, @NonNull GuildService guildService) { super("Reminder", FeatureProfile.FeatureState.DISABLED, true); this.guildService = guildService; diff --git a/src/main/java/cc/fascinated/bat/reminder/command/ClearSubCommand.java b/src/main/java/cc/fascinated/bat/reminder/command/ClearSubCommand.java index 34c0c48..bdc1d9f 100644 --- a/src/main/java/cc/fascinated/bat/reminder/command/ClearSubCommand.java +++ b/src/main/java/cc/fascinated/bat/reminder/command/ClearSubCommand.java @@ -1,7 +1,7 @@ package cc.fascinated.bat.reminder.command; -import cc.fascinated.bat.common.command.BatCommand; -import cc.fascinated.bat.common.command.CommandInfo; +import cc.fascinated.bat.common.oldcommand.BatCommand; +import cc.fascinated.bat.common.oldcommand.CommandInfo; import cc.fascinated.bat.common.EmbedUtils; import cc.fascinated.bat.reminder.ReminderProfile; import cc.fascinated.bat.common.model.BatGuild; diff --git a/src/main/java/cc/fascinated/bat/reminder/command/ListSubCommand.java b/src/main/java/cc/fascinated/bat/reminder/command/ListSubCommand.java index 8004c99..c2a81c9 100644 --- a/src/main/java/cc/fascinated/bat/reminder/command/ListSubCommand.java +++ b/src/main/java/cc/fascinated/bat/reminder/command/ListSubCommand.java @@ -1,7 +1,7 @@ package cc.fascinated.bat.reminder.command; -import cc.fascinated.bat.common.command.BatCommand; -import cc.fascinated.bat.common.command.CommandInfo; +import cc.fascinated.bat.common.oldcommand.BatCommand; +import cc.fascinated.bat.common.oldcommand.CommandInfo; import cc.fascinated.bat.common.DescriptionBuilder; import cc.fascinated.bat.common.EmbedUtils; import cc.fascinated.bat.reminder.Reminder; diff --git a/src/main/java/cc/fascinated/bat/reminder/command/ReminderCommand.java b/src/main/java/cc/fascinated/bat/reminder/command/ReminderCommand.java index b0e10ae..2be8788 100644 --- a/src/main/java/cc/fascinated/bat/reminder/command/ReminderCommand.java +++ b/src/main/java/cc/fascinated/bat/reminder/command/ReminderCommand.java @@ -1,8 +1,8 @@ package cc.fascinated.bat.reminder.command; -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.oldcommand.BatCommand; +import cc.fascinated.bat.common.oldcommand.Category; +import cc.fascinated.bat.common.oldcommand.CommandInfo; import lombok.NonNull; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.ApplicationContext; diff --git a/src/main/java/cc/fascinated/bat/reminder/command/SetSubCommand.java b/src/main/java/cc/fascinated/bat/reminder/command/SetSubCommand.java index 5758332..c3918ad 100644 --- a/src/main/java/cc/fascinated/bat/reminder/command/SetSubCommand.java +++ b/src/main/java/cc/fascinated/bat/reminder/command/SetSubCommand.java @@ -1,7 +1,7 @@ package cc.fascinated.bat.reminder.command; -import cc.fascinated.bat.common.command.BatCommand; -import cc.fascinated.bat.common.command.CommandInfo; +import cc.fascinated.bat.common.oldcommand.BatCommand; +import cc.fascinated.bat.common.oldcommand.CommandInfo; import cc.fascinated.bat.common.EmbedUtils; import cc.fascinated.bat.common.TimeUtils; import cc.fascinated.bat.reminder.Reminder; diff --git a/src/main/java/cc/fascinated/bat/service/CommandService.java b/src/main/java/cc/fascinated/bat/service/CommandService.java index 203b723..49b9670 100644 --- a/src/main/java/cc/fascinated/bat/service/CommandService.java +++ b/src/main/java/cc/fascinated/bat/service/CommandService.java @@ -1,322 +1,293 @@ package cc.fascinated.bat.service; import cc.fascinated.bat.Consts; -import cc.fascinated.bat.common.command.BatCommand; -import cc.fascinated.bat.common.command.Category; -import cc.fascinated.bat.common.EmbedUtils; -import cc.fascinated.bat.config.Config; -import cc.fascinated.bat.common.feature.FeatureProfile; +import cc.fascinated.bat.command.BatCommand; +import cc.fascinated.bat.command.BatSubCommand; +import cc.fascinated.bat.command.CommandCategory; +import cc.fascinated.bat.command.IBatCommand; +import cc.fascinated.bat.command.annotation.BotOwner; +import cc.fascinated.bat.command.annotation.Thinking; +import cc.fascinated.bat.command.command.HelpCommand; +import cc.fascinated.bat.common.InteractionResponder; import cc.fascinated.bat.common.model.BatGuild; -import cc.fascinated.bat.common.model.BatUser; -import io.sentry.Hint; -import io.sentry.Sentry; +import jakarta.annotation.Nonnull; +import jakarta.annotation.PostConstruct; import lombok.Getter; import lombok.NonNull; import lombok.extern.log4j.Log4j2; -import net.dv8tion.jda.api.JDA; import net.dv8tion.jda.api.Permission; import net.dv8tion.jda.api.entities.Guild; import net.dv8tion.jda.api.entities.Member; -import net.dv8tion.jda.api.entities.channel.unions.MessageChannelUnion; +import net.dv8tion.jda.api.events.interaction.command.CommandAutoCompleteInteractionEvent; import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent; -import net.dv8tion.jda.api.events.message.MessageReceivedEvent; import net.dv8tion.jda.api.hooks.ListenerAdapter; import net.dv8tion.jda.api.interactions.commands.Command; +import net.dv8tion.jda.api.interactions.commands.CommandInteractionPayload; +import net.dv8tion.jda.api.interactions.commands.OptionMapping; +import net.dv8tion.jda.api.interactions.commands.build.SlashCommandData; import org.jetbrains.annotations.NotNull; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.annotation.DependsOn; +import org.springframework.boot.info.BuildProperties; import org.springframework.stereotype.Service; import java.util.ArrayList; -import java.util.HashMap; +import java.util.Collections; import java.util.List; -import java.util.Map; +import java.util.Objects; import java.util.stream.Collectors; /** - * @author Fascinated (fascinated7) + * @author Braydon */ -@Service -@Log4j2(topic = "Command Service") -@Getter -@DependsOn("discordService") -public class CommandService extends ListenerAdapter { - public static CommandService INSTANCE; +@Service @Log4j2(topic = "Commands") +public final class CommandService extends ListenerAdapter { + /** + * The guild service to get and create guilds. + */ + public final GuildService guildService; /** - * The registered commands + * The build properties for this app, null if not available. */ - private final Map commands = new HashMap<>(); + private final BuildProperties buildProperties; /** - * The guild service to use + * The currently registered commands. */ - private final GuildService guildService; - - /** - * The user service to use - */ - private final UserService userService; + @Getter private final List registry = Collections.synchronizedList(new ArrayList<>()); @Autowired - public CommandService(@NonNull GuildService guildService, @NonNull UserService userService) { - INSTANCE = this; + public CommandService(@NonNull GuildService guildService, BuildProperties buildProperties) { this.guildService = guildService; - this.userService = userService; + this.buildProperties = buildProperties; DiscordService.JDA.addEventListener(this); } - /** - * Registers a command - * - * @param command The command to register - */ - public void registerCommand(@NonNull BatCommand command) { - String commandName = command.getInfo().getName().toLowerCase(); - if (commands.get(commandName) != null) { - return; - } - log.info("Registered command \"{}\"", command.getInfo().getName()); - commands.put(commandName, command); - } + @PostConstruct + public void onInitialize() { + // Command Registry + registerCommand(new HelpCommand(this, buildProperties)); + log.info("Registered {} commands", registry.size()); - /** - * Registers all slash commands - */ - public void registerSlashCommands() { - log.info("Registering all slash commands"); - JDA jda = DiscordService.JDA; - long before = System.currentTimeMillis(); + // Send the commands to the guilds + log.info("Sending {} commands to guilds...", registry.size()); + List commandData = registry.stream() + .map(BatCommand::getCommandData) + .toList(); - Guild adminGuild = jda.getGuildById(Config.INSTANCE.getAdminGuild()); - if (!Config.isProduction()) { - if (adminGuild == null) { - log.error("Unable to find the admin guild to register commands"); - return; - } - jda.retrieveCommands().complete().forEach(command -> jda.deleteCommandById(command.getId()).complete()); - List registeredCommands = adminGuild.updateCommands().addCommands(commands.values().stream().map(BatCommand::getCommandData).toList()).complete(); - log.info("Registered {} slash commands in {}ms (DEV MODE)", registeredCommands.size(), System.currentTimeMillis() - before); - return; - } + // the amount of indents here should be illegal + for (Guild guild : DiscordService.JDA.getGuilds()) { + log.info("Queueing {} commands for guild {}", commandData.size(), guild.getName()); + guild.updateCommands().addCommands(commandData).queue(registry -> { + // Once sent to Discord, set the snowflake of the commands in our registry + for (Command registeredCommand : registry) { + BatCommand rufusCommand = Objects.requireNonNull(getCommand(registeredCommand.getName())); + rufusCommand.setSnowflake(registeredCommand.getIdLong()); + log.info("Retrieved snowflake {} for command /{}", rufusCommand.getSnowflake(), rufusCommand.getName()); - // Unregister all commands that Discord has but we don't - jda.retrieveCommands().complete().forEach(command -> { - if (commands.containsKey(command.getName()) && commands.get(command.getName()).getInfo().isBotOwnerOnly()) { - jda.deleteCommandById(command.getId()).complete(); // Unregister the command on Discord - log.info("Unregistered hidden command \"{}\" from Discord", command.getName()); - return; - } - if (commands.containsKey(command.getName())) { - return; - } + // Register the sub-command groups + for (Command.SubcommandGroup subCommandGroup : registeredCommand.getSubcommandGroups()) { + for (Command.Subcommand subCommand : subCommandGroup.getSubcommands()) { + String fullName = rufusCommand.getName() + " " + subCommandGroup.getName() + " " + subCommand.getName(); + BatSubCommand rufusSubCommand = Objects.requireNonNull(rufusCommand.getSubCommand(subCommandGroup.getName(), subCommand.getName())); + rufusSubCommand.setSnowflake(subCommand.getIdLong()); + rufusSubCommand.setFullName(fullName); + log.info("Retrieved snowflake {} for sub-command-group /{}", subCommand.getIdLong(), fullName); + } + } - jda.deleteCommandById(command.getId()).complete(); // Unregister the command on Discord - log.info("Unregistered unknown command \"{}\" from Discord", command.getName()); - }); - - // Register all commands - List discordCommands = jda.updateCommands().addCommands(commands.values().stream().filter(command -> !command.getInfo().isBotOwnerOnly()) - .map(BatCommand::getCommandData).toList()).complete(); - for (Command discordCommand : discordCommands) { - commands.get(discordCommand.getName()).setSnowflake(discordCommand.getIdLong()); - if (!discordCommand.getSubcommands().isEmpty()) { - for (Command.Subcommand subCommand : discordCommand.getSubcommands()) { - commands.get(discordCommand.getName()).getSubCommands().get(subCommand.getName()).setSnowflake(subCommand.getIdLong()); + // Register the sub-commands + for (Command.Subcommand subCommand : registeredCommand.getSubcommands()) { + String fullName = rufusCommand.getName() + " " + subCommand.getName(); + BatSubCommand rufusSubCommand = Objects.requireNonNull(rufusCommand.getSubCommand(null, subCommand.getName())); + rufusSubCommand.setSnowflake(subCommand.getIdLong()); + rufusSubCommand.setFullName(fullName); + log.info("Retrieved snowflake {} for sub-command /{}", subCommand.getIdLong(), fullName); + } } - } + }); } - if (adminGuild != null) { - adminGuild.updateCommands().addCommands(commands.values().stream().filter(command -> command.getInfo().isBotOwnerOnly()) - .map(BatCommand::getCommandData).toList()).complete(); - } else { - log.error("Unable to find the admin guild to register hidden commands"); - } - log.info("Registered {} slash commands in {}ms", discordCommands.size(), System.currentTimeMillis() - before); - } - - /** - * Gets commands that are in a specific category - * - * @param category The category - * @param includeGuildCommands If guild commands should be included - * @return The commands - */ - public List getCommandsByCategory(Category category, boolean includeGuildCommands) { - List commands = new ArrayList<>(); - for (BatCommand command : this.commands.values()) { - if (command.getInfo().getCategory() == category - && (includeGuildCommands || command.getInfo().isUserInstall()) - && !command.getInfo().isBotOwnerOnly()) { - commands.add(command); - } - } - return commands; - } - - /** - * Gets a command by its class - * - * @param clazz The class of the command - * @return The command - */ - public BatCommand getCommand(Class clazz) { - for (Map.Entry entry : this.commands.entrySet()) { - if (entry.getValue().getClass().equals(clazz)) { - return entry.getValue(); - } - } - return null; + log.info("Done, commands have been sent to {} guilds", DiscordService.JDA.getGuilds().size()); } @Override public void onSlashCommandInteraction(@NotNull SlashCommandInteractionEvent event) { - if (event.getUser().isBot()) { - return; - } - long before = System.currentTimeMillis(); - BatCommand command = commands.get(event.getName()); - if (command == null) { - return; - } - String subcommandName = event.getSubcommandName(); - if (subcommandName != null) { // Use the sub command if given - command = command.getSubCommands().get(subcommandName); - } - BatUser user = userService.getUser(event.getUser().getId()); - BatGuild guild = event.getGuild() == null ? null : guildService.getGuild(event.getGuild().getId()); + Member member = event.getMember(); + Guild discordGuild = event.getGuild(); + assert member != null && discordGuild != null; + BatGuild guild = guildService.getGuild(discordGuild.getId()); - String executeChecks = runPreExecuteChecks(command, user, guild, event.getMember()); - if (executeChecks != null) { - event.replyEmbeds(EmbedUtils.errorEmbed() - .setDescription(executeChecks) - .build()).setEphemeral(true).queue(); - return; - } - - // Execute the command - try { - MessageChannelUnion channel = event.getChannel(); - command.execute(guild, user, channel, event.getMember(), null, null, event.getInteraction()); - log.info("Executed slash command \"{}\" for user \"{}\" in channel \"{}\" (took: {}ms)", - command.getInfo().getName(), - user.getName(), - channel.getName(), - System.currentTimeMillis() - before - ); - } catch (Exception ex) { - log.error("An error occurred while executing command \"{}\"", command.getInfo().getName(), ex); - event.replyEmbeds(EmbedUtils.genericInteractionError(ex).build()).setEphemeral(true).queue(); - - Hint hint = new Hint(); - hint.set("command", command.getInfo().getName()); - hint.set("user", user.getId()); - if (guild != null) { - hint.set("guild", guild.getId()); + // Execute the command if registered + for (BatCommand parent : registry) { + if (!parent.getName().equals(event.getName())) { + continue; } - Sentry.captureException(ex, hint); // Capture the exception + // Log the executed command + logUsage(discordGuild, guild, member, parent, event.getSubcommandGroup(), event.getSubcommandName(), event); + + // If @Thinking is present, tell discord we received the command, send a thinking... message to the user + if (parent.getClass().isAnnotationPresent(Thinking.class)) { + event.deferReply().queue(); + } + InteractionResponder responder = new InteractionResponder(event); + IBatCommand executor = getExecutor(parent, event); + + // Initial checks before running the command + if (executor.getClass().isAnnotationPresent(BotOwner.class) && !member.getId().equals(Consts.BOT_OWNER)) { + responder.replyError("This command is restricted to the bot owner.").queue(); + return; + } + + // Execute the command + executor.execute(guild, discordGuild, member, responder, event); + break; } } @Override - public void onMessageReceived(@NotNull MessageReceivedEvent event) { - if (event.getAuthor().isBot() || !event.isFromGuild()) { // This message wasn't sent in a guild - return; - } - BatUser user = userService.getUser(event.getAuthor().getId()); - if (user == null) { - return; - } - BatGuild guild = guildService.getGuild(event.getGuild().getId()); - String message = event.getMessage().getContentRaw(); - if (!message.startsWith(guild.getPrefix())) { // Check if the message starts with the guild prefix - return; - } + public void onCommandAutoCompleteInteraction(@NotNull CommandAutoCompleteInteractionEvent event) { + Member member = event.getMember(); + Guild discordGuild = event.getGuild(); + assert member != null && discordGuild != null; + BatGuild guild = guildService.getGuild(discordGuild.getId()); - String[] parts = message.substring(guild.getPrefix().length()).split("\\s+"); - String commandName = parts[0].toLowerCase(); - String[] args = parts.length > 1 ? new String[parts.length - 1] : new String[0]; - if (args.length > 0) { - System.arraycopy(parts, 1, args, 0, args.length); - } - BatCommand command = commands.get(commandName); - if (command == null) { + // Auto complete the command if registered + IBatCommand executor = getExecutor(event); + if (executor == null) { return; } - if (!command.getInfo().isPrefixAllowed()) { // Check if the command is allowed to be ran with a prefix + List choices = executor.autoComplete(guild, discordGuild, member, event); + if (choices.isEmpty()) { return; } - - String executeChecks = runPreExecuteChecks(command, user, guild, event.getMember()); - if (executeChecks != null) { - event.getChannel().sendMessageEmbeds(EmbedUtils.errorEmbed() - .setDescription(executeChecks) - .build()).queue(); - return; - } - - // Execute the command - try { - command.execute(guild, user, event.getChannel(), event.getMember(), event.getMessage(), args, null); - log.info("Executed prefixed command \"{}{}\" for user \"{}\" in channel \"{}\"", - command.getInfo().getName(), - args.length > 0 ? " " + String.join(" ", args) : "", - user.getName(), - event.getChannel().getName() - ); - } catch (Exception ex) { - log.error("An error occurred while executing command \"{}\"", command.getInfo().getName(), ex); - event.getChannel().sendMessageEmbeds(EmbedUtils.genericInteractionError(ex).build()).queue(); - - Hint hint = new Hint(); - hint.set("command", command.getInfo().getName()); - hint.set("user", user.getId()); - hint.set("guild", guild.getId()); - Sentry.captureException(ex, hint); // Capture the exception - } + event.replyChoices(choices.stream() + .filter(choice -> choice.getName().startsWith(event.getFocusedOption().getValue())) + .collect(Collectors.toList())).queue(); } /** - * Runs pre execute checks for a command + * Register a command. * - * @param command The command - * @param user The user - * @param guild The guild - * @param member The member - * @return The error message if any + * @param command the command */ - public String runPreExecuteChecks(BatCommand command, BatUser user, BatGuild guild, Member member) { - // Only the bot owner can run this command - if (command.getInfo().isBotOwnerOnly() && !user.getId().equalsIgnoreCase(Consts.BOT_OWNER)) { - return "You do not have permission to execute this command"; - } + private void registerCommand(@NonNull BatCommand command) { + registry.add(command); + log.info("Registered command: /{}", command.getCommandData().getName()); + } - // Check if the command is guild only and if it was not ran inside a guild - if (command.getInfo().isGuildOnly() && guild == null) { - return "This command can only be executed in a guild"; - } + /** + * Get the commands in a category + * the given member has access to. + * + * @param member the member to get the commands for + * @param category the category to get the commands for + * @return the commands the member has + */ + @NonNull + public List getCommands(@Nonnull Member member, @NonNull CommandCategory category) { + // Collect all the commands in this category + List categoryCommands = registry.stream() + .filter(command -> { + // Not the right category + if (command.getCategory() != category) { + return false; + } + // Return the commands the user has access to + Long rawPermissions = command.getCommandData().getDefaultPermissions().getPermissionsRaw(); + return rawPermissions == null || (member.getPermissions().containsAll(Permission.getPermissions(rawPermissions))); + }) + .collect(Collectors.toList()); - // Check if the feature is disabled in the guild - if (guild != null) { - FeatureProfile featureProfile = guild.getFeatureProfile(); - if (featureProfile.isFeatureDisabled(command.getFeature())) { - return "The feature `%s` is disabled in this guild".formatted(command.getFeature().getName()); - } - } + // Add all the sub-commands from the parents + List subCommands = categoryCommands.stream() + .flatMap(parent -> ((BatCommand) parent).getSubCommands().stream()) + .collect(Collectors.toList()); + categoryCommands.addAll(subCommands); - // Check if the user has the required permissions - if (guild != null && member != null) { - List missingPermissions = new ArrayList<>(); - for (Permission permission : command.getInfo().getPermissions()) { - if (!member.hasPermission(permission)) { - missingPermissions.add(permission); - } - } - if (!missingPermissions.isEmpty()) { - return "You are missing the following permissions to execute this command:\n" + - missingPermissions.stream().map(perm -> "`" + perm.name() + "`").collect(Collectors.joining(", ")); + // Finally, remove any parents that have sub-commands as they can't be executed directly + categoryCommands.removeIf(command -> command instanceof BatCommand parentCommand && (!parentCommand.getSubCommands().isEmpty())); + return categoryCommands; + } + + /** + * Get a command by name. + * + * @param name the command name + * @return the command, null if none + */ + public BatCommand getCommand(@NonNull String name) { + for (BatCommand command : registry) { + if (command.getName().equalsIgnoreCase(name)) { + return command; } } return null; } + + /** + * Log the usage of a command. + * + * @param discordGuild the Discord guild the command was executed in + * @param guild the ticket guild the command was executed in + * @param member the member that executed the command + * @param parent the parent command + * @param subCommandGroup the sub-command group, if any + * @param subCommandName the sub-command name, if any + * @param event the event that triggered the command + */ + private void logUsage(@NonNull Guild discordGuild, @NonNull BatGuild guild, @NonNull Member member, @NonNull BatCommand parent, + String subCommandGroup, String subCommandName, @NonNull SlashCommandInteractionEvent event) { + StringBuilder fullCommandName = new StringBuilder(parent.getName()); + if (subCommandGroup != null) { + fullCommandName.append(" ").append(subCommandGroup); + } + if (subCommandName != null) { + fullCommandName.append(" ").append(subCommandName); + } + for (OptionMapping option : event.getOptions()) { + fullCommandName.append(" ").append(option.getName()).append(":").append(option.getAsString()); + } + log.info("User {} (UID: {}) executed '/{}' in guild {} (GID: {})", + member.getUser().getName(), member.getId(), fullCommandName.toString(), discordGuild.getName(), guild.getId() + ); + } + + /** + * Get the command executor for the given event. + * + * @param event the event + * @return the command executor, null if none + */ + private IBatCommand getExecutor(@NonNull CommandInteractionPayload event) { + for (BatCommand parent : registry) { + if (!parent.getName().equals(event.getName())) { + continue; + } + return getExecutor(parent, event); + } + return null; + } + + /** + * Get the command executor for the given command. + * + * @param parent the parent command + * @param event the event + * @return the command executor + */ + @Nonnull + private IBatCommand getExecutor(BatCommand parent, @NonNull CommandInteractionPayload event) { + String subCommandGroup = event.getSubcommandGroup(); + String subCommandName = event.getSubcommandName(); + IBatCommand executor = null; + + // Get the command executor + if (subCommandName != null) { // Try to find the sub-command to execute + executor = parent.getSubCommand(subCommandGroup, subCommandName); + } + if (executor == null) { // Fallback to the parent + executor = parent; + } + return executor; + } } \ No newline at end of file diff --git a/src/main/java/cc/fascinated/bat/service/FeatureService.java b/src/main/java/cc/fascinated/bat/service/FeatureService.java index 9b03df0..ea84edb 100644 --- a/src/main/java/cc/fascinated/bat/service/FeatureService.java +++ b/src/main/java/cc/fascinated/bat/service/FeatureService.java @@ -1,6 +1,6 @@ package cc.fascinated.bat.service; -import cc.fascinated.bat.common.command.BatCommand; +import cc.fascinated.bat.common.oldcommand.BatCommand; import cc.fascinated.bat.common.feature.Feature; import jakarta.annotation.PostConstruct; import lombok.Getter; @@ -25,7 +25,7 @@ import java.util.Map; public class FeatureService { public static FeatureService INSTANCE; private final ApplicationContext context; - private final CommandService commandService; + private final OldCommandService commandService; /** * The registered features @@ -33,7 +33,7 @@ public class FeatureService { private final Map features = new HashMap<>(); @Autowired - public FeatureService(@NonNull ApplicationContext context, @NonNull CommandService commandService) { + public FeatureService(@NonNull ApplicationContext context, @NonNull OldCommandService commandService) { this.context = context; this.commandService = commandService; INSTANCE = this; diff --git a/src/main/java/cc/fascinated/bat/service/GuildService.java b/src/main/java/cc/fascinated/bat/service/GuildService.java index af42b2e..21e8be2 100644 --- a/src/main/java/cc/fascinated/bat/service/GuildService.java +++ b/src/main/java/cc/fascinated/bat/service/GuildService.java @@ -1,10 +1,9 @@ package cc.fascinated.bat.service; -import cc.fascinated.bat.common.command.BatCommand; +import cc.fascinated.bat.common.oldcommand.BatCommand; import cc.fascinated.bat.common.EmbedUtils; import cc.fascinated.bat.common.TimerUtils; import cc.fascinated.bat.event.EventListener; -import cc.fascinated.bat.base.commands.general.HelpCommand; import cc.fascinated.bat.base.commands.server.feature.FeatureCommand; import cc.fascinated.bat.base.commands.server.feature.ListSubCommand; import cc.fascinated.bat.common.model.BatGuild; @@ -118,9 +117,8 @@ public class GuildService extends ListenerAdapter implements EventListener { return; } TextChannel channel = defaultChannel.asTextChannel(); - BatCommand featureCommand = CommandService.INSTANCE.getCommand(FeatureCommand.class); + BatCommand featureCommand = OldCommandService.INSTANCE.getCommand(FeatureCommand.class); BatCommand listSubCommand = featureCommand.getSubCommand(ListSubCommand.class); - BatCommand helpCommand = CommandService.INSTANCE.getCommand(HelpCommand.class); Member owner = guild.getDiscordGuild().getOwner(); if (owner != null) { channel.sendMessage(owner.getAsMention()).queue(); @@ -136,8 +134,6 @@ public class GuildService extends ListenerAdapter implements EventListener { some features may not work as expected without it.** """.formatted( DiscordService.JDA.getSelfUser().getAsMention(), - helpCommand.getInfo().getName(), - helpCommand.getSnowflake(), featureCommand.getInfo().getName(), listSubCommand.getInfo().getName(), listSubCommand.getSnowflake() diff --git a/src/main/java/cc/fascinated/bat/service/OldCommandService.java b/src/main/java/cc/fascinated/bat/service/OldCommandService.java new file mode 100644 index 0000000..9a1a5df --- /dev/null +++ b/src/main/java/cc/fascinated/bat/service/OldCommandService.java @@ -0,0 +1,322 @@ +package cc.fascinated.bat.service; + +import cc.fascinated.bat.Consts; +import cc.fascinated.bat.common.oldcommand.BatCommand; +import cc.fascinated.bat.common.oldcommand.Category; +import cc.fascinated.bat.common.EmbedUtils; +import cc.fascinated.bat.config.Config; +import cc.fascinated.bat.common.feature.FeatureProfile; +import cc.fascinated.bat.common.model.BatGuild; +import cc.fascinated.bat.common.model.BatUser; +import io.sentry.Hint; +import io.sentry.Sentry; +import lombok.Getter; +import lombok.NonNull; +import lombok.extern.log4j.Log4j2; +import net.dv8tion.jda.api.JDA; +import net.dv8tion.jda.api.Permission; +import net.dv8tion.jda.api.entities.Guild; +import net.dv8tion.jda.api.entities.Member; +import net.dv8tion.jda.api.entities.channel.unions.MessageChannelUnion; +import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent; +import net.dv8tion.jda.api.events.message.MessageReceivedEvent; +import net.dv8tion.jda.api.hooks.ListenerAdapter; +import net.dv8tion.jda.api.interactions.commands.Command; +import org.jetbrains.annotations.NotNull; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.DependsOn; +import org.springframework.stereotype.Service; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +/** + * @author Fascinated (fascinated7) + */ +@Service +@Log4j2(topic = "Command Service") +@Getter +@DependsOn("discordService") +public class OldCommandService extends ListenerAdapter { + public static OldCommandService INSTANCE; + + /** + * The registered commands + */ + private final Map commands = new HashMap<>(); + + /** + * The guild service to use + */ + private final GuildService guildService; + + /** + * The user service to use + */ + private final UserService userService; + + @Autowired + public OldCommandService(@NonNull GuildService guildService, @NonNull UserService userService) { + INSTANCE = this; + this.guildService = guildService; + this.userService = userService; + DiscordService.JDA.addEventListener(this); + } + + /** + * Registers a command + * + * @param command The command to register + */ + public void registerCommand(@NonNull BatCommand command) { + String commandName = command.getInfo().getName().toLowerCase(); + if (commands.get(commandName) != null) { + return; + } + log.info("Registered command \"{}\"", command.getInfo().getName()); + commands.put(commandName, command); + } + + /** + * Registers all slash commands + */ + public void registerSlashCommands() { + log.info("Registering all slash commands"); + JDA jda = DiscordService.JDA; + long before = System.currentTimeMillis(); + +// Guild adminGuild = jda.getGuildById(Config.INSTANCE.getAdminGuild()); +// if (!Config.isProduction()) { +// if (adminGuild == null) { +// log.error("Unable to find the admin guild to register commands"); +// return; +// } +// jda.retrieveCommands().complete().forEach(command -> jda.deleteCommandById(command.getId()).complete()); +// List registeredCommands = adminGuild.updateCommands().addCommands(commands.values().stream().map(BatCommand::getCommandData).toList()).complete(); +// log.info("Registered {} slash commands in {}ms (DEV MODE)", registeredCommands.size(), System.currentTimeMillis() - before); +// return; +// } +// +// // Unregister all commands that Discord has but we don't +// jda.retrieveCommands().complete().forEach(command -> { +// if (commands.containsKey(command.getName()) && commands.get(command.getName()).getInfo().isBotOwnerOnly()) { +// jda.deleteCommandById(command.getId()).complete(); // Unregister the command on Discord +// log.info("Unregistered hidden command \"{}\" from Discord", command.getName()); +// return; +// } +// if (commands.containsKey(command.getName())) { +// return; +// } +// +// jda.deleteCommandById(command.getId()).complete(); // Unregister the command on Discord +// log.info("Unregistered unknown command \"{}\" from Discord", command.getName()); +// }); +// +// // Register all commands +// List discordCommands = jda.updateCommands().addCommands(commands.values().stream().filter(command -> !command.getInfo().isBotOwnerOnly()) +// .map(BatCommand::getCommandData).toList()).complete(); +// for (Command discordCommand : discordCommands) { +// commands.get(discordCommand.getName()).setSnowflake(discordCommand.getIdLong()); +// if (!discordCommand.getSubcommands().isEmpty()) { +// for (Command.Subcommand subCommand : discordCommand.getSubcommands()) { +// commands.get(discordCommand.getName()).getSubCommands().get(subCommand.getName()).setSnowflake(subCommand.getIdLong()); +// } +// } +// } +// if (adminGuild != null) { +// adminGuild.updateCommands().addCommands(commands.values().stream().filter(command -> command.getInfo().isBotOwnerOnly()) +// .map(BatCommand::getCommandData).toList()).complete(); +// } else { +// log.error("Unable to find the admin guild to register hidden commands"); +// } +// log.info("Registered {} slash commands in {}ms", discordCommands.size(), System.currentTimeMillis() - before); + } + + /** + * Gets commands that are in a specific category + * + * @param category The category + * @param includeGuildCommands If guild commands should be included + * @return The commands + */ + public List getCommandsByCategory(Category category, boolean includeGuildCommands) { + List commands = new ArrayList<>(); + for (BatCommand command : this.commands.values()) { + if (command.getInfo().getCategory() == category + && (includeGuildCommands || command.getInfo().isUserInstall()) + && !command.getInfo().isBotOwnerOnly()) { + commands.add(command); + } + } + return commands; + } + + /** + * Gets a command by its class + * + * @param clazz The class of the command + * @return The command + */ + public BatCommand getCommand(Class clazz) { + for (Map.Entry entry : this.commands.entrySet()) { + if (entry.getValue().getClass().equals(clazz)) { + return entry.getValue(); + } + } + return null; + } + + @Override + public void onSlashCommandInteraction(@NotNull SlashCommandInteractionEvent event) { + if (event.getUser().isBot()) { + return; + } + long before = System.currentTimeMillis(); + BatCommand command = commands.get(event.getName()); + if (command == null) { + return; + } + String subcommandName = event.getSubcommandName(); + if (subcommandName != null) { // Use the sub command if given + command = command.getSubCommands().get(subcommandName); + } + BatUser user = userService.getUser(event.getUser().getId()); + BatGuild guild = event.getGuild() == null ? null : guildService.getGuild(event.getGuild().getId()); + + String executeChecks = runPreExecuteChecks(command, user, guild, event.getMember()); + if (executeChecks != null) { + event.replyEmbeds(EmbedUtils.errorEmbed() + .setDescription(executeChecks) + .build()).setEphemeral(true).queue(); + return; + } + + // Execute the command + try { + MessageChannelUnion channel = event.getChannel(); + command.execute(guild, user, channel, event.getMember(), null, null, event.getInteraction()); + log.info("Executed slash command \"{}\" for user \"{}\" in channel \"{}\" (took: {}ms)", + command.getInfo().getName(), + user.getName(), + channel.getName(), + System.currentTimeMillis() - before + ); + } catch (Exception ex) { + log.error("An error occurred while executing command \"{}\"", command.getInfo().getName(), ex); + event.replyEmbeds(EmbedUtils.genericInteractionError(ex).build()).setEphemeral(true).queue(); + + Hint hint = new Hint(); + hint.set("command", command.getInfo().getName()); + hint.set("user", user.getId()); + if (guild != null) { + hint.set("guild", guild.getId()); + } + Sentry.captureException(ex, hint); // Capture the exception + } + } + + @Override + public void onMessageReceived(@NotNull MessageReceivedEvent event) { + if (event.getAuthor().isBot() || !event.isFromGuild()) { // This message wasn't sent in a guild + return; + } + BatUser user = userService.getUser(event.getAuthor().getId()); + if (user == null) { + return; + } + BatGuild guild = guildService.getGuild(event.getGuild().getId()); + String message = event.getMessage().getContentRaw(); + if (!message.startsWith(guild.getPrefix())) { // Check if the message starts with the guild prefix + return; + } + + String[] parts = message.substring(guild.getPrefix().length()).split("\\s+"); + String commandName = parts[0].toLowerCase(); + String[] args = parts.length > 1 ? new String[parts.length - 1] : new String[0]; + if (args.length > 0) { + System.arraycopy(parts, 1, args, 0, args.length); + } + BatCommand command = commands.get(commandName); + if (command == null) { + return; + } + if (!command.getInfo().isPrefixAllowed()) { // Check if the command is allowed to be ran with a prefix + return; + } + + String executeChecks = runPreExecuteChecks(command, user, guild, event.getMember()); + if (executeChecks != null) { + event.getChannel().sendMessageEmbeds(EmbedUtils.errorEmbed() + .setDescription(executeChecks) + .build()).queue(); + return; + } + + // Execute the command + try { + command.execute(guild, user, event.getChannel(), event.getMember(), event.getMessage(), args, null); + log.info("Executed prefixed command \"{}{}\" for user \"{}\" in channel \"{}\"", + command.getInfo().getName(), + args.length > 0 ? " " + String.join(" ", args) : "", + user.getName(), + event.getChannel().getName() + ); + } catch (Exception ex) { + log.error("An error occurred while executing command \"{}\"", command.getInfo().getName(), ex); + event.getChannel().sendMessageEmbeds(EmbedUtils.genericInteractionError(ex).build()).queue(); + + Hint hint = new Hint(); + hint.set("command", command.getInfo().getName()); + hint.set("user", user.getId()); + hint.set("guild", guild.getId()); + Sentry.captureException(ex, hint); // Capture the exception + } + } + + /** + * Runs pre execute checks for a command + * + * @param command The command + * @param user The user + * @param guild The guild + * @param member The member + * @return The error message if any + */ + public String runPreExecuteChecks(BatCommand command, BatUser user, BatGuild guild, Member member) { + // Only the bot owner can run this command + if (command.getInfo().isBotOwnerOnly() && !user.getId().equalsIgnoreCase(Consts.BOT_OWNER)) { + return "You do not have permission to execute this command"; + } + + // Check if the command is guild only and if it was not ran inside a guild + if (command.getInfo().isGuildOnly() && guild == null) { + return "This command can only be executed in a guild"; + } + + // Check if the feature is disabled in the guild + if (guild != null) { + FeatureProfile featureProfile = guild.getFeatureProfile(); + if (featureProfile.isFeatureDisabled(command.getFeature())) { + return "The feature `%s` is disabled in this guild".formatted(command.getFeature().getName()); + } + } + + // Check if the user has the required permissions + if (guild != null && member != null) { + List missingPermissions = new ArrayList<>(); + for (Permission permission : command.getInfo().getPermissions()) { + if (!member.hasPermission(permission)) { + missingPermissions.add(permission); + } + } + if (!missingPermissions.isEmpty()) { + return "You are missing the following permissions to execute this command:\n" + + missingPermissions.stream().map(perm -> "`" + perm.name() + "`").collect(Collectors.joining(", ")); + } + } + return null; + } +} \ No newline at end of file diff --git a/src/main/java/cc/fascinated/bat/statschannel/StatsChannelFeature.java b/src/main/java/cc/fascinated/bat/statschannel/StatsChannelFeature.java index 87cf4c2..68a709d 100644 --- a/src/main/java/cc/fascinated/bat/statschannel/StatsChannelFeature.java +++ b/src/main/java/cc/fascinated/bat/statschannel/StatsChannelFeature.java @@ -4,7 +4,7 @@ import cc.fascinated.bat.common.feature.Feature; import cc.fascinated.bat.common.feature.FeatureProfile; import cc.fascinated.bat.statschannel.command.StatsChannelCommand; import cc.fascinated.bat.common.model.BatGuild; -import cc.fascinated.bat.service.CommandService; +import cc.fascinated.bat.service.OldCommandService; import cc.fascinated.bat.service.DiscordService; import cc.fascinated.bat.service.GuildService; import lombok.NonNull; @@ -24,7 +24,7 @@ public class StatsChannelFeature extends Feature { private final GuildService guildService; @Autowired - public StatsChannelFeature(@NonNull ApplicationContext context, @NonNull CommandService commandService, @NonNull GuildService guildService) { + public StatsChannelFeature(@NonNull ApplicationContext context, @NonNull OldCommandService commandService, @NonNull GuildService guildService) { super("Stats Channels", FeatureProfile.FeatureState.DISABLED, true); this.guildService = guildService; diff --git a/src/main/java/cc/fascinated/bat/statschannel/command/AddSubCommand.java b/src/main/java/cc/fascinated/bat/statschannel/command/AddSubCommand.java index fd84c04..f3d65d0 100644 --- a/src/main/java/cc/fascinated/bat/statschannel/command/AddSubCommand.java +++ b/src/main/java/cc/fascinated/bat/statschannel/command/AddSubCommand.java @@ -1,8 +1,8 @@ package cc.fascinated.bat.statschannel.command; import cc.fascinated.bat.Emojis; -import cc.fascinated.bat.common.command.BatCommand; -import cc.fascinated.bat.common.command.CommandInfo; +import cc.fascinated.bat.common.oldcommand.BatCommand; +import cc.fascinated.bat.common.oldcommand.CommandInfo; import cc.fascinated.bat.common.DescriptionBuilder; import cc.fascinated.bat.common.EmbedUtils; import cc.fascinated.bat.statschannel.StatsChannelProfile; diff --git a/src/main/java/cc/fascinated/bat/statschannel/command/CurrentSubCommand.java b/src/main/java/cc/fascinated/bat/statschannel/command/CurrentSubCommand.java index d4342f8..eb337ea 100644 --- a/src/main/java/cc/fascinated/bat/statschannel/command/CurrentSubCommand.java +++ b/src/main/java/cc/fascinated/bat/statschannel/command/CurrentSubCommand.java @@ -1,7 +1,7 @@ package cc.fascinated.bat.statschannel.command; -import cc.fascinated.bat.common.command.BatCommand; -import cc.fascinated.bat.common.command.CommandInfo; +import cc.fascinated.bat.common.oldcommand.BatCommand; +import cc.fascinated.bat.common.oldcommand.CommandInfo; import cc.fascinated.bat.common.DescriptionBuilder; import cc.fascinated.bat.common.EmbedUtils; import cc.fascinated.bat.statschannel.StatsChannel; diff --git a/src/main/java/cc/fascinated/bat/statschannel/command/RemoveSubCommand.java b/src/main/java/cc/fascinated/bat/statschannel/command/RemoveSubCommand.java index cdfe0c4..50e6cf0 100644 --- a/src/main/java/cc/fascinated/bat/statschannel/command/RemoveSubCommand.java +++ b/src/main/java/cc/fascinated/bat/statschannel/command/RemoveSubCommand.java @@ -1,8 +1,8 @@ package cc.fascinated.bat.statschannel.command; import cc.fascinated.bat.Emojis; -import cc.fascinated.bat.common.command.BatCommand; -import cc.fascinated.bat.common.command.CommandInfo; +import cc.fascinated.bat.common.oldcommand.BatCommand; +import cc.fascinated.bat.common.oldcommand.CommandInfo; import cc.fascinated.bat.common.EmbedUtils; import cc.fascinated.bat.statschannel.StatsChannelProfile; import cc.fascinated.bat.common.model.BatGuild; diff --git a/src/main/java/cc/fascinated/bat/statschannel/command/StatsChannelCommand.java b/src/main/java/cc/fascinated/bat/statschannel/command/StatsChannelCommand.java index 68dd3b3..6e646b3 100644 --- a/src/main/java/cc/fascinated/bat/statschannel/command/StatsChannelCommand.java +++ b/src/main/java/cc/fascinated/bat/statschannel/command/StatsChannelCommand.java @@ -1,7 +1,7 @@ package cc.fascinated.bat.statschannel.command; -import cc.fascinated.bat.common.command.BatCommand; -import cc.fascinated.bat.common.command.CommandInfo; +import cc.fascinated.bat.common.oldcommand.BatCommand; +import cc.fascinated.bat.common.oldcommand.CommandInfo; import lombok.NonNull; import net.dv8tion.jda.api.Permission; import org.springframework.beans.factory.annotation.Autowired; diff --git a/src/main/java/cc/fascinated/bat/welcomer/WelcomerFeature.java b/src/main/java/cc/fascinated/bat/welcomer/WelcomerFeature.java index c2f3ae7..1b51ecd 100644 --- a/src/main/java/cc/fascinated/bat/welcomer/WelcomerFeature.java +++ b/src/main/java/cc/fascinated/bat/welcomer/WelcomerFeature.java @@ -3,7 +3,7 @@ package cc.fascinated.bat.welcomer; import cc.fascinated.bat.common.feature.Feature; import cc.fascinated.bat.common.feature.FeatureProfile; import cc.fascinated.bat.welcomer.command.WelcomerCommand; -import cc.fascinated.bat.service.CommandService; +import cc.fascinated.bat.service.OldCommandService; import lombok.NonNull; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.ApplicationContext; @@ -15,7 +15,7 @@ import org.springframework.stereotype.Component; @Component public class WelcomerFeature extends Feature { @Autowired - public WelcomerFeature(@NonNull ApplicationContext context, @NonNull CommandService commandService) { + public WelcomerFeature(@NonNull ApplicationContext context, @NonNull OldCommandService commandService) { super("Welcomer", FeatureProfile.FeatureState.DISABLED, true); super.registerCommand(commandService, context.getBean(WelcomerCommand.class)); diff --git a/src/main/java/cc/fascinated/bat/welcomer/command/ChannelSubCommand.java b/src/main/java/cc/fascinated/bat/welcomer/command/ChannelSubCommand.java index 9d5ebe6..04c8ddb 100644 --- a/src/main/java/cc/fascinated/bat/welcomer/command/ChannelSubCommand.java +++ b/src/main/java/cc/fascinated/bat/welcomer/command/ChannelSubCommand.java @@ -1,7 +1,7 @@ package cc.fascinated.bat.welcomer.command; -import cc.fascinated.bat.common.command.BatCommand; -import cc.fascinated.bat.common.command.CommandInfo; +import cc.fascinated.bat.common.oldcommand.BatCommand; +import cc.fascinated.bat.common.oldcommand.CommandInfo; import cc.fascinated.bat.common.EmbedUtils; import cc.fascinated.bat.welcomer.WelcomerProfile; import cc.fascinated.bat.common.model.BatGuild; diff --git a/src/main/java/cc/fascinated/bat/welcomer/command/CurrentSubCommand.java b/src/main/java/cc/fascinated/bat/welcomer/command/CurrentSubCommand.java index 437af0f..59849e3 100644 --- a/src/main/java/cc/fascinated/bat/welcomer/command/CurrentSubCommand.java +++ b/src/main/java/cc/fascinated/bat/welcomer/command/CurrentSubCommand.java @@ -1,7 +1,7 @@ package cc.fascinated.bat.welcomer.command; -import cc.fascinated.bat.common.command.BatCommand; -import cc.fascinated.bat.common.command.CommandInfo; +import cc.fascinated.bat.common.oldcommand.BatCommand; +import cc.fascinated.bat.common.oldcommand.CommandInfo; import cc.fascinated.bat.common.EmbedUtils; import cc.fascinated.bat.welcomer.WelcomerPlaceholders; import cc.fascinated.bat.welcomer.WelcomerProfile; diff --git a/src/main/java/cc/fascinated/bat/welcomer/command/EmbedSubCommand.java b/src/main/java/cc/fascinated/bat/welcomer/command/EmbedSubCommand.java index e316be1..2cc5b76 100644 --- a/src/main/java/cc/fascinated/bat/welcomer/command/EmbedSubCommand.java +++ b/src/main/java/cc/fascinated/bat/welcomer/command/EmbedSubCommand.java @@ -1,8 +1,8 @@ package cc.fascinated.bat.welcomer.command; import cc.fascinated.bat.Emojis; -import cc.fascinated.bat.common.command.BatCommand; -import cc.fascinated.bat.common.command.CommandInfo; +import cc.fascinated.bat.common.oldcommand.BatCommand; +import cc.fascinated.bat.common.oldcommand.CommandInfo; import cc.fascinated.bat.common.DescriptionBuilder; import cc.fascinated.bat.common.EmbedUtils; import cc.fascinated.bat.common.HexColorUtils; diff --git a/src/main/java/cc/fascinated/bat/welcomer/command/MessageSubCommand.java b/src/main/java/cc/fascinated/bat/welcomer/command/MessageSubCommand.java index 117ff83..0c867e3 100644 --- a/src/main/java/cc/fascinated/bat/welcomer/command/MessageSubCommand.java +++ b/src/main/java/cc/fascinated/bat/welcomer/command/MessageSubCommand.java @@ -1,8 +1,8 @@ package cc.fascinated.bat.welcomer.command; import cc.fascinated.bat.Emojis; -import cc.fascinated.bat.common.command.BatCommand; -import cc.fascinated.bat.common.command.CommandInfo; +import cc.fascinated.bat.common.oldcommand.BatCommand; +import cc.fascinated.bat.common.oldcommand.CommandInfo; import cc.fascinated.bat.common.DescriptionBuilder; import cc.fascinated.bat.common.EmbedUtils; import cc.fascinated.bat.welcomer.WelcomerPlaceholders; diff --git a/src/main/java/cc/fascinated/bat/welcomer/command/ResetSubCommand.java b/src/main/java/cc/fascinated/bat/welcomer/command/ResetSubCommand.java index a2166fe..983dee9 100644 --- a/src/main/java/cc/fascinated/bat/welcomer/command/ResetSubCommand.java +++ b/src/main/java/cc/fascinated/bat/welcomer/command/ResetSubCommand.java @@ -1,7 +1,7 @@ package cc.fascinated.bat.welcomer.command; -import cc.fascinated.bat.common.command.BatCommand; -import cc.fascinated.bat.common.command.CommandInfo; +import cc.fascinated.bat.common.oldcommand.BatCommand; +import cc.fascinated.bat.common.oldcommand.CommandInfo; import cc.fascinated.bat.common.EmbedUtils; import cc.fascinated.bat.welcomer.WelcomerProfile; import cc.fascinated.bat.common.model.BatGuild; diff --git a/src/main/java/cc/fascinated/bat/welcomer/command/WelcomerCommand.java b/src/main/java/cc/fascinated/bat/welcomer/command/WelcomerCommand.java index d6d7201..d75b3c6 100644 --- a/src/main/java/cc/fascinated/bat/welcomer/command/WelcomerCommand.java +++ b/src/main/java/cc/fascinated/bat/welcomer/command/WelcomerCommand.java @@ -1,8 +1,8 @@ package cc.fascinated.bat.welcomer.command; -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.oldcommand.BatCommand; +import cc.fascinated.bat.common.oldcommand.Category; +import cc.fascinated.bat.common.oldcommand.CommandInfo; import lombok.NonNull; import net.dv8tion.jda.api.Permission; import org.springframework.beans.factory.annotation.Autowired;