Skip to content
GitHub

CommandNotFoundError

class in meocord/common Since 4.1.0

class CommandNotFoundError extends Error

The error raised for an interaction no handler matches, such as a button whose customId fits no pattern.

Catch it in a global filter to answer an expired or unknown control in your own words. Without one, the built-in fallback answers "Command not found!" and logs a warning naming the customId or command.

Examples

TypeScript
@Catch(CommandNotFoundError)
export class ExpiredControlFilter implements ExceptionFilter<CommandNotFoundError> {
  async catch(_error: CommandNotFoundError, context: ExecutionContext) {
    const interaction = context.getInteraction()
    if (interaction?.isRepliable()) await respond(interaction).send({ content: 'That button has expired.', flags: MessageFlags.Ephemeral })
  }
}

Members

constructor

new CommandNotFoundError(message?: string)

Parameters

NameTypeDescription
message?string

What the error says, No handler matched the interaction. unless given.

See also

  • Catch
  • Exception filters