Error Messages¶
As mentioned before, JDA-Commands has a set of error messages it uses all over the place. These messages include:
- Command Execution Failed Message (used for Exceptions)
- Constraint Failed Message (see Validators)
- Cooldown Message (see Command Cooldown)
- Insufficient Permissions Message (see Permissions System)
- Timed Out Component Message (see Runtime Concept)
- Type Adapting Failed Message (see Type Adapters)
You can customize these error messages by providing an implementation of ErrorMessageFactory
.
You have to register it at the JDA-Commands Builder:
@Implementation
annotation (requires the Guice Extension):
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();
{placeholders}
can be placed anywhere in the embeds and will get injected by JDA-Commands.