Reimplement JDAMessageFormatter for Discord (#136)

Because Discord does not support coloring messages outside of embeddable fields, it is safe to use a simple message formatter than just returns the message itself.

As I was testing my previous PR, I noticed messages coming through with coloring symbols (e.g. `<c1></c1>`), and each only went up to `c3` maximum. Finally, I figured out these were colors that needed to be handled in each case.

To remove colored messages from Discord, the message formatter is passed three empty strings for each of `c1`, `c2`, and `c3` respectively.

Finally, the default formatter is set inside of `JDACommandManager` but can always be overridden by the user.
This commit is contained in:
simpleauthority
2018-06-02 07:36:57 -07:00
committed by Daniel Ennis
parent 27eb9fa733
commit 7478d030d0
2 changed files with 7 additions and 0 deletions
@@ -48,6 +48,7 @@ public class JDACommandManager extends CommandManager<
jda.addEventListener(new JDAListener(this));
this.defaultConfig = options.defaultConfig == null ? new JDACommandConfig() : options.defaultConfig;
this.configProvider = options.configProvider;
this.defaultFormatter = new JDAMessageFormatter();
this.completions = new JDACommandCompletions(this);
this.logger = Logger.getLogger(this.getClass().getSimpleName());
@@ -1,6 +1,12 @@
package co.aikar.commands;
public class JDAMessageFormatter extends MessageFormatter<String> {
public JDAMessageFormatter() {
// JDA does not support coloring messages outside of embed fields.
// We pass three empty strings so as to remove color coded messages from appearing.
super("", "", "");
}
@Override
String format(String color, String message) {
return message;