paperclipai/paperclip · error · Error

Discord bot is not installed in the selected server

Error message

Discord bot is not installed in the selected server

What it means

During Discord bot verification, verifyDiscordBot fetches the bot's guild via GET /guilds/{guildId}. Discord only returns the guild if the bot is actually a member of it; a mismatched or missing guild.id means the bot token is not installed in the server ID the user selected. The service throws this error to stop onboarding with a bot that cannot operate in that server.

Source

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

      `/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
      ? {
          botAvatarUrl: `https://cdn.discordapp.com/avatars/${user.id}/${user.avatar}.png`,
        }
      : {}),
  };
}

export async function listDiscordBotChannels(input: {
  botUserId: string;
  botToken: string;

View on GitHub (pinned to 01ad858492)

Solutions

  1. Invite the bot to the selected server using its OAuth2 authorize URL with the correct guild_id and bot scope
  2. Re-check that the guildId entered/selected matches the server where the bot is installed (copy the server ID via Developer Mode)
  3. Confirm the botToken belongs to the same application as applicationId; a mismatched token can point at a different installation
  4. If the bot was recently removed, re-add it before retrying verification

Example fix

// before: selected guildId copied from the wrong server
verifyDiscordBot({ applicationId, botToken, fetch, guildId: "111111111111111111" });
// after: guildId from the server where the bot is actually installed
verifyDiscordBot({ applicationId, botToken, fetch, guildId: "222222222222222222" });
Defensive patterns

Strategy: validation

Validate before calling

const guild = await fetch(`https://discord.com/api/v10/guilds/${guildId}`, { headers: { Authorization: `Bot ${botToken}` } });
if (guild.status === 404) throw new Error(`Bot is not installed in guild ${guildId}; invite it first`);

Try / catch

try {
  await verifyDiscordBot({ applicationId, botToken, fetch, guildId });
} catch (err) {
  if (err instanceof Error && err.message === "Discord bot is not installed in the selected server") {
    promptUserToReinviteBot(guildId);
  } else throw err;
}

Prevention

When it happens

Trigger: verifyDiscordBot({applicationId, botToken, fetch, guildId}) succeeds on /users/@me and /oauth2/applications/@me, but GET /guilds/{guildId} returns a guild whose id differs from the requested guildId (Discord resolves the token's actual guild context) — i.e., the bot is not a member of the selected guild.

Common situations: User pasted a server ID from a different Discord workspace than where the bot was invited; bot was kicked/removed from the server after configuration; wrong bot token paired with a guildId the developer assumed; OAuth flow installed the bot into a different guild than the one selected in the UI.

Understand the failure class

Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.

Related errors


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