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
    }
  }
}

Answers:

Answer

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.

Tags

Recent Questions

Top Questions

Home Tags Terms of Service Privacy Policy DMCA Contact Us

©2020 All rights reserved.