messageSubcommandNoMatch listener not working

Hello again WaveLFrog Currently I am trying to handle the messageSubcommandNoMatch error. I've registered a listener for it: listeners/messageSubcommandNoMatch.ts
import { Listener } from "@sapphire/framework";

export class CommandError extends Listener {
constructor(context: Listener.Context, options: Listener.Options) {
super(context, {
...options,
event: "messageSubcommandNoMatch",
});
}

run() {
console.log("Hello");
}
}
import { Listener } from "@sapphire/framework";

export class CommandError extends Listener {
constructor(context: Listener.Context, options: Listener.Options) {
super(context, {
...options,
event: "messageSubcommandNoMatch",
});
}

run() {
console.log("Hello");
}
}
Now when I am trying to execute a subcommand which does not exist, this listener does not get executed. Instead I just see the error in the console from Sapphires default error listener. Taking the log in the console, I can confirm that the expected identifier is messageSubcommandNoMatch fastthink I have checked whether the listener is actually registered, and for me it appears all right. (Check screenshot) My other listeners e.g. messageCreate work just fine. Is there something I am missing? Maybe because this is not a event directly bound to Discord? CheeseThinkFrog
No description
2 Replies
ITOH
ITOH12mo ago
I kind of fixed it by doing this: listeners/messageCommandError.ts
import {
Events,
Listener,
MessageCommandErrorPayload,
UserError,
} from "@sapphire/framework";

export class CommandError extends Listener<typeof Events.MessageCommandError> {
constructor(context: Listener.Context, options: Listener.Options) {
super(context, {
...options,
event: Events.MessageCommandError,
});
}

run(error: unknown, context: MessageCommandErrorPayload) {
if (error instanceof UserError && this.emitter) {
this.emitter.emit(error.identifier, error, context);
}
}
}
import {
Events,
Listener,
MessageCommandErrorPayload,
UserError,
} from "@sapphire/framework";

export class CommandError extends Listener<typeof Events.MessageCommandError> {
constructor(context: Listener.Context, options: Listener.Options) {
super(context, {
...options,
event: Events.MessageCommandError,
});
}

run(error: unknown, context: MessageCommandErrorPayload) {
if (error instanceof UserError && this.emitter) {
this.emitter.emit(error.identifier, error, context);
}
}
}
Now my messageSubcommandNoMatch listener works. So is this the intended way of tackling that, or am I doing something else wrong fastthink
Favna
Favna12mo ago
Hm no it definitely isn’t the listener should just be triggered. I’ll have to investigate this
Want results from more Discord servers?
Add your server