#What does on_message_delete return if the message has no content or is an embed?

1 messages · Page 1 of 1 (latest)

snow holly
#
 @listen()
    async def on_message_delete(self, event: events.MessageDelete):
        print(event.message.content, type(event.message.content))
        if event.message.content:
            pass 
        else:
            return     

        embed = Embed("Message Deleted")
        embed.add_field("User Id", event.message.author.id)
        embed.add_field("Message Content", event.message.content)
        embed.add_field("Resolved Name", event.resolved_name)

        guild = await self.client.fetch_guild(864557936068395018)
        channel = await guild.fetch_channel(self.messageChannelId)
        
        await channel.send(embeds=embed)
glad helmBOT
#

Hey! Once your issue is solved, press the button below to close this thread!

snow holly
#
Ignoring exception in MessageDelete():
Traceback (most recent call last):
  File "/config/.local/lib/python3.10/site-packages/interactions/client/client.py", line 597, in _async_wrap
    await _coro(_event, *_args, **_kwargs)
  File "/config/.local/lib/python3.10/site-packages/interactions/models/internal/callback.py", line 31, in __call__
    return await self.callback(self._binding, *args, **kwargs)
  File "/config/workspace/discord-flask/bot/automated/onMessage.py", line 10, in on_message_delete
    print(event.message.content, type(event.message.content))
AttributeError: 'BaseMessage' object has no attribute 'content'
remote oxide
#

Its event.ctx.message.content

slow holly
#

it' well event.message.content, however depending on the type of message maybe it is not one with content

#

if you look at that, it shows if the message can be deleted or not, maybe use it?

#

although it seems really weird that you have a BaseMessage and not a Message object, maybe try to find out where it comes from

round wharf
#

if you get BaseMessage, the deleted message was most likely not in your cache

#

this is excessively common because of the fact that messages are stored in an expiring dict, and because messages from before the bot can start caching (on bootup) can be deleted

round wharf
snow holly
#

Used a try except, thank you for your help!