Update message with images using discord.js REST

I'm trying to add images to a message using discord.js/REST V10, but without success My code:
const rest = new REST({ version: "10" }).setToken(
process.env.token
);

await rest.patch(
Routes.webhookMessage(
message.application_id,
message.token,
message.id
),
{
body, // body with other message options, like embeds
files, // array of RawFiles
}
const rest = new REST({ version: "10" }).setToken(
process.env.token
);

await rest.patch(
Routes.webhookMessage(
message.application_id,
message.token,
message.id
),
{
body, // body with other message options, like embeds
files, // array of RawFiles
}
I'm can patch the webhook message to change embeds, components and other stuff. But I still can't add files like images to it Maybe I'm doing it wrong?
8 Replies
d.js toolkit
d.js toolkit2y ago
• What's your exact discord.js npm list discord.js and node node -v version? • Post the full error stack trace, not just the top part! • Show your code! • Explain what exactly your issue is. • Not a discord.js issue? Check out #useful-servers.
Marcus Natrielli
Marcus NatrielliOP2y ago
I forgot to mention that the image "appears", but buggy
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Marcus Natrielli
Marcus NatrielliOP2y ago
I want to send an image. I'm using files because it was what I found in rest.patch options
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Marcus Natrielli
Marcus NatrielliOP2y ago
A canvas is still a kind of image. So this don't exactly solve my problem
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Marcus Natrielli
Marcus NatrielliOP2y ago
The source of the file that I'm trying to send is a image. That's why, if I understood right, It won't work using canvas What I'm trying to achieve is: I have a PNG that I want to send using discord.js/REST. So I want to know how to do it, because I know, reading Discord API, that it's possible. I just don't know how to do it with this subpackage, because when I try to do it, it return a buggy attachment The main reason is just legacy code... I started to work with this project not long ago I didn't know about webhookclient. Going to check and probably use it instead Guys. Thanks for the help! Problem solved
Want results from more Discord servers?
Add your server