【发布时间】:2021-06-12 22:42:35
【问题描述】:
在这个机器人上工作了一段时间,但我似乎被难住了。每次我运行它,它都会说
UnhandledPromiseRejectionWarning:TypeError:无法读取未定义的属性“createReactionCollector”
这是由
const collector = message.createReactionCollector(filter, { time: 15000 });
引起的
我不知道该怎么做。大多数其他示例要么已过时,要么出于特定目的而制作,因此很难将它们实现到我的代码中。非常感谢您提供的任何帮助!
if (command === 'ping') {
const pingEmbed = new Discord.MessageEmbed()
.setColor('#03cffc')
.setTitle('Ping!')
.setDescription(`${message.author.username} is playing a game! \n \n Playing With: \n ` + isPlaying);
message.channel.send(pingEmbed)
.then(sentEmbed => {
sentEmbed.react("????")
}).then( async message => {
const filter = (reaction, user) => {
return reaction.emoji.name === '????' && user.id === message.author.id;
};
const collector = message.createReactionCollector(filter, { time: 15000 });
collector.on('collect', (reaction, user) => {
console.log(`Collected ${reaction.emoji.name} from ${user.tag}`);
});
collector.on('end', collected => {
console.log(`Collected ${collected.size} items`);
});
})}
【问题讨论】:
-
是否在正确的范围内?是否定义了“消息”?
-
message正在返回未定义 -
是的,我明白了,它应该包含集合的消息就是它发送的消息。我需要帮助的是如何在机器人刚刚发送的消息上设置反应收集器
-
如果
message已经是你的全局发送消息对象的名称,不要再使用名称message,使用另一个名称例如msg或m -
我刚试过,但是,错误仍然发生我需要的是一种在机器人刚刚发送的对象上创建反应收集器的方法,所以我不介意代码被更改,我我只是说我尝试过的。
标签: javascript discord.js