#How to get avatarURL from user id?
26 messages · Page 1 of 1 (latest)
fetch the user, then you can use the avatarURL method
should i use
client.users.fetch(id).avatarURL
fetch returns a promise and avatarURL is a method
for context; i have 2 arguments. top ones are directly the user's id and bottom ones are converted ones
you should use fetch instead of cache.get for users, it checks cache first by default
well i got a different error atleast. i guess that can help us
you didn't set the token yet (via client.login) when you tried to execute the above code
the token of what
your bot's token, that you pass to client.login
without it you can't make most api requests
i mean the code is 135 lines it was working until a single avatar line change ant it gives different errors rn. the token is in index.js via env
Up
Are you trying to initialize these before login?
the login is in index.js
this is a command file
how tf it got that error it wasn't getting it until i changed it to fetch
You can’t access the api until your bot is logged in
Is the error happening when you try to use the command or bot startup?
bot startup somehow
the reason i'm mentioning about it because it was working perfectly fine until i changed cache.get to fetch
like how does that effect the token directly
Fetch tries to hit the API, where get looks in the cache and returns undefined (untested)
In order to fetch users your bot needs to have logged in and authenticated beforehand
If you have those fetch statements out side of where your command executes it’s likely that those lines are running when you try and define your command.
end of index.js