Use Discord.js v14 for an OAuth user
For a new project of mine, I need to use user's data directly, aka OAuth then user endpoints.
I saw that Discord.js modules (djs next?) provide basic methods and classes to handle auth, data queries etc. However, it does the same QOL features than v14 (or prior), e.g. caches etc. I believe it is to be expected since next is intended to have little abstraction.
Here comed my question. Can I use Discord.js v.14 (aka not modules) to handle the dirty job for me (provided that I have the user's oauth tokens)?
Tldr; can I use Discord.js v14 for a 'bearer' user instead of a bot?
2 Replies
- What's your exact discord.js
npm list discord.js
and node node -v
version?
- Not a discord.js issue? Check out #other-js-ts.
- Consider reading #how-to-get-help to improve your question!
- Explain what exactly your issue is.
- Post the full error stack trace, not just the top part!
- Show your code!
- Issue solved? Press the button!well the main part that
discord.js
does not support is the oauth flow to get a bearer token
discord.js
depends on @discordjs/rest
which does support using bearer tokens for request authorization
you're free to use <Client>.rest
, your client's REST
instance, and specify the authPrefix
option per request
there's also a couple methods such as <GuildMemberManager>.add()
that implement endpoints that require bearer tokens