首页 > 解决方案 > 无法在嵌入消息的标题 discord.py 中标记成员

问题描述

我的不和谐机器人应该在包含 GIF 的嵌入中标记人。我使用以下代码来提及:

embed = discord.Embed(title = f"{member.mention}, I'm sorry...")

但是,我没有标记成员,而是获得了 ID:屏幕截图

标签: pythondiscorddiscord.py-rewrite

解决方案


Alkes02 的回答不是真的。

您可以在嵌入中标记(他们不会收到通知)人。

从我的机器人中查看下图: https ://gyazo.com/118f0251798afd32bdd23d806c694544

我相信您只需获取消息的作者并将 a 添加.mention到对象的末尾即可。

for user in board:
    description += f"**{board.index(user) + 1}.** {user[0].mention} | Level: {user[1]} | 
                   XP: {user[2]}\n"
msg = discord.Embed(
    color=discord.Color.green(),
    title=f"{str(ctx.guild)}" "s Valley Leaderboard",
    description=description,
)

await ctx.send(embed=msg)

推荐阅读