"ChatInputCommandError" listener not firing for subcommands
ChatInputCommandError.tsChatInputCommandError.ts:import { ChatInputCommandErrorPayload, Events, Listener } from '@sapphire/framework';
import generalErrorEmbed from '../lib/embed-presets/GeneralError.js';
/**
* Emitted after a chat input command runs unsuccesfully.
*/
export class ChatInputCommandErrorListener extends Listener<typeof Events.ChatInputCommandError> {
public constructor(context: Listener.LoaderContext, options: Listener.Options) {
super(context, {
...options,
event: 'chatInputCommandError'
});
}
/**
* Is called whenever an error is thrown in a `chatInputRun` method.
*
* @param error - The error thrown
* @param payload - The contextual payload
*/
public async run(error: unknown, payload: ChatInputCommandErrorPayload) {
(async () => {
if (!payload.interaction.deferred) await payload.interaction.deferReply({ ephemeral: true });
await payload.interaction.editReply({
embeds: [generalErrorEmbed]
});
})().catch(this.container.logger.error);
this.container.logger.error(`Encountered an error with the "chatInputRun" method of command "${payload.command.name}"`, error);
}
}import { ChatInputCommandErrorPayload, Events, Listener } from '@sapphire/framework';
import generalErrorEmbed from '../lib/embed-presets/GeneralError.js';
/**
* Emitted after a chat input command runs unsuccesfully.
*/
export class ChatInputCommandErrorListener extends Listener<typeof Events.ChatInputCommandError> {
public constructor(context: Listener.LoaderContext, options: Listener.Options) {
super(context, {
...options,
event: 'chatInputCommandError'
});
}
/**
* Is called whenever an error is thrown in a `chatInputRun` method.
*
* @param error - The error thrown
* @param payload - The contextual payload
*/
public async run(error: unknown, payload: ChatInputCommandErrorPayload) {
(async () => {
if (!payload.interaction.deferred) await payload.interaction.deferReply({ ephemeral: true });
await payload.interaction.editReply({
embeds: [generalErrorEmbed]
});
})().catch(this.container.logger.error);
this.container.logger.error(`Encountered an error with the "chatInputRun" method of command "${payload.command.name}"`, error);
}
}