![](/img/trans.png)
[英]When running getting: TypeError: Cannot read properties of undefined (reading 'send')
[英]TypeError: Cannot read properties of undefined (reading 'send')
我正在用 node.js 編寫一個 discord 機器人。 我希望機器人在成員加入或離開頻道時自動發送消息。 但我不斷收到關於發送 function 的錯誤。 你能幫助我嗎? [1]: https://i.stack.imgur.com/4URud.png
module.exports = (client) => {
client.on('guildMemberRemove', (member) => {
console.log(member);
member.guild.channels.cache.get("1234567890912345678").send("byeee");
});
}
member.guild.channels.cache.get("1234567890912345678")
未定義,因此沒有send()
function。 您需要確定該通道未定義或不存在的原因,或者使用其他方法找到該通道。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.