Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to remove the embed from specific messages and from messages coming from specific users/bots using Discord.js

I'm trying to code a bot that is able to remove the embed of specific messages or the embed created from the links posted by specific users and bots present in the server.

For example, let's say I don't want to see the twitter embed when someone posts a tweet: my bot would automatically remove the twitter embed.

Other case, I don't want people to see the embed of the messages posted by another user or bot present in the server, my bot would then automatically remove the said embeds.

However, reading the API documentation, I didn't see any possibility to do so. Maybe I missed it or maybe there's a trick to do so. Or maybe it's not supported by the API yet.

So does anyone know how I could achieve that goal please?

PS: Yes, I know I could simply deactivate embeds in the server settings, but that's not the goal I want to achieve here. I want it to be specific to certains links/messages and users/bots.

Thanks

like image 994
VDS-Atomic Avatar asked Oct 31 '25 10:10

VDS-Atomic


1 Answers

You can use the suppressEmbeds method of message.


client.on("message", message => {
    if (message.author.bot) return false;

    if (message.author.id !== "YourID") { // Example Condition
        message.suppressEmbeds(true) // Removes all embeds from the message.
    }
})
like image 170
Jakye Avatar answered Nov 03 '25 11:11

Jakye