Linking NextAuth Discord provider to Discord user calling a slash command

I've got an application that allows users to sign in using the NextAuth Discord provider. I'm creating a Discord bot with a slash command that, when called, will create a chat room on my application and then reply to the user with a link (basically just a prisma create, return object id). My issue is that the user needs to be assigned the room owner, so that they can only have 1 active room. Is it possible to do this? I was hoping to just find the user by email address but this isn't returned by the Discord API. It looks like the user's name doesn't update in the db if they change it.
Solution:
It is the Discord user id is store i can’t remember if it’s in user table or account but create a user and search for the id 👍
Jump to solution
5 Replies
hyhy
hyhy15mo ago
Thinking about this briefly, I probably need to find the auth code and upsert any changes to their username on login - not quite ideal since they can change their username after login but should be fine for 99% of cases if i can do that
Steven-sensei
Steven-sensei15mo ago
If i remember well, next auth when used with Discord provider create a user with the Discord user id 😅 can check this when i m home
hyhy
hyhy15mo ago
That would be the best case scenario :D I'll take a look
Solution
Steven-sensei
Steven-sensei15mo ago
It is the Discord user id is store i can’t remember if it’s in user table or account but create a user and search for the id 👍
hyhy
hyhy15mo ago
Found it in the account table under providerAccountId, thank you!
Want results from more Discord servers?
Add your server