为什么我的控制台在“已启动”之前记录“已完成”?为什么我不能等待message.awaitReactions(); ?
const filter = async /*It is here for no reason but without it does not work neither*/ (reaction, user) => {
if (user.id == players[p].user.id && aEmojis.indexOf(reaction.emoji.name) != -1) {
console.log("Started");
attackedIndex = aEmojis[aEmojis.indexOf(reaction.emoji.name)+1];
message.delete();
return true;
}
return false;
};
await message.awaitReactions(filter, {max: 1});
console.log("Finished");
await
在异步函数中工作
(async function() {
const filter = async (reaction, user) => {
if (user.id == players[p].user.id && aEmojis.indexOf(reaction.emoji.name) != -1) {
console.log("Started");
attackedIndex = aEmojis[aEmojis.indexOf(reaction.emoji.name)+1];
message.delete();
return true;
}
return false;
};
await message.awaitReactions(filter, {max: 1});
console.log("Finished");
})();