admin管理员组文章数量:1279046
so here's the thing. I've done a bot with discord.js, it was working well and then it crashed.
The reason I get is "guild.channels.set(channel.id, channel); ^
TypeError: Cannot read property 'id' of undefined"
And this error seems to be in node_modules\discord.js\src\client\ClientDataManager.js:81
But I just don't know what to do, the bot can't log and I didn't change the main file so I don't really understand
so here's the thing. I've done a bot with discord.js, it was working well and then it crashed.
The reason I get is "guild.channels.set(channel.id, channel); ^
TypeError: Cannot read property 'id' of undefined"
And this error seems to be in node_modules\discord.js\src\client\ClientDataManager.js:81
But I just don't know what to do, the bot can't log and I didn't change the main file so I don't really understand
Share Improve this question asked Mar 31, 2021 at 20:14 La Chaine Moderne 2.0La Chaine Moderne 2.0 331 silver badge4 bronze badges 2-
1
Can you confirm that the
channel
variable is set properly? – niklhs Commented Mar 31, 2021 at 20:29 - It's in the newChannel() function of ClientDataManager but I don't know what it is used for ... – La Chaine Moderne 2.0 Commented Mar 31, 2021 at 20:31
3 Answers
Reset to default 9Looks like this error es from the new "stage" channel type they recently added. The error es from the fact that it's not listed in the ClientDataManager newChannel() switch nor anywhere else as you would need to update Discord.js to add its support.
If you don't want to update Discord.js a temporary fix would be to add if(channel != null)
line 81.
But your bot won't be able to handle the Stage channels, so the only solution would be to udpate Discord.js
Okay so I added a If in ClientDataManager.js to avoid this error, not quite sure if this was the way to fix that error but that seems to work so better than nothing I guess ...
If you have any other idea don't hesitate
It is happening because of the new feature discord added known as 'stage channels', the only fix to this is to update discord.js to the latest version. At the time of writing this I am running discord.js 12.5.3 and I am not facing that issue
本文标签: javascriptDiscordjs cannot read property id of undefinedStack Overflow
版权声明:本文标题:javascript - Discord.js cannot read property id of undefined - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741297844a2370920.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论