![](/img/trans.png)
[英]Discord.js: TypeError: Cannot read properties of undefined (reading 'add')
[英]TypeError: Cannot read properties of undefined (reading 'send') in discord.js
我正在嘗試將消息發送到 discord 上的特定頻道,但出現此錯誤:
TypeError: Cannot read properties of undefined (reading 'send')
不過我輸入了正確的頻道 ID,可能是什么問題? 這是我的 function 代碼和快照:
function discordsend(usern)
{
usern="someusername#1234"
string = "somethingsomething"+usern;
const channel = client.channels.cache.get('946932969359179786');
channel.send(string);
}
你應該使用client.guilds.cache.get("guild ID").channels.cache.get("channel ID")
如果通道一開始不存在,也可以使用條件鏈接來避免出錯。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.