Rtxxz
Rtxxz

Reputation: 1

discord.py on_message_delete get message content

I'm attempting to make a log of when a user's message is deleted, but I'm unable to see the actual message's contents when sending it to a channel:

@bot.event
async def on_message_delete(message):
    embed1 = discord.Embed(title="Deleted Message!")
    embed1.add_field(name=f"**Msg Was Deleted**", value=f"Someone Has Deleted The Following:\n`{message}`", inline=True)
    embed1.colour = (0x90EE90)
    dele = bot.get_channel(722832289955971183)
    await dele.send(embed=embed1)

Upvotes: 0

Views: 3954

Answers (1)

Diggy.
Diggy.

Reputation: 6944

The "junk" it's spitting out is the message object. This object has many attributes you can access - see the discord.Message object in the references.

To get the message's contents, you can use the content attribute of a message like so:

@bot.event
async def on_message_delete(message):
    # Code
    embed.add_field(name="..", value=f"Someone has deleted the following:\n{message.content}")
    # Rest of the code

References:

Upvotes: 1

Related Questions