From 3af151d89a8dc28c617f9f6c0f7cb2e9c80102c1 Mon Sep 17 00:00:00 2001 From: Nick Date: Thu, 27 Jun 2024 21:24:55 -0500 Subject: [PATCH] Revert quick fix --- .../cc/fascinated/bat/service/CommandService.java | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/src/main/java/cc/fascinated/bat/service/CommandService.java b/src/main/java/cc/fascinated/bat/service/CommandService.java index 9ad85fe..c54ba1d 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,10 +75,10 @@ public class CommandService extends ListenerAdapter { // Unregister all commands that Discord has but we don't jda.retrieveCommands().complete().forEach(command -> { - BatCommand batCommand = commands.get(command.getName()); - if (batCommand == null) { + 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 unknown command \"{}\" from Discord", command.getName()); + log.info("Unregistered hidden command \"{}\" from Discord", command.getName()); return; } if (commands.containsKey(command.getName())) { @@ -211,4 +208,4 @@ public class CommandService extends ListenerAdapter { .queue(); } } -} +} \ No newline at end of file