Fetch user that isn't in current server

How do I fetch a user that's not in the same server as my bot? This is for a command that will display an embed with the user's name (as well as some other stuff), but I'm not sure how to do it. I was able to do that in some of my other commands because it took a User object as a slash command option, but since this particular command that I'm writing now doesn't do that, I'm not sure how to fetch it.
const displayUserInfo = (userId: string) => new EmbedBuilder()
.setTitle(`Displaying info for ${//fetch user here using userId somehow}`)
const displayUserInfo = (userId: string) => new EmbedBuilder()
.setTitle(`Displaying info for ${//fetch user here using userId somehow}`)
Using discord.js 14.7.1 with node.js 19.6.0
9 Replies
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Idris
Idris2y ago
if I get it correctly, you’re using / commands right?
Araraura
ArarauraOP2y ago
yes
Idris
Idris2y ago
so you just need the user option no need to fetch anything
Araraura
ArarauraOP2y ago
wouldn't that just take the user that used the command?
Idris
Idris2y ago
? if you pass a valid user to your user option it resolves to a User object
Araraura
ArarauraOP2y ago
But I'm not taking a User option in this particular command that I'm writing only did that for the other commands that I wrote, and I'll need to fetch multiple different users
Idris
Idris2y ago
client.users.fetch(id)
Araraura
ArarauraOP2y ago
got it, thanks!
Want results from more Discord servers?
Add your server