{"record":{"id":"de9ea3f91603f8a3","repo":"paperclipai/paperclip","slug":"discord-token-does-not-identify-a-bot-user","errorCode":null,"errorMessage":"Discord token does not identify a bot user","messagePattern":"Discord token does not identify a bot user","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"server/src/services/chat-discord.ts","lineNumber":230,"sourceCode":"      input.botToken,\n      \"/users/@me\",\n      \"bot identity lookup\",\n    ),\n    discordJson<DiscordApplication>(\n      input.fetch,\n      input.botToken,\n      \"/oauth2/applications/@me\",\n      \"application lookup\",\n    ),\n    discordJson<DiscordGuild>(\n      input.fetch,\n      input.botToken,\n      `/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,","sourceCodeStart":212,"sourceCodeEnd":248,"githubUrl":"https://github.com/paperclipai/paperclip/blob/01ad8584922b5d85292b1723cae71fa0d9b07a19/server/src/services/chat-discord.ts#L212-L248","documentation":"verifyDiscordBot fetches the authenticated user, application, and guild for a supplied bot token, then sanity-checks the identity. This error means the /users/@me payload did not look like a bot account: user.bot was falsy or id/username were missing — i.e. the token is valid but does not belong to a bot user, or the response was unexpectedly shaped.","triggerScenarios":"Using a user account token (not a bot token) as input.botToken; a token that authenticates but returns a user object with bot=false or missing id/username; a Discord API change or proxy stripping fields from the response.","commonSituations":"Configuring a personal Discord account token instead of a token created under Developer Portal > Bot; copying an OAuth client secret instead of the bot token; partially blocked/undocumented API responses.","solutions":["Create/copy the token from the Discord Developer Portal under your Application's Bot page (token starting roughly with 'Bot ' semantics) and never a user token or client secret","Call GET /users/@me manually with the token and confirm the JSON contains \"bot\": true plus id and username","Regenerate the bot token if it was reset and update the configured value"],"exampleFix":"// before\nDISCORD_BOT_TOKEN=mFa.abc123.clientsecret\n// after\nDISCORD_BOT_TOKEN=MTIzNDU2Nzg5MDEyMzQ1Njc4.GaBcDe.xxxxxxxxxxxxxxxxxxxxxxx","handlingStrategy":"validation","validationCode":"// Probe before verifyDiscordBot\nconst res = await fetch(\"https://discord.com/api/v10/users/@me\", {\n  headers: { authorization: `Bot ${token}` },\n});\nconst user = await res.json();\nif (!res.ok || user.bot !== true || !user.id || !user.username) {\n  throw new Error(\"Token is not a valid bot token\");\n}","typeGuard":"const isBotUser = (u) => !!u && typeof u === \"object\" && u.bot === true && typeof u.id === \"string\" && u.id.length > 0 && typeof u.username === \"string\" && u.username.length > 0;","tryCatchPattern":"try {\n  await verifyDiscordBot(input);\n} catch (err) {\n  if (err.message === \"Discord token does not identify a bot user\") {\n    throw new ConfigError(\"botToken must be a bot token from the Developer Portal, not a user token or client secret\");\n  }\n  throw err;\n}","preventionTips":["Store only Developer Portal Bot tokens, never user tokens or OAuth client secrets","Probe GET /users/@me and check bot===true during config onboarding","Regenerate and re-store tokens after any reset; never commit tokens to the repo"],"tags":["discord","auth","bot-token"],"backgroundTag":"authentication-required","analyzedSha":"01ad8584922b5d85292b1723cae71fa0d9b07a19","analyzedAt":"2026-09-10T03:14:50.855Z","contentChangedAt":"2026-09-10T03:14:50.855Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}