Riceblades
Riceblades

Reputation: 349

Fetching Discord Profile Picture from ID discord.py

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!

Upvotes: 2

Views: 4302

Answers (2)

gaming man
gaming man

Reputation: 42

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

Upvotes: 1

FLAK-ZOSO
FLAK-ZOSO

Reputation: 4088

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.

Upvotes: 0

Related Questions