【发布时间】:2021-01-02 12:26:37
【问题描述】:
我正在尝试向我的机器人添加一个小功能,以便在机器人在线时通知人们。
我做了以下事情:
//BOT connexion actions
client.on("ready", function () {
console.log("BOT connected");
client.channels.cache.find(channel => channel.name === 'ID').send("text");
});
我什至尝试使用我拥有的 const,因为所有机器人消息都在特定频道中返回,但它仍然不起作用
const channel01 = client.channels.cache.find(channel => channel.id === "ID");
...
client.channel01.send("text");
当然,ID就是具体的频道ID。
简而言之,我得到的错误是:(node:22000) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'send' of undefined
我不确定这里出了什么问题,因为 .send 在命令输入时得到了正确处理。
感谢您的帮助!
【问题讨论】: