Lastest version of canvas, discord.js and node.js.
Here is the code:
const attachment = new AttachmentBuilder(canvas.toBuffer("image/png"), {
name: "DNI.png",
});
await interaction.reply({ files: [attachment] })
},
The console/terminal says: "AttachmentBuilder is not a constructor" when I use the / command.
2
Answers
It looks like your forgot to import AttachmentBuilder frmom discord.js.
Your attachment may already be an array, so there is no need to array it like embed.
So your code should be
await interaction.reply({ files: attachment })
not
await interaction.reply({ files: [attachment] })