Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Discord.js embed image spoiler

I have a bot that sends embeds. Sometimes I send embeds with a picture, but I want to put a spoiler over it. Is that possible? The problem is that I get the image from a link, so I can't rename it to 'SPOILER_'. Downloading the image and renaming it would be very troublesome, there must be another way. This is how the code I insert the image with:

{
  "embed": {
    "image": {
      "url": url
    }
  }
}
like image 789
Christian Proschek Avatar asked Nov 16 '25 11:11

Christian Proschek


1 Answers

Unfortunately, this is not possible via renaming the image file with SPOILER_

Taken from the docs, with TextChannel.send() you're able to fetch an image, rename it and then send it in an embed, like so:

channel.send({
  embed: {
    image: {
         url: "attachment://SPOILER_FILE.jpg"
      }
   },
   files: [{
      attachment: "https://cdn.pixabay.com/photo/2018/04/05/18/28/cute-3293750_960_720.jpg",
      name: "SPOILER_FILE.jpg"
   }]
});

But if you test this out, the image will still be visible. Test Spoiler Image on Embed

However, if you remove the embed part of the message, it works:

channel.send({
   files: [{
      attachment: "https://cdn.pixabay.com/photo/2018/04/05/18/28/cute-3293750_960_720.jpg",
      name: "SPOILER_FILE.jpg"
   }]
});

Test Spoiler Image on Normal Message


So what now?

Give them feedback: upvote and comment on this suggestion and other places to let them know, and hopefully they'll add it soon.

like image 57
luxmiyu Avatar answered Nov 18 '25 23:11

luxmiyu



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!