【发布时间】:2021-04-04 00:51:35
【问题描述】:
我想创建一个帮助屏幕,您可以使用反应滚动浏览。
例如,
- 如果您对信息表情符号做出反应,机器人的消息将被编辑以显示信息页面。
- 现在,当有人发送以“;help”开头的消息时,我可以发送帮助消息,并且我可以让机器人对消息做出反应。
但是,我无法让我的机器人删除用户的反应,也无法让其编辑我的消息。
这里是代码。提前感谢您的帮助!
client.on('message', message => {
if (message.author !== null && message.author.bot) return;
if (message.toString().startsWith(';help')) {
const helpPi = new Discord.MessageEmbed()
.setTitle('Help and commands')
.setColor('0004ff')
.setDescription('This is the help menu for available commands. Here is the table of contents:\n> 1 - Commands\n> 2 - More info.')
const helpP1 = new Discord.MessageEmbed()
.setTitle('Help and commands')
.setColor('0004ff')
.setDescription('Command A\nCommand B')
const helpP2 = new Discord.MessageEmbed()
.setTitle('Help and commands')
.setColor('0004ff')
.setDescription('More info.')
message.channel.send(helpPi).then(sentMessage => {
sentMessage.react('ℹ️')
sentMessage.react('1️⃣')
sentMessage.react('2️⃣')
client.on('messageReactionAdd', reaction => {
if (reaction == '1️⃣') {
sentMessage.edit(helpP1)
}
else if (reaction == '2️⃣') {
sentMessage.edit(helpP2)
}
else if (reaction == 'ℹ️') {
sentMessage.edit(helpPi)
}
})
})
}
});
【问题讨论】:
标签: javascript node.js discord discord.js bots