Is it possible to edit the default message returned by "preset preconditions"?
For example, the precondition set by
<CommandOptions.requiredClientPermissions>
returns I am missing the following permissions to run this command: Manage Channels
as the <UserError>.message
parsed in the ChatInputCommandDenied
listener, but I'd like it to return something else.4 Replies
Implement https://www.sapphirejs.dev/docs/Guide/preconditions/reporting-precondition-failure and rather than sending error.message, send your custom one. And identify the precondition with error.identifier.
Sapphire Framework
Reporting precondition failure | Sapphire
When a precondition fails, it's usually important for the user to know why. For example, if they hit a cooldown or lack
The thing is, I'd create my own precondition and then set it in the command's
<CommandOptions#preconditions
so let's say my custom precondition would be called HasPermissions
, how would I specify, from the command, which permissions the user needs to my custom precondition so that it fails/succeeds accordingly?
Because unless I'm miss understanding something, preconditions are static in the sense they will check for the same things regardless of the command sent and it would be nice that I could somehow set a context for the preconditions from the commandsWell first of all we have built in preconditions for permission checking but other than that you should implement the same as those built in ones are with containers: https://github.com/sapphiredev/framework/blob/main/src/lib/utils/preconditions/containers/ClientPermissionsPrecondition.ts
But you probably are far better off using the built in ones https://www.sapphirejs.dev/docs/Guide/preconditions/handling-permissions
Sapphire Framework
Handling permissions | Sapphire
One of the most basic needs of a Discord bot is to be able to deny command access to users based on their permissions or