#Get discord user data to show in website

9 messages · Page 1 of 1 (latest)

cold turtle

I'm making a dashboard for my project, the project includes a module to work with discord.js, and in this module the bot saves some data in the database, one of this is a User ID

Now, in the front-end with React + vite, working with this data, i get an obstacle...

With this ID, i want to get the user name, avatar and discriminator to show on the page, only public informations

  • I read the discord API docs but i didn't find something about this, only how get self user data (GET /users/@me), but i want to get other users public data
  • Watching the discord web requests, i saw the route users/:userId/profile, this route returns what i want (name, avatar and discriminator) but when trying to get the data, i observe who the Discord doesn't accept tokens provided by Oauth (Bearer xxxxxxxx)

So, i want to know... How can i do this? I only want the name, avatar and discriminator

  • I studied the possibility to save the user name when i'm saving this data in the database, but the user can only change they name and mock this
  • I studied the possibility to do a anchor to redirect the user to https://discord.com/users/:userId, but the dashboard can run in mobile too, so the user will need to login in discord with browser only to see the user? in addition to the fact that the information would not be explicit
  • I studied to get the members informations by the guild members, but, if the user leave or get banned / kicked of the guild?

(I'm marking all the tags because this question envolves all of them, node.js because my bot with discord.js module and api made with hyper-express, typescript because it's my language, database because the data who i'm working, and browser because of the react website, and the solution can involve any of the 4)

  • I only have the bearer user token (and all oauth info)
cold turtle

.

silver hare

tbh I would just use @discordjs/rest

silver hare
cold turtle .

Or simply make a GET request to https://discord.com/api/users/{userId} with a header containing Authorization: Bot TOKEN

and provide any bot token

cold turtle
silver hare and provide any bot token

I don't think so, but could that be a problem? I mean, it's a bot with token exposed to the public (in the source of website and network bar in devtools)

I imagine that not adding the bot to any server and setting it private would solve this, but I'm wondering if I might be forgetting something

silver hare

just make the request server sided?

if you make a dashboard you gotta have a server side

cold turtle