Skip to content

Discord.js cannot read property id of undefined

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_modulesdiscord.jssrcclientClientDataManager.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

Answer

Looks like this error comes from the new “stage” channel type they recently added.
The error comes 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