I can't connect to Discord

Suddenly, the Discord BOT can no longer connect to Discord. Looking at the error, it seems that there is an error in the login process. However, TOKEN is set correctly. Please tell me how to resolve. (I translated this into English with Google Translate, so something may be wrong, but don’t worry.)

Can you give us the exact error you receive in the console?

/rbd/pnpm-volume/04276061-857b-4005-84cd-4e7a78aee408/node_modules/.registry.npmjs.org/discord.js/11.6.4/node_modules/discord.js/src/client/ClientDataManager.js:81

12:10 AM

guild.channels.set(channel.id, channel);

12:10 AM

^

12:10 AM

12:10 AM

TypeError: Cannot read property ‘id’ of undefined

12:10 AM

at ClientDataManager.newChannel (/rbd/pnpm-volume/04276061-857b-4005-84cd-4e7a78aee408/node_modules/.registry.npmjs.org/discord.js/11.6.4/node_modules/discord.js/src/client/ClientDataManager.js:81:36)

12:10 AM

at Guild.setup (/rbd/pnpm-volume/04276061-857b-4005-84cd-4e7a78aee408/node_modules/.registry.npmjs.org/discord.js/11.6.4/node_modules/discord.js/src/structures/Guild.js:307:68)

12:10 AM

at GuildCreateHandler.handle (/rbd/pnpm-volume/04276061-857b-4005-84cd-4e7a78aee408/node_modules/.registry.npmjs.org/discord.js/11.6.4/node_modules/discord.js/src/client/websocket/packets/handlers/GuildCreate.js:12:15)

12:10 AM

at WebSocketPacketManager.handle (/rbd/pnpm-volume/04276061-857b-4005-84cd-4e7a78aee408/node_modules/.registry.npmjs.org/discord.js/11.6.4/node_modules/discord.js/src/client/websocket/packets/WebSocketPacketManager.js:108:65)

12:10 AM

at WebSocketConnection.onPacket (/rbd/pnpm-volume/04276061-857b-4005-84cd-4e7a78aee408/node_modules/.registry.npmjs.org/discord.js/11.6.4/node_modules/discord.js/src/client/websocket/WebSocketConnection.js:336:35)

12:10 AM

at WebSocketConnection.onMessage (/rbd/pnpm-volume/04276061-857b-4005-84cd-4e7a78aee408/node_modules/.registry.npmjs.org/discord.js/11.6.4/node_modules/discord.js/src/client/websocket/WebSocketConnection.js:299:17)

12:10 AM

at WebSocket.onMessage (/rbd/pnpm-volume/04276061-857b-4005-84cd-4e7a78aee408/node_modules/.registry.npmjs.org/ws/6.2.1/node_modules/ws/lib/event-target.js:120:16)

12:10 AM

at WebSocket.emit (events.js:196:13)

12:10 AM

at Receiver.receiverOnMessage (/rbd/pnpm-volume/04276061-857b-4005-84cd-4e7a78aee408/node_modules/.registry.npmjs.org/ws/6.2.1/node_modules/ws/lib/websocket.js:789:20)

12:10 AM

at Receiver.emit (events.js:196:13)

(All of these errors disappear when I comment out the part of the login process, so I guessed that was the cause.)

channel is undefined

I do not see how you thought this was a connection issue at all.

Apparently, it was a problem with Discord x Discord.js v11. After updating Discord.js to v12, everything worked fine. Thank you to those who answered. (I translated this into English using Google Translate, so something may be wrong, but don’t worry.)