Skip to content
Advertisement

discord.py avatar command bringing up error

I am running an avatar command which worked before, but every time I try to run it now it gives me the error :

discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'Member' object has no attribute 'avatar_url'

I feel I am doing something dumb, but what is going wrong?

Here is the code:

import discord
from discord.ext import commands
intents = discord.Intents.default()
intents.members = True

client = commands.Bot(command_prefix="p!", intents=intents)

@client.command()
async def avatar(ctx, user:discord.Member=None):
    if user is None:
        await ctx.send("Invalid user!")
    await ctx.send(user.avatar_url)

client.run('xxxxx')

Thanks in advance for the help.

Advertisement

Answer

If you’ve updated your discord.py then avatar_url got replaced with avatar.url.

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement