#button #discord.js #embed
Вопрос:
Я не могу отправить кнопку с включенной вставкой discord.js v13, бот отправляет только вставку, а не кнопку. Я получил ошибку «Неверно от тела», но я не знаю, что мне делать?
Вот мой код :
const embedopen = new Discord.MessageEmbed() .setDescription(`Bonjour ${button.user.tag}, bienvenue dans votre ticket. Un lt;@amp;799060000122994698gt; ou l'lt;@amp;799049340538191892gt; 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]})
И вот в чем ошибка :
04:55:06 -gt; [ERR] -gt; DiscordAPIError: Invalid Form Body components[0].components[0].style: This field is required at RequestHandler.execute (h:UsersZarcrossDesktopSiteCompletnode_modulesdiscord.jssrcrestRequestHandler.js:298:13) at processTicksAndRejections (node:internal/process/task_queues:96:5) at async RequestHandler.push (h:UsersZarcrossDesktopSiteCompletnode_modulesdiscord.jssrcrestRequestHandler.js:50:14) at async TextChannel.send (h:UsersZarcrossDesktopSiteCompletnode_modulesdiscord.jssrcstructuresinterfacesTextBasedChannel.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: [] } }
Ответ №1:
Если вам нужна красная кнопка, перейдите .setStyle("red")
на .setStyle("DANGER")
Вы получили ошибку, потому что «красный» не является допустимым стилем кнопки.
В настоящее время существует пять различных стилей кнопок:
PRIMARY
— кнопка размытия
SECONDARY
— серая кнопка
SUCCESS
— зеленая кнопка
DANGER
— красная кнопка
LINK
— кнопка, которая переходит по URL-адресу.
Комментарии:
1. Теперь это работает на меня ! Я забыл об этом изменении в v13