'Nextcord Display User Avatar
@client.command()
async def avatar(ctx, *, member : nextcord.Member = None):
if member == None:
member = ctx.author
memberAvatar = member.avatar_url
avaEmbed = nextcord.Embed(title = f"{member.name}'s Avatar")
avaEmbed.set_image(url = memberAvatar)
await ctx.send(embed = avaEmbed)
I get an error running this code, here is the problem I am getting:
raise CommandInvokeError(exc) from exc
nextcord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'Member' object has no attribute 'avatar_url'
Solution 1:[1]
Member does not have the attribute avatar_url instead, if you look over at the docs you will see that you should use
member.avatar.url
Note that avatar might be None!
Solution 2:[2]
It was changed in Discord.py 2.0 (aka what nextcord uses)
its now member.avatar.url
Solution 3:[3]
In some forks like Nextcord,
its
member.avatar.url
not member.avatar_url
Many other things got changed too, so go ahead and read the docs.
Solution 4:[4]
It's because you need to make it member.avatar.url although, if you want it to be the guild avatar(if the member has one) or just a global avatar you can make it member.display_avatar
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | HippoBaguette |
| Solution 2 | Glowstik_ |
| Solution 3 | Navis |
| Solution 4 | realShamlol |
