Skip to content

Errors

Every error discord0 throws or logs starts with a stable code in brackets, followed by what went wrong, why, and how to fix it:

[DUPLICATE_COMMAND] Duplicate command: ban
Why: Discord identifies a command by its name and type, so the second definition would replace the first when commands sync.
Fix: Rename one of them, or move one into a sub-app mounted with `app.route()` so it becomes a subcommand.
Docs: https://github.com/natebabyak/discord0/blob/main/packages/discord0/ERRORS.md#duplicate_command

Thrown errors are Discord0Error instances (or subclasses such as ValidationError and InteractionAlreadyRepliedError) with code, detail, why, fix, and docs properties. Match on code, which never changes between releases, rather than on the message:

import { Discord0Error } from "discord0";
try {
app.command("ban", "Ban a member", ban);
} catch (error) {
if (error instanceof Discord0Error && error.code === "DUPLICATE_COMMAND") {
// ...
}
}

Errors from Discord’s API are DiscordAPIError instances instead, with Discord’s status, numeric code, and errors, plus a hint for common codes. See DISCORD_API_ERROR.

This page is generated from packages/discord0/src/errors.ts. A copy ships in the package at node_modules/discord0/ERRORS.md.

What you see: An option passed to new Discord() is out of range.

Why: discord0 checks options when the app is built, so a bad value fails at startup rather than on the first interaction.

Fix: Correct the option named in the message. autoDeferAfterMs must be from 0 to 2999, since Discord drops interactions that aren’t answered within 3 seconds.

new Discord({ autoDeferAfterMs: 2000 });

What you see: A handler was registered on a sub-app after it was mounted.

Why: app.route() copies a sub-app’s commands, components, tasks, and webhooks when it mounts it. Later registrations would be silently lost, so the sub-app is sealed instead.

Fix: Register every handler on the sub-app before passing it to app.route(), and mount inner sub-apps before outer ones.

const tickets = new Discord().command("open", "Open a ticket", () => "Opened");
app.route("ticket", "Manage tickets", tickets); // mount last

What you see: A command, subcommand, or group name breaks Discord’s naming rules.

Why: Discord rejects slash command names that aren’t 1-32 lowercase letters, digits, -, or _, and the whole sync fails.

Fix: Rename it to lowercase without spaces, such as "open-ticket". Show a different name per language with name_localizations.

What you see: A slash command or subcommand is missing its description, or it is too long.

Why: Discord requires every slash command, subcommand, and group to have a description of 1-100 characters.

Fix: Pass a description as the second argument, or as description in the config object.

app.command("ping", "Replies with Pong!", () => "Pong!");

What you see: Two commands of the same type share a name.

Why: Discord identifies a command by its name and type, so the second definition would replace the first when commands sync.

Fix: Rename one of them, or move one into a sub-app mounted with app.route() so it becomes a subcommand.

What you see: The app defines more commands of one type than Discord allows.

Why: Discord allows 100 slash commands, 15 user commands, and 15 message commands per app.

Fix: Group related slash commands into sub-apps with app.route(). Each mount counts as one command and can hold 25 subcommands or groups.

What you see: A command or group has more than 25 subcommands and groups.

Why: Discord allows at most 25 options, including subcommands and groups, on each level of a command.

Fix: Split the sub-app into groups by mounting smaller sub-apps inside it with route().

What you see: A mounted sub-app has no slash commands.

Why: Mounting with a name turns the sub-app’s commands into subcommands, and Discord rejects a command with no subcommands.

Fix: Register at least one command() on the sub-app before mounting it, or mount it without a name: app.route(subApp).

What you see: Commands nest deeper than command → group → subcommand.

Why: Discord supports at most two levels below a command: a group and its subcommands.

Fix: Flatten the tree. Mount sub-apps at most twice deep, and don’t put Subcommand options in options yourself; mount a sub-app instead.

What you see: A subcommand sets a field only top-level commands support.

Why: Fields such as default_member_permissions, contexts, and nsfw apply to a whole top-level command, so Discord ignores or rejects them on subcommands.

Fix: Set the field on the mount instead.

app.route(
{ name: "mod", description: "Moderation", default_member_permissions: "8" },
moderation,
);

What you see: A command’s names, descriptions, and choices exceed 8000 characters.

Why: Discord caps each top-level command, counting all its subcommands, options, choices, and localizations, at 8000 characters.

Fix: Shorten descriptions, move choices to autocomplete, or split the command into several top-level commands.

What you see: Two autocomplete handlers target the same command.

Why: Each command path gets one autocomplete handler, which answers for every option of that command.

Fix: Keep one handler and branch on c.focused?.name to answer for each option.

app.autocomplete("ticket open", (c) =>
c.focused?.name === "team" ? teams : priorities,
);

