Get user by ID via DM Slash command
I'm trying to get a User obj for a specifc user by their ID, but from a Slash command thats run via a DM ...
I know when working in the guild, it can be gotten from like
interaction.guild.members.cache.get(UID)
however, in DMs there is no guild.
Is there any way to do this? Or even get the guild object (by ID) from a DM message?
Basically I'm budling a secret santa type bot for my server ... User A can send the bot a question via a slash command, the bot then gets who User A drew for the drawing; and sends them (User B) a DM asking the question .. but I can't get the user object for User B in the DMs so send the message to5 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!
- ✅
Marked as resolved by OP^14.13.0
node 18.17.0
use <User>.createDM()
to fetch the user, use <Client>.users.fetch(id)
<Client> in this instance would be the interaction correct? This has the user Object, but its the user who ran the interaction ... Im probably missing something tho
User A -> DMs bot with the /ask command -> Bot pull the info from the database, which is User Bs userID ... -> Bot sending DM to User B
perfect ... I always forget you can get client from interaction