Mohd osama
Mohd osama

Reputation: 81

why is my discord.py command not working or sending messages

I have this edit snipe command and event in which if a user edits a messages it snipes it. The event works fine and sends the edited messages into a private logs admin channel. However, when I try to make this into a command and it send an embed into the given command channel the message and command does not work at all


    @commands.command()
    async def es(self,message_before, message_after):
        embed=discord.Embed(description=f"📝**Message sent by** {author} **edited in** {channel}")
        embed.set_author(name= f" ‎‏‏‎ ‎‏‏‎ ‎‏‏‎ ‎‏‏‎ ‎‏‏‎ ‎‏‏‎ ‎‏‏‎ ‎‏‏‎ ‎‏‏‎ ‎‏‏‎ {message_before.author.name}#{message_before.author.discriminator}")
        embed.add_field(name="Old message", value=message_before.content, inline=False)
        embed.add_field(name="New message", value=message_after.content, inline=False)
        await message_before.channel.send(embed=embed)
        return

Upvotes: 0

Views: 172

Answers (1)

Shunya
Shunya

Reputation: 2459

You are confusing command and event.

In the previous answer by @Cohen in your other post, he told you to use the on_message_edit event. This event (and many others) are already defined by the discord.py library, hence they already provide the input parameters.

If you want to send an embed each time an user edits a message, do not do it in a separate function, add your code to the piece of code in on_message_edit. If, on another hand, you want to be able to call a command ("!es") for example, who will retrieve the last edited message, you will need to create a database and keep a log of the edited messages (a single table with a old_message and new_message columns).

You can use DB Browser for SQLite to create and manually check your database, and I suggest using an asynchronous library such as aiosqlite which works well with discord.py

Upvotes: 1

Related Questions