What you see: An interaction’s options don’t match the command’s definition.

Why: The command registered with Discord differs from the one in your code, usually because commands haven’t been synced since the definition changed. discord0 rejects the interaction rather than hand your handler bad data.

Fix: Sync commands again with discord0 sync (or restart discord0 dev). Until then, users see the generic messages.error reply.

What you see: app.route() was called with something it can’t mount.

Why: route() takes a sub-app built with new Discord(), optionally after a name and description or a config object. A sub-app takes its options from its own commands.

Fix: Pass the sub-app as the last argument, don’t mount an app into itself, and leave options and type off the mount config.

app.route("ticket", "Manage tickets", tickets);
app.route(misc); // no name: its commands stay top-level

What you see: A sub-app has constructor options or lifecycle hooks.

Why: Only the main app serves requests, so options such as publicKey and hooks such as onError on a sub-app would never run.

Fix: Create sub-apps with new Discord() and no options, and set beforeHandle, afterHandle, and onError on the main app.

What you see: A sub-app with context menu commands was mounted under a name.

Why: Discord doesn’t allow user and message commands as subcommands.

Fix: Mount it without a name, app.route(subApp), or move the context menu commands to the main app.

What you see: A custom ID template such as approve:{id} is malformed.

Why: Templates are :-separated literal and {param} segments. Each segment must be non-empty, parameter names must be unique, and the template must fit in Discord’s 100-character custom ID.

Fix: Fix the template named in the message. A template with no {param} is just an ID: register the exact string instead, such as "refresh".

app.component("approve:{id}", (c) => c.update(`Approved ${c.params.id}`));

What you see: CustomId.id() got parameters it can’t encode.

Why: Every parameter needs a non-empty value without :, the separator, and the result must fit in Discord’s 100 characters.

Fix: Pass every parameter, encode values that may contain : (for example with encodeURIComponent), and keep values short: store large state elsewhere and put its key in the ID.

What you see: Two component or modal handlers claim the same custom ID.

Why: discord0 routes each incoming custom ID to exactly one handler; with two candidates the choice would be arbitrary.

Fix: Give each handler its own custom ID or template. Templates overlap when one ID could match both, such as vote:{id} and vote:{choice}; add a distinct literal segment, such as vote:up:{id}.

What you see: A message component or modal breaks Discord’s component rules.

Why: Discord rejects the whole message when one component is invalid, and its error is hard to trace back. discord0 checks components before sending them so the message names the exact field.

Fix: Correct the component field named in the message. Components v2 messages (with MessageFlags.IsComponentsV2) can’t also set content, embeds, poll, or stickers.

What you see: A handler replied to an interaction twice.

Why: Discord accepts exactly one initial response per interaction. Later messages must edit the reply or send follow-ups.

Fix: Use c.editReply() to change the reply, or c.followUp() to send another message. Returning a value from a handler also replies, so don’t both await c.reply() and return a string.

app.command("slow", "Slow command", async (c) => {
await c.defer();
await c.editReply(await work());
});

What you see: A handler edited or followed up on an interaction it hasn’t answered.

Why: Edits and follow-ups act on the original response, which doesn’t exist until the interaction is acknowledged with a message.

Fix: Call c.reply() or c.defer() first. After c.showModal(), answer from the modal’s handler instead.

What you see: A deferred public reply was finished as ephemeral.

Why: Discord fixes a reply’s visibility when it is deferred, so a later reply can’t change it.

Fix: Defer with the visibility you need, c.defer(true) for ephemeral, or send the private message as an ephemeral follow-up.

What you see: update() or deferUpdate() was called on a modal not opened from a message.

Why: Only a modal opened from a message component has a message to update. A modal opened from a slash command has none.

Fix: Check c.interaction.message first, or c.reply() instead.

What you see: Autocomplete choices break Discord’s rules.

Why: Discord shows at most 25 choices, and every choice in one response must have the option’s type: all strings or all finite numbers.

Fix: Return at most 25 choices with .slice(0, 25), and give every choice a value of the option’s type.

What you see: A task’s name or handler is invalid.

Why: Task names become host resource names (Cloudflare Cron Triggers, EventBridge schedules, Netlify functions), so they’re limited to 1-64 lowercase letters, digits, -, and _.

Fix: Use a name such as daily-digest, and pass a handler function as the last argument.

app.task("daily-digest", "0 9 * * *", (c) => c.send(channelId, "Digest"));

What you see: A task’s cron expression uses syntax not every host supports.

Why: discord0 deploys the same schedule to six hosts, so it accepts only what they all share: five fields of numbers, *, lists, ranges, and steps. Days of the week run from 0 (Sunday) to 6.

Fix: Rewrite names such as MON as numbers (1), and @daily as 0 0 * * *. L, W, #, and ? have no portable equivalent.

