big black brown man
big black brown man
SIASapphire - Imagine a framework
Created by big black brown man on 6/17/2023 in #sapphire-support
How do I handle this UserError?
After some more searching, the following code works, although very hardcoded and unusual:
@ApplyOptions<Listener.Options>({
event: Events.MessageCommandError,
})
export class CoreEvent extends Listener<typeof Events.MessageCommandError> {
public async run(error: Error, payload: unknown) {
if(!(error instanceof UserError && error.message === "No subcommand was matched with the provided arguments.")) return;
// logic..
}
}
@ApplyOptions<Listener.Options>({
event: Events.MessageCommandError,
})
export class CoreEvent extends Listener<typeof Events.MessageCommandError> {
public async run(error: Error, payload: unknown) {
if(!(error instanceof UserError && error.message === "No subcommand was matched with the provided arguments.")) return;
// logic..
}
}
6 replies
SIASapphire - Imagine a framework
Created by big black brown man on 6/17/2023 in #sapphire-support
How do I handle this UserError?
Hello, thank you for the reply I have tried listening to MessageSubcommandError, MessageSubcommandNotFound and SubcommandMappingIsMissingMessageCommandHandler. This is the code I am using:
import { ApplyOptions } from "@sapphire/decorators";
import { Listener } from "@sapphire/framework";
import { SubcommandPluginEvents } from "@sapphire/plugin-subcommands";

@ApplyOptions<Listener.Options>({
event: SubcommandPluginEvents.MessageSubcommandNotFound
})
export class UserErrorListener extends Listener {
public run() {
console.log("Hello?")
}
}
import { ApplyOptions } from "@sapphire/decorators";
import { Listener } from "@sapphire/framework";
import { SubcommandPluginEvents } from "@sapphire/plugin-subcommands";

@ApplyOptions<Listener.Options>({
event: SubcommandPluginEvents.MessageSubcommandNotFound
})
export class UserErrorListener extends Listener {
public run() {
console.log("Hello?")
}
}
However, this is not printing to console. Is my listening class correct?
6 replies