Precondition error type
How to access the code of precondition error?
to override the reply or something like that
Solution:Jump to 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....13 Replies
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
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
In the
this.error()
of the precondition itself. The instructions are a little further down the page.I can't edit the default ones
I mean the preconditions like timeout etc
cooldown*
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
Thank you,
I have another question related to the listeners types
Where can I get the types of listeners like Guild Create
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.I want to get the events' run payload
lilke guild in guildcreate
I can't reach it
Oh
Is there temp solution for that?
temp solution for what
I want to get the types of payload :)
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.
Another question is how to rename structures' folders without affecting the reading of the framework