(node:47028) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'emoji' of undefined

(node:47028) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'emoji' of undefined

为什么会给我这个错误?如何定义表情符号? IT 应该只检查反应是否与那个表情符号有关。

.then(function (message, reaction) {
                message.react("")
                message.react("")

                const filter = (reaction, user) => {
                    return ['', 'B'].includes(reaction.emoji.name) && user.id === message.author.id;
                };

                message.awaitReactions(filter, { max: 1 })
                    .then(collected => {
                        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>.');
                        }    
                    })
            });

reaction 不会由您在显示的代码之前直接调用的任何方法返回。从回调函数中删除参数。然后,要访问应用的反应,您需要从 Message#awaitReactions() 返回的 Collection 中读取它。例如...

.then(collected => {
  const reaction = collected.first();
  // now you can check the reaction with the code you were using
})