-
User avatar fetch v13 |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
client.users.fetch("id").avatarURL() |
Beta Was this translation helpful? Give feedback.
-
Superseding @xrenata's answer as it's incorrect: const user = await client.users.fetch('id');
const avatar = user.displayAvatarURL();
// Use `avatar` here The issue with the previous "correct" answer is that However, the |
Beta Was this translation helpful? Give feedback.
Superseding @xrenata's answer as it's incorrect:
The issue with the previous "correct" answer is that
users.fetch
returns aPromise<User>
, and thePromise
object does not have a property (nor a method) with the name ofdisplayAvatarURL
, so it becomes undefined and eventually throws, this makes the code invalid.However, the
User
class has bothavatarURL()
(returnsnull
when the user uses their default avatar) anddisplayAvatarURL()
(returns default avatar if none is set).