© 2026 Hedgehog Software, LLC
ChatInputCommandError.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); } }
SubcommandPluginEvents
Join the Discord to ask follow-up questions and connect with the community
Sapphire is a next-gen object-oriented Discord.js bot framework.
2,286 Members