首页 > 解决方案 > 我如何让机器人只通过输入不带标签的用户名来提及某人

问题描述

例如:

我:-提到LOL

机器人:@LOL

标签: pythondiscord.py

解决方案


您可以将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

这是它的样子:

在此处输入图像描述


推荐阅读