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

时间:2021-02-11 07:15:07

标签: python discord avatar

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

它给了我一个错误:

<块引用>

命令引发异常:AttributeError: 'str' object has no 属性'消息'

我该如何解决这个问题?

1 个答案:

答案 0 :(得分:0)

试试这个:

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