#any way to get the user from userID?

44 messages · Page 1 of 1 (latest)

reef geyser
#

i want to know this

pine geyser
#

member: <Guild>.members.fetch("id")
user (if you don't need guild data or don't have a guild available in the context): <Client>.users.fetch("id")

#

either will reject the returned promise if not a part of a guild (only for member) or wrong id

reef geyser
#

that didnt seem to work

pine geyser
#

well, that is how it works

#

if that didn't work, elaborate

reef geyser
#

lemme do it and send u the logs

#
client.users.fetch(userid).then((user) => {
    console.log(user);
}).catch(console.error);```
pine geyser
#

why are you fetching a user if you have one nayways?

reef geyser
#

mhm

#

and this worked

#

my god

#

every time i seek for help it starts working for no reason

#

lol

pine geyser
#

questionable

#

code tends to be more or less determinisitc

reef geyser
#

really

pine geyser
#

yeah, literally impossible

#

you can say really as much as you want

reef geyser
#

the only issue here is that the banner doesnt seem to work for some reason

pine geyser
#

odd
i do know you need to fetch the user, because the user data we usually get doesn't include it but... that's quite literally what you are doing with that

#

ah, it is cached, so the fetch short-circuits
(fetch always tries to hit the cache before the api and resolves with the cached user data, if available)

#

force-fetch (so it actually hits the API)

#

.fetch(id, true)

reef geyser
#

theres another issue

pine geyser
#

that is turning into base js now

reef geyser
#

how can i bring the user value outside of the block

lime lotusBOT
pine geyser
#

the "user" variable is only valid within the then callback function
anything that needs to happen afterwards needs to be within that scope

reef geyser
pine geyser
#

you don't

reef geyser
#

oh

#

so it looks like its useless in that case?

pine geyser
#

what?

reef geyser
#

the main point of getting the user info is using it elsewhere

pine geyser
#

i think you should read both what i just said as well as the resources in the tag above

#

without understanding promises this will be a bit of a pain. anything we do that hits the API will return a promise, familiarising yourself with them is def. recommended

reef geyser
#

okay alright

reef geyser
pine geyser
#

fetch returns one, yes