discord.js - discord.js反应TypeError:无法读取未定义的属性'get'
问题描述
所以我试图从嵌入中收集反应,但我仍然收到这个错误:
var peopleReacted = embedsend.reactions.get(party).users.array();
^
TypeError: Cannot read property 'get' of undefined
at Timeout._onTimeout
这是我的代码:
message.channel.send(`${boost} **GIVEAWAY** ${boost}`, embed).then(sentEmbed => {
sentEmbed.react(party)});
setTimeout(function() {
var random = 0;
var winners = [];
var inList = false;
var peopleReacted = embedsend.reactions.get(party).users.array();
我也一直在尝试使用
sentEmbed.reactions.get
orcache.get
但后来我得到了sentEmbed is not definied
解决方案
其中一个错误是 in embedsend.reactions.get(party).users.array();
,因为(假设你在 d.js 版本 12 中),你必须改为使用.cache
,所以让它embedsend.reactions.cache.get(party).users.array();
另外,var embedsend = embed;
不是消息,它是一个嵌入对象。相反,使用var embedsend = message.channel.send('${boost} **GIVEAWAY** ${boost}', embed);
,然后它将设置为您发送的实际消息,而不是嵌入。
推荐阅读
- python-3.x - keras 中的三重损失,如何从合并向量中获取锚点、正数和负数
- python - 带有格式的现有 Excel 模板的 Pandas 数据框
- rest - Kerberos 安全 API 的 MuleSoft 应用程序使用者
- prolog - 为什么是“canget(state(atdoor, onfloor, inmiddle, atwindow, hasnot), Plan)”的输出。在这个程序中反复返回为假?
- javascript - 如何在 MongoDB 中预先存在的文档中定义一个不在模式中的新字段?(Node.js)
- sql-server - 在 SQL Server 2016 存储过程中解析 XML
- tensorflow - 在冻结的 Keras 模型中,dropout 层是否仍然处于活动状态(即 trainable=False)?
- c++ - 如何在 Linux 中通过 C/C++ 以另一个用户身份创建文件?
- sql - 如何在 In Clause 中为数千个项目编写 Like Condition
- python - 从存储帐户安装私有 python 轮子