Multiple listeners on the same event ?
Hi, I'm trying to define two listeners for the same event (
chatInputCommandError
)
My folder is organised as such:
src >
listeners >
commands >
chatInputCommandError.ts
chatInputCommandErrorBis.ts
I want to handle some different types of errors in these two files.
In these two files it's basically like so:
The issue is that the second file is never fired on errors, only the first one.
What did I miss in the docs to make that work ?
Thanks ❤️Solution:Jump to solution
Listeners detect which events they should be listening to by the file name, not the generic type. If the file name does not match the event, pass
{ event: '...' }
into the constructor (either via @ApplyOptions
from @sapphire/decorators
or with super()
)2 Replies
Solution
Listeners detect which events they should be listening to by the file name, not the generic type. If the file name does not match the event, pass
{ event: '...' }
into the constructor (either via @ApplyOptions
from @sapphire/decorators
or with super()
)Ok, thanks for clarifying that part for me. I find the role of the 'Router/Middleware' is bit confusing sometimes 😅
And that is what I tried before with no success. But now I've realized I had made a simple copy-paste mistake, and now it works like a charm.
Thanks for your response !