-2

So im trying to make a self bot that when I mention someone the bot changes my avatar with the mentioned person's avatar. Is that possible?

The code im using is this:

@bot.command()
async def avatar(ctx):
    await bot.user.edit(avatar=pfp)

But idk how to get the mention person's avatar.

1 Answers1

1

If you only want to get the user's avatar you can use the following method:

@bot.command()
async def avatar(ctx, *, user: discord.Member = None):
    author = ctx.author

    if not user:
        user = author # Get your avatar if you do not mention someone

    if user.is_avatar_animated():
        url = user.avatar_url_as(format="gif") # Check if it is a GIF
    if not user.is_avatar_animated():
        url = user.avatar_url_as(static_format="png") # If it is not a GIF = PNG

    await ctx.send("{}'s avatar: {}".format(user.name, url)) # Output a link + picture
Dominik
  • 3,551
  • 2
  • 6
  • 32