gpt4 book ai didi

discord.js - 获取对旧消息的旧 react

转载 作者:行者123 更新时间:2023-12-04 15:30:34 24 4
gpt4 key购买 nike

我写了一个版本为 12.0.2 的 discord.js 机器人,一些功能已经运行了一段时间但现在无法正常工作,它似乎与空缓存有关,但我无法弄清楚如何解决它。

场景如下:

I have my bot weekly posting a message on a server and guild members have a week to react to this message. At the end of the week, I want to analyze the reactions to the bot to decide what to do (I can't have the bot running 24/7 to await for reactions).

这是我的问题:

Once I've fetched this specific message, what I did until now was msg.reactions.resolve('✅').users.fetch().then(somestuff), but since a few weeks it stopped functionning and now throws (node:2336) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'users' of null.

我已经完成了一些调试步骤,发现 msg.reactions.cache 是空的,因此我认为这里是问题所在,但我找不到如何填充它。以下是 msg.reactions 包含的内容:

ReactionManager {
cacheType: [Function: Collection],
cache: Collection [Map] {},
message: Message {
details_about_the_message_that_confirm_it_is_the_desired_one_that_have_been_reacted_to
}
}

有人知道如何解决这个问题吗?任何帮助将不胜感激,谢谢!

最佳答案

我终于找到了一个解决方案,或者我最好称它为解决方法,因此我在这里分享它以关闭这篇文章。

首先,我必须说 msg.reactions.resolve('✅').users.fetch().then(somestuff) 完成了它的工作并且不是问题的一部分,因为问题出在消息获取过程中。获取一堆消息或获取特定消息(按 ID)会导致不同的结果。

通过 ID 获取特定消息可以让您访问 ReactionManager 的缓存,而获取多条消息似乎不会填充缓存。

关于discord.js - 获取对旧消息的旧 react ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61312773/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com