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:
export class UserEvent extends Listener<typeof Events.ChatInputCommandError> {
public override async run(error: UserError, { interaction }: ChatInputCommandErrorPayload) {

if (Reflect.get(Object(error.context), 'silent')) return;
if (UserUsageError.isUserUsageError(error)) return; // If it's an error for the other file, return

// Do the stuff

}
}
export class UserEvent extends Listener<typeof Events.ChatInputCommandError> {
public override async run(error: UserError, { interaction }: ChatInputCommandErrorPayload) {

if (Reflect.get(Object(error.context), 'silent')) return;
if (UserUsageError.isUserUsageError(error)) return; // If it's an error for the other file, return

// Do the stuff

}
}
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:
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())
Jump to solution
2 Replies
Solution
Lioness100
Lioness1008mo ago
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())
Cyber Grandma
Cyber Grandma8mo ago
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 !