{"record":{"id":"718eb84b34e448d5","repo":"paperclipai/paperclip","slug":"discord-bot-is-not-installed-in-the-selected-serve","errorCode":null,"errorMessage":"Discord bot is not installed in the selected server","messagePattern":"Discord bot is not installed in the selected server","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"server/src/services/chat-discord.ts","lineNumber":243,"sourceCode":"      `/guilds/${encodeURIComponent(guildId)}`,\n      \"server membership lookup\",\n    ),\n  ]);\n  if (!user.bot || !user.id || !user.username) {\n    throw new Error(\"Discord token does not identify a bot user\");\n  }\n  if (application.id !== applicationId || user.id !== applicationId) {\n    throw new Error(\n      \"Discord Application ID does not match the supplied bot token\",\n    );\n  }\n  if (((application.flags ?? 0) & MESSAGE_CONTENT_FLAGS) === 0) {\n    throw new Error(\n      \"Discord Message Content intent is not enabled for this application\",\n    );\n  }\n  if (guild.id !== guildId) {\n    throw new Error(\"Discord bot is not installed in the selected server\");\n  }\n  return {\n    providerAccountId: guildId,\n    providerAccountLabel: guild.name ?? guildId,\n    botExternalId: user.id,\n    botUsername: user.username,\n    botLabel: user.global_name ?? application.name ?? user.username,\n    ...(user.avatar\n      ? {\n          botAvatarUrl: `https://cdn.discordapp.com/avatars/${user.id}/${user.avatar}.png`,\n        }\n      : {}),\n  };\n}\n\nexport async function listDiscordBotChannels(input: {\n  botUserId: string;\n  botToken: string;","sourceCodeStart":225,"sourceCodeEnd":261,"githubUrl":"https://github.com/paperclipai/paperclip/blob/01ad8584922b5d85292b1723cae71fa0d9b07a19/server/src/services/chat-discord.ts#L225-L261","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Invite the bot to the selected server using its OAuth2 authorize URL with the correct guild_id and bot scope","Re-check that the guildId entered/selected matches the server where the bot is installed (copy the server ID via Developer Mode)","Confirm the botToken belongs to the same application as applicationId; a mismatched token can point at a different installation","If the bot was recently removed, re-add it before retrying verification"],"exampleFix":"// before: selected guildId copied from the wrong server\nverifyDiscordBot({ applicationId, botToken, fetch, guildId: \"111111111111111111\" });\n// after: guildId from the server where the bot is actually installed\nverifyDiscordBot({ applicationId, botToken, fetch, guildId: \"222222222222222222\" });","handlingStrategy":"validation","validationCode":"const guild = await fetch(`https://discord.com/api/v10/guilds/${guildId}`, { headers: { Authorization: `Bot ${botToken}` } });\nif (guild.status === 404) throw new Error(`Bot is not installed in guild ${guildId}; invite it first`);","typeGuard":null,"tryCatchPattern":"try {\n  await verifyDiscordBot({ applicationId, botToken, fetch, guildId });\n} catch (err) {\n  if (err instanceof Error && err.message === \"Discord bot is not installed in the selected server\") {\n    promptUserToReinviteBot(guildId);\n  } else throw err;\n}","preventionTips":["Copy the guild ID via Discord Developer Mode (right-click server) from the same server the bot is invited to","Automate the invite: redirect users through the bot's OAuth2 authorize URL with scope=bot and a fixed guild selection","Re-verify bot presence in the guild whenever configuration is loaded, not just at initial setup"],"tags":["discord","oauth","configuration","integration"],"backgroundTag":"resource-not-found","analyzedSha":"01ad8584922b5d85292b1723cae71fa0d9b07a19","analyzedAt":"2026-09-10T03:14:50.855Z","contentChangedAt":"2026-09-10T03:14:50.855Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}