Python 如何让机器人显示用户';如果其他用户ping该用户discord.py,则返回s info

Python 如何让机器人显示用户';如果其他用户ping该用户discord.py,则返回s info,python,discord,discord.py,Python,Discord,Discord.py,我试图让我的机器人显示一个用户信息,如果用户类型的配置文件?[其他用户的名称]” 如果message.content==“profile?”+user.note: x=显示玩家微笑(str(用户提及)) y=显示\玩家\皱眉(str(user.notice)) embedVar=discord.Embed(title=str(user.notice),description=“这是他们的个人资料”,color=0x0210ff) embedVar.add_字段(name=“Smiles”,val

我试图让我的机器人显示一个用户信息,如果用户类型的配置文件?[其他用户的名称]”

如果message.content==“profile?”+user.note:
x=显示玩家微笑(str(用户提及))
y=显示\玩家\皱眉(str(user.notice))
embedVar=discord.Embed(title=str(user.notice),description=“这是他们的个人资料”,color=0x0210ff)
embedVar.add_字段(name=“Smiles”,value=str(x),inline=False)
embedVar.add_字段(name=“皱眉”,value=str(y),inline=False)
wait message.channel.send(嵌入=embedVar)

我试图使用user.notice,但它给了我一个错误。

如果您没有理由使用命令,我会给您举个例子

@bot.command()#或'client.command()`-取决于如何命名bot实例
异步def配置文件(ctx,用户:discord.Member):
x=显示\u玩家\u微笑(用户提及)
y=显示\u玩家\u皱眉(用户提及)
embedVar=discord.Embed(title=user.notice,description=“这是他们的个人资料”,color=0x0210ff)
embedVar.add_字段(name=“Smiles”,value=str(x),inline=False)
embedVar.add_字段(name=“皱眉”,value=str(y),inline=False)
等待ctx.send(嵌入=embedVar)
有几件事值得一提:

  • 您需要启用
    intents.members
  • 在需要添加的
    on_消息的
    事件末尾
wait bot.process\u命令(消息)或'client.process..`-取决于您如何命名它
  • 记住使用
    命令。Bot
    ,而不是
    discord。Client
    ,还记得只使用一个命令,而不是同时使用两个命令
看看这本书,希望它能为你澄清一些事情


这里是关于如何启用意图和特权意图的另一个有用链接,

您使用消息上的
事件而不是命令有什么原因吗?这对你来说会容易得多没有理由,我也不介意用命令来代替。我只是不知道如何使用这些命令。每当我尝试运行代码时,我总是在on_消息中忽略异常。错误是什么?此外,您还应该删除
on_message
事件中的
profile
命令,因为它是一条命令。什么是eo?是的,我删除了我以前的profile命令,这是我现在唯一的一个,但我仍然得到相同的错误。对不起,错误*,misstype
Traceback(最近一次调用):文件“C:\Users\Gabe K\AppData\Local\Programs\Python\Python 38-32\lib\site packages\discord\client.py”,第312行,在运行事件等待coro(*args,**kwargs)文件中“x-wingide-python-shell://114675904/2“,on_消息名称中的第162行错误:未定义名称‘bot’,忽略on_消息中的异常