[英]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.