0
votes

I have an annoying problem with my discord bot. My bot's name is R3NAUT and it is a single server moderation bot programmed in python 3.9.2 and discord.py 1.6.0.

The problem is, that when the bot is logging a message deletion, it is logging a message deleted by the bot even I've forbidden it. Here is the code:

@Cog.listener()
async def on_message_delete(self, message):
    if not message.author.bot:
        embed = Embed(title="Message deletion",
                    description=f"Deleted by {message.author.display_name} in {message.channel}.",
                    colour=0xff6f00,
                    timestamp=datetime.utcnow())

        fields = [("Content", message.content, False)]

        embed.set_thumbnail(url="https://cdn.discordapp.com/attachments/629382706299666432/837723544863244338/unnamed_3.png")

        for name, value, inline in fields:
            embed.add_field(name=name, value=value, inline=inline)

        await self.logs_channel.send(embed=embed)

This problem is occurring, when someone types help command and the bot is programmed to delete the help command after 60 seconds. The weird thing is, that in log, there is written that the member deleted the message not the bot. Image how the logged embed looks. If you want full code it is here https://github.com/Guard-SK/R3NAUT/ Thanks for reply.

Guard_SK

1
You have to add a condition. Add: if message.author == client.user: return. client here is the bot variable.Bhavyadeep Yadav
Where exactly it it showing a bot's message that was deleted?, In the image you provided, it is only showing that your message has been deleted, not a bot'sCeres

1 Answers

0
votes

if not message.author.bot: checks if the message author is a bot, not if the message was deleted by a bot. So with this code, the only messages that will be skipped will be messages that were sent by the bot

As I am aware the only way to skip messages that bot deletes would be to fetch them from audit log, you can read on audit log below: