【发布时间】: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