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
WhacK8mo 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
promise 🍉
promise 🍉8mo 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
WhacK8mo ago
In the this.error() of the precondition itself. The instructions are a little further down the page.
promise 🍉
promise 🍉8mo ago
I can't edit the default ones I mean the preconditions like timeout etc cooldown*
Favna
Favna8mo 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
promise 🍉
promise 🍉8mo 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
Favna8mo 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.
promise 🍉
promise 🍉8mo 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
Favna8mo ago
temp solution for what
promise 🍉
promise 🍉8mo ago
I want to get the types of payload :)
Favna
Favna8mo 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.
promise 🍉
promise 🍉8mo ago
Another question is how to rename structures' folders without affecting the reading of the framework
Spinel
Spinel8mo ago
<:_:746069730170896405> Sapphire guide results: User Guide / Registering custom paths for a store