What you see: A task’s timezone isn’t an IANA time zone.

Why: Hosts that honor time zones need a name from the IANA database; abbreviations such as EST are ambiguous.

Fix: Use a name such as "America/Toronto", or leave timezone off for UTC.

What you see: Two tasks share a name.

Why: A task’s name identifies its schedule on the host and in discord0 task <name>.

Fix: Rename one task. Tasks in sub-apps share the main app’s namespace.

What you see: A task was run by a name the app doesn’t define.

Why: runTask(), discord0 task, and host schedules look tasks up by name.

Fix: Check the spelling against the names listed in the message. After renaming a task, deploy again so the host’s schedule uses the new name.

What you see: The host fired a schedule the deployed app has no task for.

Why: The host’s schedules come from the last deploy. A task removed or rescheduled in code still fires until you deploy again.

Fix: Run discord0 deploy so the host’s schedules match app.task() again.

What you see: The adapter can’t run the app’s scheduled tasks as written.

Why: Each host has its own scheduler. Some can’t run tasks at all, some schedule in UTC only, and EventBridge can’t combine a day of the month with a day of the week.

Fix: Follow the fix in the message, or deploy with an adapter whose scheduler supports the task: aws, node, and bun honor time zones.

What you see: An app.webhook() route has an invalid path or options.

Why: Webhook paths are routed by the host as exact URLs, so they must be absolute, without a trailing slash, query, . or .. segments.

Fix: Use a path such as "/webhooks/github", HTTP methods such as ["POST"], and a positive maxBodyBytes.

What you see: A webhook route has no verify option.

Why: A webhook URL is public, so anyone can post to it. verify is required so that skipping verification is a visible choice.

Fix: Pass verify: verifyHmac({ ... }) or your own check. Pass verify: false only for a source that can’t sign requests.

app.webhook(
"/webhooks/github",
{
verify: verifyHmac({
secret: () => process.env.GITHUB_WEBHOOK_SECRET,
header: "x-hub-signature-256",
prefix: "sha256=",
}),
},
(c) => new Response(null, { status: 202 }),
);

What you see: A webhook or events path collides with another route or a path the host reserves.

Why: Each URL can reach one route. /interactions takes only Discord’s signed interactions, /events takes app.event() webhook events, and some hosts reserve paths such as /api (Vercel) and /.netlify (Netlify).

Fix: Choose another path, such as /webhooks/<service>, or move the events endpoint with new Discord({ eventsPath }).

What you see: app.event() or app.webhook() was called without a handler function.

Why: Each route needs a function to run when it’s called.

Fix: Pass the handler as the last argument.

What you see: app.event() got an event type that isn’t Discord’s name for one.

Why: Discord names webhook events in SCREAMING_SNAKE_CASE, and discord0 enables exactly these names in the Developer Portal instructions.

Fix: Use Discord’s name, such as "APPLICATION_AUTHORIZED" or "ENTITLEMENT_CREATE".

What you see: app.dispatchEvent() got a body that isn’t a Discord webhook event.

Why: dispatchEvent() expects the parsed JSON Discord posts to the events URL: { version, application_id, type, event }.

Fix: Pass the whole event body. In tests, build one with discord0/testing.

What you see: A Discord webhook to post to isn’t a webhook URL.

Why: Posting through a webhook needs its ID and token, which discord0 reads from the URL.

Fix: Pass the URL Discord shows under Integrations → Webhooks, https://discord.com/api/webhooks/<id>/<token>, or { id, token }.

What you see: The app received a request before it had a public key.

Why: Discord signs every interaction with your application’s Ed25519 key, and discord0 must check the signature before trusting the request.

Fix: Set DISCORD_PUBLIC_KEY (Developer Portal → General Information → Public Key) in .env and in the host’s environment, or pass publicKey to new Discord().

What you see: The public key isn’t a 64-character hex string.

Why: An Ed25519 public key is 32 bytes, which the Developer Portal shows as 64 hex characters.

Fix: Copy the Public Key from Developer Portal → General Information again; don’t use the bot token or client secret.

What you see: A command sync ran without a bot token.

Why: Registering commands is a REST call that Discord authorizes with the bot token.

Fix: Set DISCORD_BOT_TOKEN (Developer Portal → Bot → Reset Token) in .env, or skip syncing with --no-sync.

What you see: discord0 couldn’t look up which application the bot token belongs to.

Why: Command sync needs the application ID. Without APPLICATION_ID, discord0 asks Discord for it with the token, which failed.

Fix: Set APPLICATION_ID (Developer Portal → General Information → Application ID), and check that DISCORD_BOT_TOKEN is current.

What you see: A REST request targeted a URL outside Discord’s API.

Why: The REST client attaches the bot token to requests, so it refuses any URL other than https://discord.com/api/v10.

