简体   繁体   中英

TypeError: Cannot read property 'send'of undefined | Discord.JS

Error:

TypeError: Cannot read property 'send' of undefined

 let generalChannel = client.channels.cache.get("739065709132382261")
 generalChannel.send("Hello!")

How do I fix it?

client.channels.cache.get needs to be specified with channel's name, as far as I know. So, instead of let generalChannel = client.channel.cache.get("ID") , try using let generalChannel = client.channels.cache.find(channel => channel.name === "Name of the channel")

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM