Fix modules without Command registries

This commit is contained in:
Steven Tracey 2022-08-15 12:06:29 -04:00
parent 4764f862ac
commit 2fcf0fd647
2 changed files with 13 additions and 1 deletions

View File

@ -1,5 +1,6 @@
package tech.nevets.modbot;
import ch.qos.logback.classic.Level;
import net.dv8tion.jda.api.JDA;
import net.dv8tion.jda.api.JDABuilder;
import net.dv8tion.jda.api.hooks.ListenerAdapter;
@ -21,6 +22,7 @@ public class CoreBot {
private static final Logger LOGGER = LoggerFactory.getLogger(CoreBot.class);
public static void main(String[] args) {
setLoggingLevel(Level.DEBUG);
CORE_CONFIG.addDefaults(getDefaults());
CORE_CONFIG.loadConfig();
modules = ModuleLoader.loadModules();
@ -42,7 +44,11 @@ public class CoreBot {
coreListener.getCommandRegistry().registerSlashCommands();
for (BotModule module : modules) {
module.loadCommandRegistry().registerSlashCommands();
if (module.loadCommandRegistry() == null) {
LOGGER.warn("Module has no commands to load");
} else {
module.loadCommandRegistry().registerSlashCommands();
}
module.onEnable(jda);
}
@ -61,4 +67,9 @@ public class CoreBot {
return defaults;
}
public static void setLoggingLevel(ch.qos.logback.classic.Level level) {
ch.qos.logback.classic.Logger root = (ch.qos.logback.classic.Logger) org.slf4j.LoggerFactory.getLogger(ch.qos.logback.classic.Logger.ROOT_LOGGER_NAME);
root.setLevel(level);
}
}

View File

@ -109,6 +109,7 @@ public class ModuleLoader {
}
}
LOGGER.debug("Loaded module: " + modules.toArray().toString());
return modules;
}
}