首页 > 解决方案 > 如何显示作者的 Discord 标签

问题描述

如何显示用户的姓名 + Discord 标签?如:

我知道; f"Hello, <@{ctx.author.id}>" 将返回用户,并被 ping 通。(@用户)

然后; f"Hello, {ctx.author.name}" 将返回用户的昵称,但后面没有 #XXXX。(用户)

但是如何让它显示用户的全名和标签?(用户#XXXX)

标签: pythondiscorddiscord.py

解决方案


下面我列出了大多数(如果不是全部)您可以使用的方式ctx.author,以及它提供的功能。

    await ctx.send(f"Hello {ctx.author}") # author + number discriminator
    await ctx.send(f"Hello {ctx.author.display_name}") # nickname of author of message
    await ctx.send(f"Hello {ctx.author.mention}") # mention the author (ping)
    await ctx.send(f"Hello {ctx.author.id}") # author's user id
    await ctx.send(f"Hello {ctx.author.discriminator}") # the numbers from author#0001

ctx.author 东西


推荐阅读