Skip to content

Package

errors v0.15.1

Changelog

seedcordseedcord

The whole Discord bot, typed end to end

Website · Guide · Reference · Discord

npm node bun license

About

@seedcord/errors defines the codes for every error seedcord throws, in SeedcordErrorCode. isSeedcordError checks a caught value against a code, so your code can react to one specific failure.

Both seedcord transports depend on it and re-export it, so a bot imports isSeedcordError from its transport. Install it directly in a plugin or a library that catches errors from a seedcord package, like @seedcord/custom-id in a discord.js bot.

seedcord is pre-1.0, so a minor version can break your code. Each release's changelog says what changed and how to update.

Installation

pnpm add @seedcord/errors

Usage

Say Approve is a CustomId from @seedcord/custom-id, and a click arrives on a button built from an older version of it:

import { isSeedcordError, SeedcordErrorCode } from '@seedcord/errors';

try {
    Approve.decode(interaction.customId);
} catch (error) {
    if (!isSeedcordError(error, 'SeedcordError', SeedcordErrorCode.CustomIdWireStale)) throw error;
    await interaction.reply('This button is out of date. Run the command again.');
}

The error handling guide covers how a seedcord bot replies to an error.