From deb656086afdba2b45e9607d950db263a91b135d Mon Sep 17 00:00:00 2001 From: Liam Date: Thu, 27 Jun 2024 21:14:45 +0100 Subject: [PATCH] fix admin cmds --- .../java/cc/fascinated/bat/service/CommandService.java | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/main/java/cc/fascinated/bat/service/CommandService.java b/src/main/java/cc/fascinated/bat/service/CommandService.java index d34b24f..10bdf97 100644 --- a/src/main/java/cc/fascinated/bat/service/CommandService.java +++ b/src/main/java/cc/fascinated/bat/service/CommandService.java @@ -1,10 +1,7 @@ package cc.fascinated.bat.service; import cc.fascinated.bat.Consts; -import cc.fascinated.bat.command.BatCommand; -import cc.fascinated.bat.command.BatCommandExecutor; -import cc.fascinated.bat.command.BatSubCommand; -import cc.fascinated.bat.command.Category; +import cc.fascinated.bat.command.*; import cc.fascinated.bat.common.EmbedUtils; import cc.fascinated.bat.model.BatGuild; import cc.fascinated.bat.model.BatUser; @@ -78,7 +75,8 @@ public class CommandService extends ListenerAdapter { // Unregister all commands that Discord has but we don't jda.retrieveCommands().complete().forEach(command -> { - if (commands.containsKey(command.getName()) && commands.get(command.getName()).getCommandInfo().category().isHidden()) { + CommandInfo commandInfo = commands.get(command.getName()).getCommandInfo(); + if (commands.containsKey(command.getName()) && (commandInfo.category().isHidden() || commandInfo.botOwnerOnly())) { jda.deleteCommandById(command.getId()).complete(); // Unregister the command on Discord log.info("Unregistered hidden command \"{}\" from Discord", command.getName()); return; @@ -107,7 +105,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() || !command.isBotOwnerOnly()) + .filter(command -> command.getCategory().isHidden() || command.isBotOwnerOnly()) .map(BatCommand::getCommandData).toList()).complete(); log.info("Registered all slash commands in {}ms", System.currentTimeMillis() - before);