javascript - guild.channels.cache.array() 返回一个空数组。与 client.channels.cache.array() 相同
问题描述
此代码返回一个空数组 -[]
为什么?公会有很多频道。
'use strict'
import { Client } from 'discord.js'
const bot = new Client
bot.login('token')
bot.guilds.fetch('826581310151196712').then(server => {
console.log(server.channels.cache.array())
})
解决方案
我认为您需要遍历数组或传播它。
bot.guilds.fetch('826581310151196712')
.then({ channels : { cache : { array } } } => {
for (const channel of array()) {
console.log(channel.id);
}
})
也许你可以试试:[...array()]
?
推荐阅读
- java - 如何将.dex文件转换为android studio项目
- x86-16 - 如何打印存储在变量中的整数
- python - 混合龙卷风和 sqlalchemy
- java - 在java中使用opencv录制和保存视频流
- r - ggplot构面图重新排序未按预期工作
- algorithm - 我正在努力为我的家庭作业找到有效的解决方案。冒泡排序还是插入排序?
- php - php - 基于范围键返回数组
- kubernetes - 将 2 个不同的 statefulSet 连接到同一个 PV
- architecture - 在 DDD 的上下文中应该如何处理事务
- ruby-on-rails - 更新具有相同图像的模型时出现 ActiveSupport::MessageVerifier::InvalidSignature 错误