diff --git a/src/main/java/cc/fascinated/bat/command/BatCommand.java b/src/main/java/cc/fascinated/bat/command/BatCommand.java index 7efb8fa..3fc7d4d 100644 --- a/src/main/java/cc/fascinated/bat/command/BatCommand.java +++ b/src/main/java/cc/fascinated/bat/command/BatCommand.java @@ -37,6 +37,11 @@ public abstract class BatCommand implements BatCommandExecutor { */ private Category category; + /** + * Whether the command can only be used by the bot owner + */ + private boolean botOwnerOnly; + /** * The command snowflake from Discord */ @@ -45,6 +50,7 @@ public abstract class BatCommand implements BatCommandExecutor { public BatCommand() { this.commandInfo = getClass().getAnnotation(CommandInfo.class); this.category = this.commandInfo.category(); + this.botOwnerOnly = this.commandInfo.botOwnerOnly(); this.commandData = new CommandDataImpl(this.commandInfo.name(), this.commandInfo.description()) .setGuildOnly(this.commandInfo.guildOnly()); diff --git a/src/main/java/cc/fascinated/bat/command/impl/botadmin/premium/PremiumAdminCommand.java b/src/main/java/cc/fascinated/bat/command/impl/botadmin/premium/PremiumAdminCommand.java index dc9b2cb..de4891a 100644 --- a/src/main/java/cc/fascinated/bat/command/impl/botadmin/premium/PremiumAdminCommand.java +++ b/src/main/java/cc/fascinated/bat/command/impl/botadmin/premium/PremiumAdminCommand.java @@ -1,6 +1,7 @@ package cc.fascinated.bat.command.impl.botadmin.premium; import cc.fascinated.bat.command.BatCommand; +import cc.fascinated.bat.command.Category; import cc.fascinated.bat.command.CommandInfo; import lombok.NonNull; import org.springframework.beans.factory.annotation.Autowired; @@ -11,7 +12,7 @@ import org.springframework.stereotype.Component; * @author Fascinated (fascinated7) */ @Component -@CommandInfo(name = "premiumadmin", description = "Set a guild as premium", botOwnerOnly = true) +@CommandInfo(name = "premiumadmin", description = "Set a guild as premium", botOwnerOnly = true, category = Category.BOT_ADMIN) public class PremiumAdminCommand extends BatCommand { @Autowired public PremiumAdminCommand(@NonNull ApplicationContext context) { diff --git a/src/main/java/cc/fascinated/bat/service/CommandService.java b/src/main/java/cc/fascinated/bat/service/CommandService.java index 636d577..d34b24f 100644 --- a/src/main/java/cc/fascinated/bat/service/CommandService.java +++ b/src/main/java/cc/fascinated/bat/service/CommandService.java @@ -94,7 +94,7 @@ public class CommandService extends ListenerAdapter { // Register all commands List discordCommands = jda.updateCommands().addCommands(commands.values().stream() - .filter(command -> !command.getCategory().isHidden()) + .filter(command -> !command.getCategory().isHidden() || !command.isBotOwnerOnly()) .map(BatCommand::getCommandData).toList()).complete(); for (Command discordCommand : discordCommands) { commands.get(discordCommand.getName()).setCommandSnowflake(discordCommand.getIdLong()); @@ -107,7 +107,7 @@ public class CommandService extends ListenerAdapter { Objects.requireNonNull(jda.getGuildById(Consts.ADMIN_GUILD), "Admin guild is null!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!") .updateCommands().addCommands(commands.values().stream() - .filter(command -> command.getCategory().isHidden()) + .filter(command -> !command.getCategory().isHidden() || !command.isBotOwnerOnly()) .map(BatCommand::getCommandData).toList()).complete(); log.info("Registered all slash commands in {}ms", System.currentTimeMillis() - before);