Python Discord 机器人 |我如何在嵌入中提及某人?

时间:2021-01-11 12:16:23

标签: python-3.x discord discord.py

我想在嵌入中提及用户。我当前的代码是:

    @staticmethod
    def cr_embsuc(ctx, bot, ad, irk, sinif):
        embed = discord.Embed(title="Başarıyla karakter oluşturuldu.", color=0x0b9310)
        embed.set_author(name="DcRPG - Character Creation", icon_url=bot.user.avatar_url)
        embed.add_field(name=str(ctx.author)+" isimli kullanıcının karakteri ", value="Ad : "+ad+"\n"+"Irk : "+irk+"\n"+"Sınıf : "+sinif,
                        inline=True, )
        embed.set_thumbnail(url="https://cdn3.iconfinder.com/data/icons/flat-actions-icons-9/792/Tick_Mark_Dark-512.png")
        embed.set_footer(text="Footeroe", icon_url=bot.user.avatar_url)
        return ctx.send(embed=embed)


结果如下:

enter image description here

我希望它是这样的:

enter image description here

我该怎么做?

1 个答案:

答案 0 :(得分:1)

您可以使用 discord.Member.mention 提及某人。但据我所知,您不能在嵌入或字段的 name 中提及某人。所以你基本上可以这样做:

embed = discord.Embed(title="Başarıyla karakter oluşturuldu.", color=0x0b9310)
embed.add_field(name=str(ctx.author), value=ctx.author.mention)