Fix modules without Command registries
This commit is contained in:
parent
4764f862ac
commit
2fcf0fd647
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -109,6 +109,7 @@ public class ModuleLoader {
|
||||
}
|
||||
}
|
||||
|
||||
LOGGER.debug("Loaded module: " + modules.toArray().toString());
|
||||
return modules;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user