Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/276.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在Python中编程一个Discord bot-in_raw_reaction_add中,如何判断消息是否有图像?_Python_Discord.py - Fatal编程技术网

在Python中编程一个Discord bot-in_raw_reaction_add中,如何判断消息是否有图像?

在Python中编程一个Discord bot-in_raw_reaction_add中,如何判断消息是否有图像?,python,discord.py,Python,Discord.py,我想让机器人知道一条消息什么时候有反应,以及该消息是否有图像。这是我的密码: @client.event async def on_raw_reaction_add(payload): if payload.message.attatchments[0] != None: print("True") 触发时,希望它打印“True”,但我只得到以下错误:AttributeError:'RawReactionActionEvent'对象没有属性“message”。我

我想让机器人知道一条消息什么时候有反应,以及该消息是否有图像。这是我的密码:

@client.event
async def on_raw_reaction_add(payload):
  if payload.message.attatchments[0] != None:
    print("True")
触发时,希望它打印“True”,但我只得到以下错误:
AttributeError:'RawReactionActionEvent'对象没有属性“message”
。我不知道为什么会这样,有什么建议吗

编辑: 这是我试过的另一件事

@client.event
async def on_raw_reaction_add(payload):
  message = await channel.fetch_message(payload.message_id)
  if message.attatchments[0] != None:
        print("True")

它使用id获取消息,然后检查图像。不幸的是,我遇到了一个错误:
AttributeError:“Message”对象没有属性“attachments”

这个问题与


根据那里的答案,您要查找的属性是
message\u id

好的,那么我如何使用它来检查图像附件?尝试payload.message\u id.attachments,但我不确定是的,这也不起作用-我用另一个我尝试过的东西更新了问题