I can't send a button with my embed on discord.js v13, the bot only send the embed and not the button. I got an error "Invalid from body" but i don't know what i have to do?
Here is my code :
const embedopen = new Discord.MessageEmbed()
.setDescription(`Bonjour ${button.user.tag}, bienvenue dans votre ticket. Un <@&799060000122994698> ou l'<@&799049340538191892> va s'occuper de vous.`)
.setTimestamp()
const row = new Discord.MessageActionRow()
.addComponents(
new Discord.MessageButton()
.setLabel("Fermer le ticket")
.setCustomId("close_ticket")
.setEmoji('❌')
.setStyle("red")
)
channel.send({embeds: [embedopen], components: [row]})
And here is the error :
04:55:06 -> [ERR] -> DiscordAPIError: Invalid Form Body
components[0].components[0].style: This field is required
at RequestHandler.execute (h:\Users\Zarcross\Desktop\SiteComplet\node_modules\discord.js\src\rest\RequestHandler.js:298:13)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async RequestHandler.push (h:\Users\Zarcross\Desktop\SiteComplet\node_modules\discord.js\src\rest\RequestHandler.js:50:14)
at async TextChannel.send (h:\Users\Zarcross\Desktop\SiteComplet\node_modules\discord.js\src\structures\interfaces\TextBasedChannel.js:172:15) {
method: 'post',
path: '/channels/902752250697515048/messages',
code: 50035,
httpStatus: 400,
requestData: {
json: {
content: undefined,
tts: false,
nonce: undefined,
embeds: [Array],
components: [Array],
username: undefined,
avatar_url: undefined,
allowed_mentions: undefined,
flags: undefined,
message_reference: undefined,
attachments: undefined,
sticker_ids: undefined
},
files: []
}
}
CodePudding user response:
If you want a red button, change .setStyle("red")
to .setStyle("DANGER")
You got the error because "red" is not a valid button style.
There are currently five different button styles:
PRIMARY
- a blurple button
SECONDARY
- a grey button
SUCCESS
- a green button
DANGER
- a red button
LINK
- a button that navigates to a URL.