javascript - “无法读取未定义的属性‘缓存’”?
问题描述
我正在使用 Discord.js V12
我正在尝试按 ID 向特定频道发送消息
我得到了频道 ID,并使用下面的代码将其存储在ChRules中
const ChRules = client.channels.cache.find(c => c.name === '│rules-and-info').id
因此,当我尝试按 ID 向频道发送消息时,我使用下面的代码
client.channels.cache.get(ChRules).send("Follow the rules");
但由于某种原因,我得到了错误
TypeError:无法读取未定义的属性“缓存”
我的机器人在一个服务器上,所以我不明白为什么会出现这个错误
我client
定义为const client = new Discord.Client();
解决方案
这应该工作
const ChRules = client.guild.channels.cache.find(c => c.name === '│rules-and-info')
ChRules.send("SEND");
推荐阅读
- entity-framework-core - 在 Entity Framework Core 中重用包含语句
- c# - 是否可以创建具有特定文件名的 blob 触发 azure 函数?
- ruby - 如何使用端口转发从同一个文件运行多个 vagrant box 实例
- javascript - Typescript 编译器工作但 Javascript 结果错误
- css - Semantic-ui Accordion:嵌套手风琴的控制风格
- html - 在 CSS 中设置 SVG 颜色以覆盖整个背景
- if-statement - 如何在 IF 条件中应用 2 awks?
- mysql - MySQL:在 GROUP BY 之后添加多个列?
- node.js - 如何强制 express 始终提供新的 index.html?
- maven - 我可以在单个 artifactId 上发布多个工件吗?