SubcommandErrorEvent how to?

I have this code for defining listener for subcommand error event
import {
ChatInputSubcommandErrorPayload,
SubcommandPluginEvents,
} from "@sapphire/plugin-subcommands"
import { Listener } from "@sapphire/framework"
import { YumeError, interactionError, logCommand } from "@yume/common"
import { ApplyOptions } from "@sapphire/decorators"

@ApplyOptions<Listener.Options>({
name: SubcommandPluginEvents.ChatInputSubcommandError,
})
export class ChatInputSubcommandError extends Listener<
typeof SubcommandPluginEvents.ChatInputSubcommandError
> {
public override async run(error: Error, payload: ChatInputSubcommandErrorPayload) {
if (error instanceof YumeError) {
logCommand(payload)
interactionError(payload.interaction, error.message)
} else {
this.container.logger.error(error)
}
}
}
import {
ChatInputSubcommandErrorPayload,
SubcommandPluginEvents,
} from "@sapphire/plugin-subcommands"
import { Listener } from "@sapphire/framework"
import { YumeError, interactionError, logCommand } from "@yume/common"
import { ApplyOptions } from "@sapphire/decorators"

@ApplyOptions<Listener.Options>({
name: SubcommandPluginEvents.ChatInputSubcommandError,
})
export class ChatInputSubcommandError extends Listener<
typeof SubcommandPluginEvents.ChatInputSubcommandError
> {
public override async run(error: Error, payload: ChatInputSubcommandErrorPayload) {
if (error instanceof YumeError) {
logCommand(payload)
interactionError(payload.interaction, error.message)
} else {
this.container.logger.error(error)
}
}
}
I register it in "listeners" store like this:
void container.stores.loadPiece({
name: ChatInputSubcommandError.name,
piece: ChatInputSubcommandError,
store, // "listeners"
})
void container.stores.loadPiece({
name: ChatInputSubcommandError.name,
piece: ChatInputSubcommandError,
store, // "listeners"
})
But error still logs in to the console when I'm throwing YumeError. I don't have logs in logCommand and interactionError I have literally the same listeners for default commands that aren't subcommands and it works like expected. What can be the problem?
0 Replies
No replies yetBe the first to reply to this messageJoin

Did you find this page helpful?