'set image with canvas inside an embed

The message is edited correctly if I add text, title... but don't add the image in .setImage(), it doesn't bring the image. Any idea?

      const img = new Discord.MessageAttachment(canvas.toBuffer(), 'img.png');
      const embed = new Discord.MessageEmbed()
        .setColor('RANDOM')
        .setImage('attachment://img.png')

  client.channels.cache.get("channel id").messages.fetch("msg id")
  .then(msgg => msgg.edit({embeds: [embed]}))

I have created the image with canvas previously, if I insert the image outside the embed, it works correctly



Solution 1:[1]

When you edit the message you need to pass along the file.

msgg.edit({ embeds: [embed], files: [img]})

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 Matthew Vine