-
|
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` hereThe 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.fetchreturns aPromise<User>, and thePromiseobject 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
Userclass has bothavatarURL()(returnsnullwhen the user uses their default avatar) anddisplayAvatarURL()(returns default avatar if none is set).