我最近注意到我的discordbot停止工作,我没有升级我的服务器上的任何东西,它只是停止工作。
我在日志中注意到了。我想我有旧版本的软件包,我升级到discord.js v13,一切都更糟糕了。
discclient.channels.fetch(item.channel[i]).send(msgembed)
现在我被困在这里了。
index2.js:46
channel.send({ embeds: [msgembed] });
^
TypeError: Cannot read properties of undefined (reading 'send')
有人知道吗?他们改变了很多东西吗?
谢谢!
GuildChannelManager#fetch()返回一个promise,您必须在尝试访问通道之前解决它。
discclient.channels.fetch(item.channel[i])
.then(channel => channel.send({ embeds: [msgembed] }))
.catch(console.error);
从v12到v13的更新指南
这仅仅意味着通道不存在。在发送消息之前,尝试获取并验证它是否找到了它。