Fetching Discord Profile Picture from ID discord.py

Viewed 455

I am wondering how I can fetch the profile picture of a discord user without my bot being in a server with them. https://discord.id can do this and I'm wondering how I could in discord.py. Thanks!

2 Answers

Here you can use something like this:

User = await client.fetch_user(DISCORD_ID_HERE)
print(User.avatar) # this will print the link to the users profile picture!

for even more info I'd suggestion reading discord.py's documentation

You can use the attribute (actually it is a @property) .avatar_url of class discord.Member, it will give you the link to the avatar.

Notice that sending the bare url in Discord will create an embed with the image, so probably you don't even need to download the image.


Also class discord.User has an avatar_url attribute, so you can fetch the user using the fetch_user method

await Bot.fetch_user(id)

and then get the avatar reading the property avatar_url.

Related