1
votes

After noticing that deviantArt embeds on discord were really bad, I decided to make a feature in my bot that would detect a deviantart url with an event and send a better embed that worked.

If there is several urls in the message, it detects DeviantArt ones and sends embeds of them (bot).

My issue is that sometimes, in the same message (user), some DA urls embed show and some don't. So I want to delete only Deviantart embeds to keep ArtStation ones.

But the only thing I found on Discord js is message.suppressEmbeds(true)which delete all embeds of a message.

I tried using message.edit() but it is unauthorised for non-authors of the message.

I also tried looping through all embeds and storing in an array all urls not being DeviantArt. So i could re-send them after running message.suppressEmbeds(true) but the re-sent version looks somehow different. And I still can't figure out why

var messageEmbed = [];
var index = 0;
for(var embed of msg.embeds){
     
  if(!embed.url.includes("www.deviantart.com")){ 
      messageEmbed[index]  = new Discord.MessageEmbed(embed);
      //also tried with
      //messageEmbed[index]  = embed; it does the same thing
      index++;
  } 
}

Image of what it looks like

I need either:

  • to find a way do delete specific embed of a message (user).
  • to find a way to display properly the stored embed.
1

1 Answers

0
votes

It is not possible to suppress single embeds.

But you can save all embeds:

const embeds = message.embeds;

Then suppress the embeds:

message.suppressEmbeds(true);

And send every embed again, checking if you want to replace them.

for (let embed of embeds) {

 let modifiedEmbed = new Discord.MessageEmbed(embed);

 if (embed.url === "deviantArtURL") {

  // Modify the embed embed

 }

 message.channel.send(embed);

}

Unfortunately there's no other way.