Lightweight Discord server verification. No pre-made "filled" library. Verification is instant: a user logs in with Discord OAuth2, we confirm they're really a member of the server, and grant them a role server-side. No codes to copy, no slash commands.
- Someone joins your guild, the bot creates a one-time verification token and DMs them a link.
- If users DMs are closed, the bot posts a link button in a fallback channel instead.
- The link sends them through Discord OAuth2.
- On callback, the web app checks:
- the OAuth2
stateparam is genuinely one we signed, - the logged-in Discord account matches the one the DM was sent to,
- that account is still actually in the guild.
- the OAuth2
- If all three pass, the bot token grants the verified role. The web app never holds the bot token in the browser, only the server process does.
- Create an application at the
Discord Developer Portal.
- Bot tab: create a bot, copy the token, enable the Server Members
Intent (privileged, required for
GUILD_MEMBER_ADD). - OAuth2 tab: copy the Client ID/Secret, add a redirect matching
DISCORD_REDIRECT_URI(http & https just in case). - Invite the bot with the
botscope and these permissions: Manage Roles, Send Messages, Embed Links, Attach Files. Make sure the bot's role sits above the role it will be granting.
- Bot tab: create a bot, copy the token, enable the Server Members
Intent (privileged, required for
- Copy
.env.exampleto.envand fill all values in. npm installnpm run buildnpm run dev:botandnpm run dev:web(separate processes/terminals).
- The verified role must be below the bot's own role in the server's role
list, or the
PUT .../roles/{roleId}call will 403. - If your bot is or grows past 100 servers, the Server Members privileged intent needs to be approved by Discord in the verification process before it'll work in production.
PUBLIC_BASE_URLmust be reachable from a user's browser (notlocalhost) once you're not testing locally, put the web package behind a reverse proxy with TLS.
- Add multi-guild support so the bot can handle verification flows for more than one Discord server at a time.