【发布时间】:2021-07-03 02:51:47
【问题描述】:
@commands.Cog.listener()
async def on_raw_message_delete(self, payload):
try:
conn.reconnect()
except:
pass
print("deleted")
channel=self.client.get_channel(payload.channel_id)
message=await channel.fetch_message(payload.message_id) #<===========
emb=message.embeds
for mes in emb:
cursor.execute(f"DELETE FROM suggestions WHERE channel_id={payload.channel_id} and id={payload.guild_id} and code={mes.fields[1].value}")
conn.commit()
discord.errors.NotFound: 404 Not Found (error code:10008): Unknown message
当我将代码更改为此时,它显示了另一个错误
@commands.Cog.listener()
async def on_raw_message_delete(self, payload):
try:
conn.reconnect()
except:
pass
print("deleted")
channel=self.client.get_channel(payload.channel_id)
message=payload.cached_message
emb=message.embeds #<===========
for mes in emb:
cursor.execute(f"DELETE FROM suggestions WHERE channel_id={payload.channel_id} and id={payload.guild_id} and code={mes.fields[1].value}")
conn.commit()
AttributeError: 'NoneType' 对象没有属性 'embeds'
如何从嵌入中获取内容?
【问题讨论】:
-
我认为错误不言自明,您无法获取不存在的消息
-
以及如何从不存在的消息(嵌入)中获取内容?
-
如果我之前的评论不够明显,你不能。除非它被机器人缓存
标签: python discord.py embed message