How do I convert an Attachment into a RawFile

For a modmail, I want to send the user's attachments into a channel and I'm not sure how to
8 Replies
d.js toolkit
d.js toolkit2mo ago
- What's your exact discord.js npm list discord.js and node node -v version? - Not a discord.js issue? Check out #other-js-ts. - Consider reading #how-to-get-help to improve your question! - Explain what exactly your issue is. - Post the full error stack trace, not just the top part! - Show your code! - Issue solved? Press the button! - Marked as resolved by OP
d.js docs
d.js docs2mo ago
Files in embeds should be attached via the message option object and referenced in the embed:
const attachment = new AttachmentBuilder('./image.png', { name: 'image1.png' });
const embed = new EmbedBuilder()
.setTitle('Attachments')
.setImage(`attachment://${attachment.name}`);

channel.send({
embeds: [embed],
files: [attachment]
});
const attachment = new AttachmentBuilder('./image.png', { name: 'image1.png' });
const embed = new EmbedBuilder()
.setTitle('Attachments')
.setImage(`attachment://${attachment.name}`);

channel.send({
embeds: [embed],
files: [attachment]
});
Sasial
SasialOP2mo ago
^ doesn't help
TÆMBØ
TÆMBØ2mo ago
What is "user's attachments"? Are you referring to attachment options on a slash command? If so, using <Interaction>.options.getAttachment() will return the attachment for that option (if specified), which you can simply pass to the files option when sending the message
Sasial
SasialOP2mo ago
attachments from a Message
Unknown User
Unknown User2mo ago
Message Not Public
Sign In & Join Server To View
TÆMBØ
TÆMBØ2mo ago
files: [...message.attachments.values()]
Sasial
SasialOP2mo ago
ty! was wondering why files: message.attachments.values() didn't work forgot it needed to be in an array

Did you find this page helpful?