Fix: Call Discord’s API through c.rest or the paths in discord0/openapi. Use fetch for other services.

What you see: A REST, rate limit, or request limit option is out of range.

Why: These limits must be positive, finite numbers for requests to be checked and scheduled.

Fix: Correct the option named in the message, or leave it unset for the default.

What you see: Discord’s API rejected a request.

Why: Discord returned an HTTP error. The error’s status, code, and errors say which; the message adds a likely fix for common codes.

Fix: Read the hint in the message. 401: reset the bot token. 403 or 50001: invite the bot with the bot and applications.commands scopes. 50035: fix the fields listed in the message. 10062: answer within 3 seconds or let discord0 defer.

What you see: discord0.config.ts has an invalid setting.

Why: The CLI validates the config before building, so a typo fails fast instead of deploying with the wrong settings.

Fix: Correct the setting named in the message. Valid options are entry, adapter, guild, and sync.

import adapter from "@discord0/adapter-cloudflare";
import { defineConfig } from "discord0";
export default defineConfig({
adapter: adapter(),
guild: process.env.DISCORD_GUILD_ID,
});

What you see: A guild sync was requested without a server ID.

Why: Syncing to one server, which updates instantly, needs that server’s ID.

Fix: Pass --guild <id>, set DISCORD_GUILD_ID in .env, or set guild in discord0.config.ts. Copy the ID with Developer Mode on: right-click the server → Copy Server ID.

What you see: discord0 deploy doesn’t know which host to deploy to.

Why: Each host needs its own bundle and provider CLI.

Fix: Pass the adapter, discord0 deploy cloudflare, or set adapter in discord0.config.ts.

What you see: The adapter package isn’t installed.

Why: discord0 deploy <name> loads @discord0/adapter-<name> from the project’s dependencies.

Fix: Install the package with the command in the message.

What you see: The configured adapter isn’t a discord0 adapter.

Why: adapter in discord0.config.ts must be the object an adapter package’s default export returns.

Fix: Call the adapter: adapter: cloudflare(), not adapter: cloudflare.

What you see: The entry point is missing, or doesn’t export default a Discord app.

Why: The CLI imports the entry point to read its commands, tasks, and webhooks, and the host calls its fetch.

Fix: Point entry (default src/index.ts) at the file that ends with export default app, where app = new Discord().

What you see: The entry point threw while the CLI loaded it.

Why: Before building, the CLI runs the entry point to read its tasks, webhooks, and events, so top-level code runs then too.

Fix: Read the app’s output in the message. Move work that needs the host’s environment, such as database connections, into handlers.

What you see: Bundling the app for the host failed.

Why: Each host runs one JavaScript file, so the app and its imports must bundle without assets.

Fix: Fix the build errors in the message. Import data as JSON or TypeScript instead of other asset types, and keep the entry point outside .discord0.

What you see: An adapter’s handler ran outside the runtime it was built for.

Why: Each adapter wraps the app for one host’s runtime and relies on its APIs, such as Lambda’s response streaming.

Fix: Deploy the bundle with discord0 deploy <adapter> to the matching host, or import the adapter that matches where the code runs.

What you see: An adapter produced files discord0 refuses to write.

Why: Adapters may write only inside .discord0/<adapter>, so a buggy adapter can’t overwrite the project.

Fix: This is a bug in the adapter. Report it with the path from the message.

What you see: discord0 init can’t create a project in the directory.

Why: init never overwrites files, so it needs a new or empty directory.

Fix: Pass a new directory, discord0 init my-bot, or empty the existing one.

What you see: A discord0/testing helper got a command, option, or app the app doesn’t define.

Why: The test client builds interactions from the app’s own command definitions, the way Discord would, so it rejects names Discord would never send.

Fix: Use the full path, such as client.command("ticket open", { title: "Help" }), and only option names the command defines.

What you see: An interaction, event, task, or webhook handler threw.

Why: discord0 catches the error so the request still gets an answer: users see the generic messages.error reply, webhooks get a 500, and events and tasks are logged.

Fix: Read the error and stack trace below the message. Report errors elsewhere with app.onError().

What you see: Work passed to waitUntil rejected after the response was sent.

Why: The response already went out, so the failure can only be logged.

Fix: Read the error below the message, and catch errors inside the background work if it needs its own handling.

What you see: A webhook’s verify function threw, so the request was rejected with 401.

Why: A verifier that throws can’t vouch for the request, so discord0 treats it as unverified.

Fix: Return false (or a Response) for bad requests instead of throwing, and check the secret and header names.

What you see: verifyHmac() has no secret, so the webhook answered 503.

Why: Without the shared secret no request can be verified, so every request is refused until it’s set.

Fix: Set the secret’s environment variable on the host, then redeploy if the host needs it.