简体   繁体   中英

Discord.JS Add a button to a message

I want to add another button to an existing message (send by the bot) I tried:

// const... log in... ....
let msg = await interaction.channel.fetchMessage(interaction.options.get('message-id'))
if(!msg || msg?.author?.id !== client.user.id) return interaction.reply({ content: "Error..." })

msg.edit({ embeds: ["a defined embed"], components: [row] })

When I edit the components, it replaces the first one with the new one.

How can I add a new button to the message?

Don't edit the whole message. Just do message.edit({components: [row]})

It should just add the button without editing the message

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM