From e05e08c291963a817c2f8cc21fdad509efbcf856 Mon Sep 17 00:00:00 2001 From: Liam Date: Thu, 27 Jun 2024 21:25:06 +0100 Subject: [PATCH] fix bot not loading when admin guild is null --- .../cc/fascinated/bat/service/CommandService.java | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/main/java/cc/fascinated/bat/service/CommandService.java b/src/main/java/cc/fascinated/bat/service/CommandService.java index 71c244c..6894ab1 100644 --- a/src/main/java/cc/fascinated/bat/service/CommandService.java +++ b/src/main/java/cc/fascinated/bat/service/CommandService.java @@ -102,10 +102,14 @@ 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()) - .map(BatCommand::getCommandData).toList()).complete(); + Guild adminGuild = jda.getGuildById(Consts.ADMIN_GUILD); + if (adminGuild != null) { + adminGuild.updateCommands().addCommands(commands.values().stream() + .filter(command -> command.getCategory().isHidden() || command.isBotOwnerOnly()) + .map(BatCommand::getCommandData).toList()).complete(); + } else { + log.error("Unable to find the admin guild to register hidden commands"); + } log.info("Registered all slash commands in {}ms", System.currentTimeMillis() - before); }