How do I handle this UserError?
I've been fiddling around with the subcommands plugin and I see that it throws an error ("No subcommand was matched with the provided arguments.") every time there is not a default defined and it doesnt match with a command.
I am not trying to add a default, but I am trying to handle this error by adding a response message, e.g. "Did you mean to execute ...".
I have tried using a listener to listen to Events.Error but it never gets fired.
Is there any way I can handle this type of error?
2 Replies
listen to the not found event for your type of subcommand
https://www.sapphirejs.dev/docs/Documentation/api-plugins/modules/sapphire_plugin_subcommands#subcommandpluginevents
Hello, thank you for the reply
I have tried listening to
MessageSubcommandError
, MessageSubcommandNotFound
and SubcommandMappingIsMissingMessageCommandHandler
. This is the code I am using:
However, this is not printing to console.
Is my listening class correct?
After some more searching, the following code works, although very hardcoded and unusual: