python - 我如何让机器人只通过输入不带标签的用户名来提及某人
问题描述
例如:
我:-提到LOL
机器人:@LOL
解决方案
您可以将member: discord.Member
其用作必需的参数。
如果你想提及一个用户,你必须使用member.mention
.
这是一个示例代码:
@client.command() # Or whatever you use
async def mention(ctx, member: discord.Member = None):
if member == None: # If no argument was passed
await ctx.send(ctx.author.mention) # Mention the author of the command
else:
await ctx.send(member.mention) # Mention the member
这是它的样子:
推荐阅读
- python - 试图在我的 Django 应用程序上创建第二个 forms.py 以在同一页面上发布
- c++ - 结构和指针问题
- python - 为什么我无法在某些网站上执行请求获取方法
- php - 如何在另一个 hasMany 关系中访问 hasMany
- r - 拜托,有人知道为什么我不能在 R 的向量中保存数据吗?
- c# - 如何为每个异步操作创建一个新上下文并以线程安全的方式使用它来存储一些数据
- matrix - 减去 SSRS 中矩阵表中的组列
- java - 将模拟推送到远程 Wiremock 服务器失败并出现“JSON Parsing”错误
- javascript - 导入节点模块时出现 ImportError
- python - 如何从 arcgis 10.2 发行版在 python 2.7 解释器上安装 psycopg2