python - 你怎么提
问题描述
我需要用 id 提及一个特定的角色631147065925173310
。我什么都试过了,很多人跟我说我不懂python,这很难,但是我学习如何使用discord.py
才2天。
if channel.name == "General":
await ctx.send(f"{ctx.author.mention}needs help at{channel.mention})
else:
await ctx.send(f"{ctx.author}needs help at an unknown place")
每当一个人写“h!”时,我都想要那个。或帮助,它会说:
@user needs help at #channel @specific role
解决方案
要提及角色或用户,您应该在消息中使用以下语法:
<@id>
因此,将“id”更改为相应角色的 id,这样您的代码将是:
awit ctx.send(f"<@{userId}>nedds help at<@{channelId}>)
推荐阅读
- wordpress - 尝试访问我的网站和 wp-admin 时出现内部错误 500
- python - 为什么 python3.7 中的多线程中的 sleep 功能使输出变得更加可预测?
- web-scraping - 使用 Openoffice BASIC 实现网络自动化甚至是可能的吗?
- powershell - 在 OutGridView 中显示 Get-WinEvent 结果的 ServerName?
- java - Jmeter 2.11:让对等体未经过身份验证
- javascript - 如何使用样式组件将道具传递给 .mapped 元素?
- javascript - 如何使用 influxdb 和 Grafana 通过 docker 运行 K6
- sql - 将数据库排序规则读入 SQL Server 中的变量时出现问题
- vb.net - List 和 CheckedListBox 中的项目顺序问题
- java - Java 串行通信 -> EventListener 的问题