我正在尝试建立一个自动系统,其中机器人具有计时器,如果它对机器人消息没有足够的反应,它说的是一件事,但是如果票数匹配,则发送另一条消息,我它的大部分功能都可以正常工作,但是“ rpMessage.awaitReactions”这一行出现了错误。
我尝试将初始消息设置为Const,变量,“ let”,仅使message.awaitReactions
if(cmd === `${prefix}rp`) {
const rpMessage = message.channel.send("<@&608365714775998485> A Roleplay is being started by " + message.author + " React with :white_check_mark: to join / vote" + '\n' + "Just a few rules to remember:" + '\n \n' + "• Dont FRP as this will get you removed from the RP" + '\n' + "• Drive cars in your civ rank (You can find speeds if you click your name)" + '\n' + "• Listen to staff" + '\n' + "• Don't cop bait").then(rpvote => {
rpvote.react('?').then(() => rpvote.react('?'));})
const filter = (reaction, user) => {
return ['?', '?'].includes(reaction.emoji.name) && user.id === message.author.id;
};
rpMessage.awaitReactions(filter, { max: 1, time: 60000, errors: ['time'] }) // This part isn't working
.then(collected => {
const reaction = collected.first();
if (reaction.emoji.name === '?') {
message.reply('you reacted with a thumbs up.');
}
else {
message.reply('you reacted with a thumbs down.');
}
})
.catch(collected => {
console.log(`After a minute, only ${collected.size} out of 4 reacted.`);
message.reply('>rpfail.');
});
}
应该从消息中获取响应,但是它永远无法读取awaitReacions的属性
答案 0 :(得分:0)
我假设问题是在不更新变量的情况下重用stackoverflow问题Discord.js message after receiving emoji reaction中的代码。
rpMessage.awaitReactions(filter, { max: 1, time: 60000, errors: ['time'] }) // This part isn't working
.then(collected => {
const reaction = collected.first();
if (reaction.emoji.name === '?') {
rpMessage.reply('you reacted with a thumbs up.');
}
else {
rpMessage.reply('you reacted with a thumbs down.');
}
})
.catch(collected => {
console.log(`After a minute, only ${collected.size} out of 4 reacted.`);
rpMessage.reply('>rpfail.');
});
}
您的变量名是rPMessage
,并且您使用过message