python - 如何使用 Python 中的机器人在 Discord 中发送某人的姓名
问题描述
我正在编写我的 Python Discord 机器人,在询问时,
Warn <@anyone>
应将 DM 发送到@anyone
Discord 中。
到现在为止,我写过,
if message.content.startswith('Warn '):
现在我想将整个消息转换为字符串格式,然后从中删除“警告”。@anyone
这样我就很容易得名了。但我无法做到这一点。此外,我不知道是否可以转换为字符串。
有人能回答我的问题吗?感谢您阅读我的问题。
解决方案
通过@user来获得使用,这就是我的做法
@client.command() #to start the command
async def warn(ctx, member : discord.member): #name and import ctx / other things too
await ctx.send(f"{member.mention}")
如果我做错了,请告诉我它有点
推荐阅读
- machine-learning - 计算训练误差和交叉验证误差时的模型训练
- java - 将一段 ByteBuffer 代码从 Java 转换为 C#
- node.js - 使用 MongoDB 缓慢 .findByIdAndUpdate().lean()
- reactjs - 如何识别 React JS 中的输入和输出元素?
- mysql - 记录用户所学单词的 Web 应用程序
- javascript - TypeError:null 不是对象(评估 ''this.state.torchon')
- python - 如何使用 matplotlib 添加动画图例
- android - 如何以编程方式在 RelativeLayout 内的两个布局之间添加 CustomLayout?
- javascript - 为什么 React.memo 不能与 useEffect 一起使用?
- google-cloud-dataproc - Dataproc 是否有每个作业的资源分配限制