Search code examples
discord.jscanvasjs

How can I put a canvas attachment into an embed?


My current code wont work, dont really know how to attach the file

            const attachment = new MessageAttachment(canvas.toBuffer());

            let embed = new MessageEmbed()
                .setTitle(`Hello`)
                .setDescription(Welcome!`)
                .setImage(attachment)
                .setColor(embedColor)

            message.channel.send({ embeds: [embed] })

Solution

  • from the porting guide to v13, as you have the newer syntax for embeds listed, this implies this is your version...

    channel.send({ embeds: [embed], files: ['./image1.png', './image2.jpg'] });
    

    https://discordjs.guide/additional-info/changes-in-v13.html#sending-messages-embeds-files-etc