Error listeners
Which listener catches this (image)?
I have MessageCommandError and ChatInputCommandError listeners and neither one gets a log, I don't even get anything in the console.
In addition, there are also MessageCommandDenied and ChatInputCommandDenied listeners
23 Replies
None. There is no function called
expect
on Result. What you're writing is a syntax error.
And pickResult never throws. That's the whole point of pickResult as opposed to pick.Interesting, VScode is drunk then, I should check where does this function come from cause it isn't throwing errors for me using it...
Any way to make ResultError throw custom errors if it doesn't find what I'm trying to pick/rest?
Use pickResult, check isErr() and throw a custom UserError
Yeah, that's what I suspected, I was just looking for a shorter solution, isn't there something like isErrAnd (I don't remember the Result class by heart)
Thx
So shouldn't that technically work?
oh my bad
I forgot that
anyway it will still throw a ResultError you need to catch in
*CommandError
np, ideas as to why it doesn't actually trigger anything?
Like, I debugged it, and it doesn't go past that if the error happens, but, the console stays empty
The error isn't passed to the error event at all, other errors do though (like the no subcommands found error the subcommands plugin throws)
is this a subcommand...?
No
Actually
Yeah
does it extend the subcommand class?
Yeah it is
It's a subcommand
Is there another event that they throw? Couldn't find anything about that
then you need to use
*SubcommandError
For the love of god
So many listeners...
shrug
I wish I could just combine the error and deny listeners of everything into one, is that even possible?
No and that would be a code smell if it would be possible because it means you're making 1 thing responsible for multiple completely disparate things
subcommands overwrite
messageRun
and chatInputRun
(and you should absolutely never implement those functions when using subcommands) https://github.com/sapphiredev/plugins/blob/main/packages/subcommands/src/lib/Subcommand.ts
which is why they throw their own errors, because only uncaught and unexpected errors should end up in the default listenersWell, I have listeners for chat input, message (and now subcommand) denies and errors, and they all technically do (well, will do, it's wip) the exact same thing
Code duplication basically
there is this thing called a module system yaknow
Yeah, that's the plan currently
The bot is written with functional programming, I'm trying to minimize duplicated code when possible
Thx tho, this solves the issue