因此,我的机器人现在在第一条消息之后立即发送“ A”反应消息,但用户没有反应。它不应该那样做。为什么?我没有错误。
client.on("guildMemberAdd", member => {
try {
member.send(`Hello ${member}, welcome to the PotatoHost Server!
I want to help you and so my question is: Do you want to buy a server or do you need more informations first? \n
A: I want to buy a server
B: I need more informations first \n
Please react to this message with A or B.`)
.then(function (message) {
message.react("?")
message.react("?")
const filter = (reaction, user) => {
return ['?', 'B'].includes(reaction.emoji.name) && user.id === message.author.id;
};
message.awaitReactions(filter, { max: 1, time: 3600000, errors: ['time'] })
.then(collected => {
const reaction = collected.first();
if (reaction.emoji.name === '?') {
message.channel.send('Ok, so you want to buy a server. Let me recommend you to visit <#699374469977735208>.');
}
else {
message.channel.send('Ok, so you need more informations first. Let me recommend you to visit <#699374469977735208>.');
}
})
.catch(collected => {
message.channel.send('You reacted with neither A or B.');
})
});
}catch (err) {
console.log(err)
}
})
答案 0 :(得分:0)
看来您正在覆盖原始的message
对象。在您的过滤器中,您要确保它是成员的ID,因此没有人可以声明它,
&& user.id === message.author.id
但是,在这种情况下,message
指的是您的漫游器正在发送的消息-.then(function (message) {
。因此,您的代码将读取过滤器,因为ID必须与您的机器人相匹配,并且由于您的机器人与A发生反应,因此它会发出A反应消息。
要解决此问题,请将之前所述的过滤器更改为
&& user.id === member.id
编辑
第二个问题:B.您的过滤器仅找到?或B,您需要将B更改为return ['?', 'B']
中的表情符号版本。