Eduardo
Eduardo

Reputation: 1831

Send message including button

I am using Discord.js v13.2. I need to send a message once ready. I am able to send a text message, but the button does not appear, so I guess I am not sending the parameter correctly.

client.once("ready", async () => {
  const button = new MessageButton()
    .setLabel("Go To Site")
    .setStyle("blue")
    .setCustomId("btn-go-to-site");

  const helpChannel = await client.channels.fetch(channelID);
  helpChannel.send('Welcome to Site', button);
});

Upvotes: 0

Views: 499

Answers (1)

MrMythical
MrMythical

Reputation: 9041

Discord.js v13 now only accepts 1 parameter in message sending, editing and replying. You must send the message with the content and components parameters.

helpChannel.send({
  content: "Welcome to Site",
  components: [
    new MessageActionRow().addComponents([button])
  ]
})

This must also be done with embeds, files, stickers and other message options

Upvotes: 1

Related Questions