[英]How to count amount of reactions in Discord.js v13?
I have tried so many things out, here's my current code我已经尝试了很多东西,这是我当前的代码
var green = toString(msg.reactions.cache.get('🟩').count);
var red = toString(msg.reactions.cache.get('🟥').count);
msg.reply("Poll has ended which was created by " + msg.author.username)
msg.reply(green + " " + red)
It gives this error它给出了这个错误
var green = toString(msg.reactions.cache.get('🟩').count);
^
TypeError: Cannot read properties of undefined (reading 'count') TypeError:无法读取未定义的属性(读取“计数”)
Please help!请帮忙!
I want it to display how many people reacted on 🟩 and 🟥.我希望它显示有多少人对 🟩 和 🟥 做出了反应。
I'm not able to do that even after asking Discord.js experts, I can't understand how to get them.即使在询问了 Discord.js 专家之后,我也无法做到这一点,我无法理解如何获得它们。
I also want them to be a string, that's why I used The toString() function.我也希望它们是一个字符串,这就是我使用 toString() 函数的原因。
This is for a poll/vote bot I am making.这是我正在制作的投票/投票机器人。
I react to the messages and still it shows this error.我对消息做出反应,但仍然显示此错误。
This is Discord.js v13.这是 Discord.js v13。
Thanks!谢谢!
TheThiefingKing盗贼王
let msg = await message.channel.messages.fetch("974311411314475059")
let reactsSize = msg.reactions.cache.get("✅").count
message.channel.send("✅ Reacts on that message is: " + (+reactsSize))
You need to await message first after that you can fetch reactions.您需要先等待消息,然后才能获取反应。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.