【发布时间】:2020-08-15 19:01:11
【问题描述】:
所以我正在为我的服务器制作 Discord 机器人,到目前为止它运行良好,除了一个看起来非常小的问题,但尽管阅读了文档,但我找不到解决方案。
基本上我发送带有反应的嵌入,它工作正常,但如果有人在特定时间内没有反应,机器人会创建另一个表情符号反应,这就是问题所在。我希望它收集第一个对新表情符号做出反应的人,而不是消息作者。这是这部分代码:
.catch(collected => {
message.channel.sendMessage("You run out of time, maybe someone else wants it?");
const filter = (reaction, user) => {
return ['????'].includes(reaction.emoji.name) && user.id === message.author.id;
};
embedMessage.react('????');
embedMessage.awaitReactions(filter, {
max: 1,
time: 45000,
errors: ['time']
}).then(collected => {
const reaction = collected.first();
if (reaction.emoji.name === '????'){
message.channel.sendMessage("Yay.");
}
});
});
所以我想知道这是否与这部分有关:
return ['????'].includes(reaction.emoji.name) && user.id === message.author.id;
我尝试将 message.author.id 替换为 reaction.users,但它似乎不起作用。
【问题讨论】:
标签: node.js discord.js