Reputation: 1
@client.command()
async def avatar(self, ctx, *, member: discord.Member=None):
if not member:
member = ctx.message.author
favatar = discord.Embed(title=f"{member.name}'s avatar", color=0x000000)
favatar.set_footer(text=f"Requested by {ctx.author.name}#{ctx.author.discriminator}")
favatar.set_image(url='{}'.format(member.avatar_url))
await ctx.send(embed = favatar)
await ctx.message.delete()
It gives me an error:
Command raised an exception: AttributeError: 'str' object has no attribute 'message'
How can I fix this issue?
Upvotes: 0
Views: 151
Reputation: 1639
Try this out:
@client.command()
async def avatar(ctx, member: discord.Member=None):
if member is None:
member = ctx.author
favatar = discord.Embed(title=f"{member.name}'s avatar", color=0x000000)
favatar.set_footer(text=f"Requested by {ctx.author.name}#{ctx.author.discriminator}")
favatar.set_image(url='{}'.format(member.avatar_url))
await ctx.send(embed = favatar)
await ctx.message.delete()
Upvotes: 1