所以我有一个名为 p!profile
的命令,它发送用户的个人资料。我希望有人执行命令 p!profile @someone
我的机器人会发送此人的个人资料。
我不是世界上最好的编码员,抱歉。另外,感谢过去帮助过我的人<3
@client.command
async def profile(ctx, mention):
if ctx.mention == ctx.author:
#code
else:
#code
答案 0 :(得分:1)
您可以使用 discord.Member
代替 mention
作为 arg
。如果执行您的 None
命令的人没有提及任何人,您可以最初将其定义为 p!profile
。
@client.command()
async def profile(ctx, user:discord.Member=None):
if user == None or user == ctx.author:
user = ctx.author # converts user to ctx.author if user is None or the person mentioned themselves
else:
# other code here