Skip to content

Error Messages

As mentioned before, JDA-Commands has a set of error messages it uses all over the place. These messages include:

You can customize these error messages by providing an implementation of ErrorMessageFactory. You have to register it at the JDA-Commands Builder:

JDACommands.builder(jda, Main.class)
    .errorMessageFactory(new OwnErrorMessageFactory());
    .start();
Or use the @Implementation annotation (requires the Guice Extension):
@Implementation
public class OwnErrorMessageFactory implements ErrorMessageFactory {...}

JsonErrorMessageFactory

To make things easier, these error message can also be loaded from a JSON file. Therefore, you have to enable the JsonErrorMessageFactory. The JsonErrorMessageFactory takes an EmbedCache as input.

JDACommands.builder(jda, Main.class)
    .errorMessageFactory(new JsonErrorMessageFactory(new EmbedCache("/path/to/json/embeds.json")));
    .start();
The template for the error messages can be found here. The {placeholders} can be placed anywhere in the embeds and will get injected by JDA-Commands.