如何在嵌入标题中添加用户的头像?不和谐.py

时间:2021-06-05 17:07:34

标签: discord discord.py

这是我的代码示例。

@client.command()
async def test(ctx):
  test = discord.Embed(
        title=f"{ctx.author.avatar_url}",
        #skip
    )

    await ctx.send(embed=test)

I am trying to make it like this, but it's not working.

2 个答案:

答案 0 :(得分:0)

使用 author 方法代替 title 属性设置 set_author() 属性。像这样:

@client.command()
async def test(ctx):
    test = discord.Embed()
    test.set_author(name="title", icon_url=ctx.author.avatar_url)
    await ctx.send(embed=test)

答案 1 :(得分:0)

在这种情况下,图片在embed.thumbnailembed.author.image中,所以你必须设置这两个:

@client.command()
async def test(ctx):
    test = discord.Embed(title=f"Your embed title in the picture you attached it's Eggspert Player but doesn't have to be")
    test.set_author(name=ctx.author.name, icon_url=ctx.author.avatar_url)
    test.set_thumbnail(url=ctx.author.avatar_url)
    await ctx.send(embed=test)

参考资料