Why are my embeds not sent but Files are?

I'm using this payload in a raw rest.post() request and the files are being sent, but not the embeds. Why? I have based the code on the original code from djs.
payload = {
body: {
payload_json: {
embeds: [
{
// ...
},
],
},
},
files: files, // That goes through
} as RESTPostAPIChannelMessageFormDataBody;

...

await ctx.client.rest.post(
Routes.channelMessages(postId),
payload
)
payload = {
body: {
payload_json: {
embeds: [
{
// ...
},
],
},
},
files: files, // That goes through
} as RESTPostAPIChannelMessageFormDataBody;

...

await ctx.client.rest.post(
Routes.channelMessages(postId),
payload
)
No description
13 Replies
d.js toolkit
d.js toolkit3mo 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!
monbrey
monbrey3mo ago
payload_json is not a valid property of the body? Where did yoiu get that from
LukeZ
LukeZOP3mo ago
discord docs + djs code gimme a second
monbrey
monbrey3mo ago
doubt Yeah
LukeZ
LukeZOP3mo ago
No description
monbrey
monbrey3mo ago
huh, thats odd Ive always just passed it directly as body
LukeZ
LukeZOP3mo ago
like
let sendOptions = { payload_json: {}, files: files }
let sendOptions = { payload_json: {}, files: files }
monbrey
monbrey3mo ago
ahh right
LukeZ
LukeZOP3mo ago
okay, lemme try it I do Wait what :Thinkeng: I give it a try nope, still doesn't work Because I don't have the channel and don#t want to fetch it I'm using raw rest Because it might not be cached -# but that's not the point here
sendOptions = {
payload_json: JSON.stringify({
embeds: [
{
author: {
name: "...",
url: `...`,
},
description: "...",
thumbnail: !ticket.alias
? { url: ctx.user.avatarURL() }
: undefined,
color: 0x<somecolorcode>,
},
],
}),
files: files,
} as RESTPostAPIChannelMessageFormDataBody;
sendOptions = {
payload_json: JSON.stringify({
embeds: [
{
author: {
name: "...",
url: `...`,
},
description: "...",
thumbnail: !ticket.alias
? { url: ctx.user.avatarURL() }
: undefined,
color: 0x<somecolorcode>,
},
],
}),
files: files,
} as RESTPostAPIChannelMessageFormDataBody;
d.js docs
d.js docs3mo ago
:class: MessagePayload @14.16.3 Represents a message to be sent to the API.
LukeZ
LukeZOP3mo ago
I wanted to use this, but I would still need the channel tho I tried using it but the target needs to be set - I might not have it in the cache
LukeZ
LukeZOP3mo ago
uuuh
No description
LukeZ
LukeZOP3mo ago
[x] doubt I might just use the interaction.user and resolve the body there it's not sent to the user but it might work since I just need the body noted

Did you find this page helpful?