Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get profile picture from set user

I'm looking to get my bot to reply to my command with a hard-coded user's profile picture.

This is the code I have for now, as it is it replies with the message.author's pfp and I'm wondering if and how I could replace the user = message.author for it to target a hard-coded user.

if message.content.upper().startswith('TEST'):
userID = message.author.id
user = message.author
pfp = user.avatar_url
embed = discord.Embed(
  title="test",
  description='<@%s>, test' % (userID),
  color=0xecce8b
)
embed.set_image(url=pfp)

await client.send_message(message.channel, embed=embed) `

I also know that if I switch to "for user in message.mentions" I can get it to pop out the mentioned user's pfp, but again, I want to be able to do this without mentioning anyone.

Thank you for your time and any answers brought forward!

like image 288
Teddy Avatar asked Mar 05 '23 18:03

Teddy


1 Answers

You can use Server.get_member to resolve the Member whom you have the id for.

if message.content.upper().startswith('TEST'):
    user = message.server.get_member("116273596605049942") # Fake snowflake, will not work
    if not user:
        return # Can't find the user, then quit
    pfp = user.avatar_url
    embed=discord.Embed(title="test", description='{}, test'.format(user.mention) , color=0xecce8b)
    embed.set_image(url=(pfp))
    await client.send_message(message.channel, embed=embed)
like image 130
Patrick Haugh Avatar answered Mar 08 '23 23:03

Patrick Haugh