Precondition error type

How to access the code of precondition error? to override the reply or something like that
Solution:
we export a constant called Events from sapphire, you can use that as for the parameter types.. sadly TS doesn't let us strictly type that to the point where you don't need to specify the actual types (i.e. it's inferred) (we really would want to!) but if you use Listener<typeof Events.GuildCreate> then in your run you have parameters of incorrect types, TS will tell you this....
Jump to solution
13 Replies
WhacK
WhacK13mo ago
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
Sayed
Sayed13mo ago
I read that before but the default preconditions return a message so how can I edit that message or override it according to the type of precondition error
WhacK
WhacK13mo ago
In the this.error() of the precondition itself. The instructions are a little further down the page.
Sayed
Sayed13mo ago
I can't edit the default ones I mean the preconditions like timeout etc cooldown*
Favna
Favna13mo ago
1. Article that WhacK linked 2. Use error.identifier to identify which precondition it is 3. Use error.context to get for example the time in ms for cooldown Then send a custom msg
Sayed
Sayed13mo ago
Thank you, I have another question related to the listeners types Where can I get the types of listeners like Guild Create
Solution
Favna
Favna13mo ago
we export a constant called Events from sapphire, you can use that as for the parameter types.. sadly TS doesn't let us strictly type that to the point where you don't need to specify the actual types (i.e. it's inferred) (we really would want to!) but if you use Listener<typeof Events.GuildCreate> then in your run you have parameters of incorrect types, TS will tell you this.
Sayed
Sayed13mo ago
I want to get the events' run payload lilke guild in guildcreate I can't reach it Oh Is there temp solution for that?
Favna
Favna13mo ago
temp solution for what
Sayed
Sayed13mo ago
I want to get the types of payload :)
Favna
Favna13mo ago
Discord.js
Discord.js is a powerful node.js module that allows you to interact with the Discord API very easily. It takes a much more object-oriented approach than most other JS Discord libraries, making your bot's code significantly tidier and easier to comprehend.
Sayed
Sayed13mo ago
Another question is how to rename structures' folders without affecting the reading of the framework
Spinel
Spinel13mo ago
<:_:746069730170896405> Sapphire guide results: User Guide / Registering custom paths for a store
Want results from more Discord servers?
Add your server