paperclipai/paperclip · error · Error

Discord Application ID does not match the supplied bot token

Error message

Discord Application ID does not match the supplied bot token

What it means

After identity checks, verifyDiscordBot requires that both the fetched application id and the bot user id equal the caller-provided Application ID. This error means the token authenticates successfully but belongs to a different Discord application than the one configured — a mismatch between the bot token and application ID credentials.

Source

Thrown at server/src/services/chat-discord.ts:233

    ),
    discordJson<DiscordApplication>(
      input.fetch,
      input.botToken,
      "/oauth2/applications/@me",
      "application lookup",
    ),
    discordJson<DiscordGuild>(
      input.fetch,
      input.botToken,
      `/guilds/${encodeURIComponent(guildId)}`,
      "server membership lookup",
    ),
  ]);
  if (!user.bot || !user.id || !user.username) {
    throw new Error("Discord token does not identify a bot user");
  }
  if (application.id !== applicationId || user.id !== applicationId) {
    throw new Error(
      "Discord Application ID does not match the supplied bot token",
    );
  }
  if (((application.flags ?? 0) & MESSAGE_CONTENT_FLAGS) === 0) {
    throw new Error(
      "Discord Message Content intent is not enabled for this application",
    );
  }
  if (guild.id !== guildId) {
    throw new Error("Discord bot is not installed in the selected server");
  }
  return {
    providerAccountId: guildId,
    providerAccountLabel: guild.name ?? guildId,
    botExternalId: user.id,
    botUsername: user.username,
    botLabel: user.global_name ?? application.name ?? user.username,
    ...(user.avatar

View on GitHub (pinned to 01ad858492)

Solutions

  1. Open the Discord Developer Portal, copy the Application ID from the same application whose Bot page supplied the token, and update config so both come from one app
  2. Call GET /oauth2/applications/@me with the token and use its returned id as the Application ID
  3. Search config/env for other Discord app values that may have been mixed in

Example fix

// before
DISCORD_APPLICATION_ID=1111111111111111111  // from app A
DISCORD_BOT_TOKEN=<token from app B>
// after
DISCORD_APPLICATION_ID=2222222222222222222  // same app as token
DISCORD_BOT_TOKEN=<token from app B>
Defensive patterns

Strategy: validation

Validate before calling

const app = await fetch("https://discord.com/api/v10/oauth2/applications/@me", {
  headers: { authorization: `Bot ${botToken}` },
}).then((r) => r.json());
if (app.id !== applicationId) throw new Error("Application ID does not belong to this bot token");

Try / catch

try {
  await verifyDiscordBot(input);
} catch (err) {
  if (err.message.includes("Application ID does not match")) {
    throw new ConfigError("applicationId and botToken must come from the same Discord application");
  }
  throw err;
}

Prevention

When it happens

Trigger: Application ID env var from app A paired with bot token from app B; rotating the bot in the Developer Portal and updating the token but not the Application ID (or vice versa); pasting a guild/user ID into the applicationId field.

Common situations: Multiple Discord apps in config (staging/prod) with swapped values; re-creating an application so the old configured ID no longer matches any live token; team members copying values from different apps.

Understand the failure class

Background: "Invalid value" and "allowed values are" config errors: what your library rejected and how to fix it — this error's family across 41 libraries.

Related errors


AI-assisted analysis of paperclipai/paperclip@01ad858492 (2026-09-10). Data as JSON: /api/errors/73215f51c076997c. Report an issue: GitHub.