【问题标题】:The button showing up on the embed works, but when I click on the button, it says interaction failed嵌入上显示的按钮有效,但是当我单击该按钮时,它说交互失败
【发布时间】:2021-09-25 17:56:27
【问题描述】:

用按钮发送嵌入的东西

if (message.content.toLowerCase().startsWith(prefix+ 'test')) {
    let first = new disbut.MessageButton().setStyle("blurple").setID("1").setLabel("Confirm") //first button
    let second = new disbut.MessageButton().setStyle("red").setID("2").setLabel("Cancel") //second button
    var buttons = [first, second]
    let embed = new Discord.MessageEmbed() 
      .setTitle(":fire: Test")
      .setDescription("Yes")
      .setColor("#BEBDBD")
      .setTimestamp("Today"+ message.createdAt)
      message.channel.send({ embed: embed, buttons: buttons })

当我们点击按钮时会发生什么

     client.on('clickButton', async (button) => {
      if (button.id == "1") {
        button.message.channel.send("it worked");
      }
      if (button.id == '2') {
        button.edit(embed.footer("canceled"));
      }
     })
  }

【问题讨论】:

  • 在你的事件下尝试 console.logging 看看它是否正在运行,像这样:client.on('clickButton', async button => {console.log('run successfully'})
  • 我已经试过了,还是不行
  • 这意味着事件没有发出。

标签: javascript node.js discord.js discord-buttons


【解决方案1】:

您必须在 API 提供的一行中添加两个按钮。不在列表中

let row = new MessageActionRow()
  .addComponents(button, button2);

https://discord-buttons.js.org/docs/stable/examples/buttons.html#:~:text=%23-,Multiple%20Buttons,-let%20button%20%3D%20new

【讨论】:

    猜你喜欢
    • 2022-01-19
    • 2021-08-13
    • 2022-08-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多