This feature is implemented in Klasa 0.5.0, check the PR that implemented it here.
Custom resolvers allow developers to set up custom types for each command, they are highly customizable and can hold its own logic and type name. This is possible thanks to the {@link Command.createCustomResolver} method.
A custom resolver is usually created in the command constructor and its usage is identical to {@link ArgResolver} methods:
this.createCustomResolver('key', (arg, possible, message, params) => {
// Logic
});
Where the first parameter is the name of the custom type, and the second is a function that takes arg
(string), possible
({@link Possible}), message
({@link KlasaMessage}) and optionally, params
(any[], remember parameters are parsed arguments).
Then in your usage, you can use the type key
, it'll be recognized as a local resolver that your command is able to use. Check a live example here. You can also check the tutorial {@tutorial CreatingCustomArguments} for further information.
- {@tutorial CommandsArguments}
- {@tutorial CommandsSubcommands}
- {@tutorial CommandsCustomResponses}