pingex
/
DiscordBot
Archived
1
0
Fork 0

No longer spams the log when rebuilding commands list.

master
Pingex aka Raphaël 9 years ago
parent 0fa98cb1b5
commit ee0d746a04

@ -184,18 +184,21 @@ class CommandDispatcher
commandList = new TreeMap<>();
shortList = new TreeMap<>();
int count = 0;
int invalidCount = 0;
for(AbstractModule i : registry)
if(i.getClass().isAnnotationPresent(Controllable.class))
for(Method j : i.getClass().getDeclaredMethods())
if(j.isAnnotationPresent(Command.class))
{
String id = i.getClass().getAnnotation(Controllable.class).name() + ":" + j.getName().toLowerCase();
logger.info("Found " + id);
if(j.getParameterCount() >= 1 && j.getParameterTypes()[0] == MessageReceivedEvent.class && j.getReturnType() == String.class)
if(!commandList.containsKey(id))
{
commandList.put(id, new InvokableMethod(j, i));
count++;
// Eventual command shorthands
if(!j.getAnnotation(Command.class).shorthand().isEmpty())
@ -205,11 +208,18 @@ class CommandDispatcher
logger.warning("Conflicting shorthand for command " + id);
}
else
{
logger.warning("Conflicting command " + id);
invalidCount++;
}
else
{
logger.warning("Command [" + id + "]: incorrect function prototype, thus won't be added to the command list.");
invalidCount++;
}
}
logger.info("Found " + count + " valid commands and " + invalidCount + " invalid commands.");
logger.info("... Done");
}