fix bot not loading when admin guild is null

This commit is contained in:
Lee 2024-06-27 21:25:06 +01:00
parent ff5b83f531
commit e05e08c291

@ -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()
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);
}