我的头像命令不起作用 - 我该如何解决?

My avatar command isn't working - How do I fix it?

@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()

它给我一个错误:

Command raised an exception: AttributeError: 'str' object has no attribute 'message'

我该如何解决这个问题?

试试这个:

@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()