I’m developing a Discord bot that requires access to user email addresses for certain features. Although I have added the email scope in my OAuth settings, the user object I get back does not show an email field.
Here’s the authorization link I used, which includes permission for email, but when I run this code:
Discord does this on purpose. Bot tokens can grab messages and user profiles from servers, but emails need individual permission through OAuth2 web flows. Your email scope works fine - users just need to authenticate through your OAuth URL in a browser first. I hit this same issue with a tournament bot that needed emails for notifications. I built a web portal where users do OAuth authentication first, then stored their Discord ID with their email in my database. When they use the bot later, I just look up their email using their Discord ID. The trick is treating these as two separate auth processes that you connect using the Discord ID.
Discord bot tokens can’t grab user emails from message events. The email scope only works with OAuth2 flows where users explicitly authorize your app.
When users message your bot, you’re getting basic profile info - not OAuth data. Want emails? Users need to go through OAuth2 authorization on your website first.
This creates a messy workflow:
Set up OAuth2 endpoints
Store user tokens securely
Link Discord IDs to OAuth profiles
Handle token refresh
I’ve hit this exact problem before. Automating the entire OAuth flow beats trying to patch different APIs together.
Latenode handles the OAuth complexity automatically. You can set up Discord OAuth, store user data, and connect it to bot responses without backend code. It manages token storage and user linking seamlessly.
The automation runs in the background. When someone uses your bot, you already have their email from the OAuth flow stored and ready.
Bot tokens and OAuth serve different purposes - that’s your main issue. Your bot token gets you guild events and basic user data, but emails need explicit user consent through OAuth flows. I hit this same wall building a registration system last year. You’ll need a separate web-based OAuth endpoint from your bot. Users visit your auth URL and grant permissions directly, which gives you an access token with their email data. Here’s how it works: user authorizes through web OAuth, your server saves their email and Discord ID, then when they use your bot later, you match their Discord ID to pull up that stored email. Discord does this because they treat emails as sensitive info that needs explicit consent, unlike basic profile stuff your bot can already access. The OAuth flow makes sure users know they’re sharing their email with your app.
yeah, ur mixing bot tokens and oauth tokens. message events can’t access emails, only oauth url does. u gotta set up a separate oauth flow to get emails and link discord ids later. it’s kinda frustrating but discord has this for privacy reasons.