python - 如何显示作者的 Discord 标签
问题描述
如何显示用户的姓名 + Discord 标签?如:
我知道;
f"Hello, <@{ctx.author.id}>"
将返回用户,并被 ping 通。(@用户)
然后;
f"Hello, {ctx.author.name}"
将返回用户的昵称,但后面没有 #XXXX。(用户)
但是如何让它显示用户的全名和标签?(用户#XXXX)
解决方案
下面我列出了大多数(如果不是全部)您可以使用的方式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
推荐阅读
- java - 使用递归/辅助函数计算链表的大小 - Java
- reactjs - 单击通知时导航到特定屏幕 - React Native
- javascript - 无法获取按钮的 ID
- java - JSoup - 无法通过经过身份验证的代理进行隧道传输
- c++ - 使用stl交换堆栈c ++中的第一个和最后一个元素
- tsql - SQL XQuery;更新类型化 XML 中的属性
- ruby-on-rails - Rails - 如何在哪里使用自定义属性?
- c# - 从 PreviewMouseLeftButtonDown 获取 Listview ot ListViewItem 的索引
- regex - 匹配单词的第一部分并且仅匹配剩余单词的部分的正则表达式
- excel - “For”循环不会删除工作表中的所有图表