#on_raw_message_edit and on_raw_message_delete cached_message issues

1 messages · Page 1 of 1 (latest)

sage ferry
#

on_raw_message_edit's cached_message becomes None on the second edit of a message, and the on_raw_message_delete's cached_message becomes None after any edit to the message

#
@commands.Cog.listener()
    async def on_raw_message_delete(self, payload:RawMessageDeleteEvent):
        await self.bot.get_guild(826685546772168734).get_channel(1193792402914283560).send(f"Message deleted in Allowlist sent by user: {payload.cached_message.author.mention}, content: {payload.cached_message.content}")
    
    @commands.Cog.listener()
    async def on_raw_message_edit(self, payload:RawMessageUpdateEvent):
        if payload.cached_message != None:
            await self.bot.get_guild(826685546772168734).get_channel(1193792402914283560).send(f"Message edited in Allowlist, sent by <@{payload.data['author']['id']}>, Edited to: {payload.data['content']} from {payload.cached_message.content}")
#

If this sequence of events happen

test > test 1 > test 2

then the payload.cached_message in the on_raw_message_edit becomes None causing Attribute errors

#

If this occurs instead

test > test 2 > message gets deleted

then the payload.cached_message in the on_raw_message_delete becomes None also resulting in Attribute errors

#

Using the regular on_message_delete and on_message_edit result in no errors but the functions do not fire in the above cases