Discord:通过 ID returns 未定义/空获取频道

Discord: Get channel by ID returns undefined / null

我正在为 运行 机器人命令设置一个 cron 作业,该机器人命令每天在特定时间 unlocks/locks 一个频道。尝试使频道 returns 未定义或为空,具体取决于我的处理方式。 机器人已添加到 discord 服务器并在线

require('dotenv').config();
const Discord = require("discord.js");
const client = new Discord.Client();

client.login(process.env.TOKEN);

const chan = client.channels.cache.get("858211703946084352");
console.log(chan);
const channel = client.channels.fetch("858211703946084352").then(res => {
    console.log(res);
});
console.log(channel);

当我在控制台中 运行 它时,我得到

undefined
Promise { <pending> }
null

我看过很多例子和解决方案,但 none 似乎解决了我的问题


编辑:

bot 具有管理员权限。

我做了 'right click on channel and copy ID' 技术,这与我使用开发工具检查包含频道名称的元素时得到的 ID 相匹配

服务器中有一个 MEE6 机器人所以我知道机器人可以发送消息

编辑2:

为了好玩和利益,我删除了应用程序并重新制作了它,同样的问题

我尝试使用 MEE6 机器人发送到的频道,同样的问题

在就绪事件中尝试运行此代码

client.on('ready', () => {
    const chan = client.channels.cache.get("858211703946084352");
    console.log(chan);
});