【问题标题】:Send message including button发送消息,包括按钮
【发布时间】:2021-12-09 12:27:39
【问题描述】:

我正在使用 Discord.js v13.2。准备好后,我需要发送消息。我可以发送短信,但没有出现按钮,所以我想我没有正确发送参数。

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);
});

【问题讨论】:

  • 你使用的是什么版本的 discord.js?
  • @MrMythical 我正在使用:“discord.js”:“^13.2.0”

标签: javascript discord discord.js


【解决方案1】:

Discord.js v13 现在只接受消息sendingeditingreplying 中的1 个参数。您必须使用contentcomponents 参数发送消息。

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

这也必须通过嵌入、文件、贴纸和其他message options来完成

【讨论】:

  • 另外,难道不能创建一个 MessageActionRow 并在那里添加 Button 组件吗?你可以使用它然后发送.send({ content: content, components: [<MessageActionRow>]
  • 在消息发送选项中添加也可以
  • @MrMythical 如果您可以检查这个问题,请:stackoverflow.com/questions/69746918/discord-js-deploy-commands
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2018-03-23
  • 1970-01-01
  • 2017-07-18
  • 2016-01-06
  • 2018-12-17
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多