0
votes

I've been working on a discord bot and I was able to create the snipe command that, well snipes the recent deleted message but now I'm trying to program it to be able to edit snipe which is to snipe the recently edited message

Here is my snipe deleted messages code

    async def on_ready(self):
        print('Snipe commands are working')


    @commands.Cog.listener()
    async def on_message_delete(self, message):

        global snipe_message_content
        global snipe_message_author
        global snipe_message_id
        global snipe_message_channel
        global snipe_message_author_avatar
        global a
        global b

        snipe_message_content = message.content
        snipe_message_author = message.author.id
        snipe_message_id = message.id
        snipe_message_channel = message.channel
        snipe_message_author_avatar = message.author.avatar_url
        a = message.author.name
        b = message.author.discriminator
        
        if (snipe_message_author in botsid):
            m == 1
        else:
            embed = discord.Embed(description=f"????️ **Message sent by** <@!{snipe_message_author}> **deleted in** {message.channel.mention} \n  \n {snipe_message_content}")
            embed.set_author(name= f"‎‎‏‏‎ ‎‏‏‎ ‎‏‏‎ ‎‏‏‎ ‎‏‏‎ ‎‏‏‎ ‎‏‏‎ ‎‏‏‎ ‎‏‏‎ ‎‏‏‎ ‎‏‏‎ ‎{message.author.name}#{message.author.discriminator}")
            channel = self.client.get_channel(795726497922809947)
            await channel.send(embed=embed)
1
you need to use the on_message_edit event.Abdul Aziz Barkat

1 Answers

1
votes

You can simply achieve this by using on_message_edit and using message_before prior to editing the message. Below is an example

async def on_message_edit(message_before, message_after):
      
        author = message_before.author
        guild = message_before.guild.name
        channel = message_before.channel


        await channel.send(f"""
   
        Original Message
        {message_before.content}

        Updated Message
        {message_after.content}""")


From this, you can just copy what you have done above.