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 to
5 Replies
d.js toolkit
d.js toolkit11mo ago
- 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
Nahana
NahanaOP11mo ago
^14.13.0 node 18.17.0
treble/luna
treble/luna11mo ago
use <User>.createDM() to fetch the user, use <Client>.users.fetch(id)
d.js docs
d.js docs11mo ago
method UserManager#send() Sends a message to a user.
Nahana
NahanaOP11mo ago
<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
Want results from more Discord servers?
Add your server