python - 用 python 在 Discord 上标记某人
问题描述
这是我第一次在 Discord 上制作机器人,我想在我的频道上标记一个成员,并在其中添加一条消息。我的代码是这样的:
@client.event
async def on_message(message):
if message.author == client.user:
return
if message.content.startswith('|bro'):
await message.channel.send("You are dumb" + the member)
消息应该是这样的:"You are dumb @themember"
解决方案
如果您想 ping 作者,只需message.author.mention
在您的回复中包含。
“.mention”会 ping 用户,就像您使用 @ 符号一样。
推荐阅读
- google-cloud-storage - 谷歌云服务不允许我查看我刚刚创建的存储桶?
- snowflake-cloud-data-platform - 无法使用 Apache Spark 连接器创建 Snowflake 临时阶段
- mysql - 排名不重复
- javascript - Joi Validation - 验证数组,即使只有一个元素与模式匹配
- wpf - 将 ViewModel 属性绑定到静态资源的属性
- python - 如何从 lambda 函数中的变量生成持久值
- tensorflow - tensorflow_core.keras.callbacks 没有属性“Earlystopping”
- python - 在 localhost 上看不到我正在运行的 Docker 容器
- spring-boot - Java Redis Spring boot Jackson-java.lang.ClassCastException:类 java.util.LinkedHashMap 无法转换为 MyClass
- c++ - 将所有 c++ 类代码放在头文件中是个好主意吗?