How to use preconditions properly?
Hi, im a new at sapphire and didn't know much about it, also i was reading the Docs that how to use Preconditions and how to handle failure on it.
The question is, i was following the same thing at the docs but there is nothing show when i console.log it, im using ESM JavaScript not TypeScript. also, can someone explain how does Preconditions work? and what make it triggered on Listener event?
9 Replies
Something I noticed is that you're not actually listening to the event, you either need to make the file name the event names or provide the event name in the options inside the constructor.
I see, so i need to make it same as Precondition that i made?
No
Sapphire Framework
Creating your own listeners | Sapphire
Similar to what you learned in both Creating Commands and [Creating
Preconditions emit an event called messageCommandDenied
And you need to listen to that
Here's something that might help https://github.com/skyra-project/skyra/blob/main/src/listeners/commands/messageCommandDenied.ts
GitHub
skyra/src/listeners/commands/messageCommandDenied.ts at main · skyr...
A multipurpose Discord Bot designed to carry out most of your server's needs with great performance and stability. - skyra-project/skyra
Basically you need to add a constructor to your class and add the option to listen to
messageCommandDenied
or name the filename to messageCommandDenied
ooh, yes, i see thank you very much
it work when i change the filename to
messageCommandDenied
once again, thank you so muchNp