'Removing an embed from a message in Discord.py

I'm trying to figure out how to remove an embed from a message my Discord bot sends. As a joke, I made a bot to "censor" certain links, but so it's not mean, the bot reposts the link itself. Assuming any message from the bot has only one link in it, how do I either prevent the link embed from occurring, or have the bot delete the embed immediately?

Not a duplicate of this question because I do not know what the link will be, so I can't just find a certain substring and put angle brackets around it.

My code is as follows:

if any(substring in message.content.lower() for substring in ["www.example.com", "www.wikipedia.com"]):
    msg = await message.channel.send(f"{message.author.mention} is out of line!"
                                     f"\n> {message.content}\nThis misdeed has been noted, "
                                     "and future transgressions will result in severe penalties.")
    # remove embeds here?
    await message.delete()

(In addition, if there's a better way to do the if statement, let me know.)



Solution 1:[1]

Explanation

This can be accomplished by setting the SUPPRESS_EMBEDS flag to True, if your bot has MANAGE_MESSAGE permissions. In discord.py, this would be in the Message.edit method, where you set the suppress argument to True.

Code

if any(substring in message.content.lower() for substring in ["www.example.com", "www.wikipedia.com"]):
    msg = await message.channel.send(f"{message.author.mention} is out of line!"
                                     f"\n> {message.content}\nThis misdeed has been noted, "
                                     "and future transgressions will result in severe penalties.")
    # remove embeds here!
    await message.edit(suppress=True)

Reference

Message Flags

discord.Message.edit

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 TheFungusAmongUs