I am running an avatar command which worked before, but every time I try to run it now it gives me the error :
JavaScript
x
2
1
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'Member' object has no attribute 'avatar_url'
2
I feel I am doing something dumb, but what is going wrong?
Here is the code:
JavaScript
1
15
15
1
import discord
2
from discord.ext import commands
3
intents = discord.Intents.default()
4
intents.members = True
5
6
client = commands.Bot(command_prefix="p!", intents=intents)
7
8
@client.command()
9
async def avatar(ctx, user:discord.Member=None):
10
if user is None:
11
await ctx.send("Invalid user!")
12
await ctx.send(user.avatar_url)
13
14
client.run('xxxxx')
15
Thanks in advance for the help.
Advertisement
Answer
If you’ve updated your discord.py then avatar_url
got replaced with avatar.url
.