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
Add a ment  | 

3 Answers 3

Reset to default 9

Looks 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