pingex
/
DiscordBot
Archived
1
0
Fork 0

Can choose whether a command output should be displayed as code (ie. "```") or not.

master
Pingex aka Raphaël 9 years ago
parent 90a0a76ac4
commit bb1fc6da4a

@ -33,4 +33,9 @@ public @interface Command
* Arguments that are required, or not. `true` for a required field, `false` for a not required one.
*/
boolean[] required() default {};
/**
* Should the output be embraced with "```" ?
*/
boolean codeOutput() default true;
}

@ -154,7 +154,7 @@ class CommandDispatcher
try
{
String ans = (String) commandList.get(finalFullCommand).invoke(finalParsedArray);
if(ans != null) event.getMessage().getChannel().sendMessage("```\n" + ans + "\n```");
if(ans != null) event.getMessage().getChannel().sendMessage(commandList.get(finalFullCommand).getMethod().getAnnotation(Command.class).codeOutput() ? "```\n" + ans + "\n```" : ans);
} catch (IllegalArgumentException | IllegalAccessException e)
{
logger.severe("Couldn't call target method (" + e.getClass().getName() + "): " + e.getMessage());