discordjs / discord.js

A powerful JavaScript library for interacting with the Discord API
https://discord.js.org
Apache License 2.0
25.2k stars 3.96k forks source link

New Stage channels are causing Discord.js to crash on v11.6.4 #5526

Closed icanovi closed 3 years ago

icanovi commented 3 years ago

Discord bots using Discord.js version 11.6.4 are throwing a "TypeError: Cannot read property 'id' of undefined" on line 81 of the ClientDataManager.js file. New Stage channels seems to be the cause of it.

Include a reproducible code sample here, if possible:

1|npm -- run start:node  | /app/discord-bot/node_modules/discord.js/src/client/ClientDataManager.js:81
1|npm -- run start:node  |         guild.channels.set(channel.id, channel);
1|npm -- run start:node  |                                    ^
1|npm -- run start:node  | TypeError: Cannot read property 'id' of undefined
1|npm -- run start:node  |     at ClientDataManager.newChannel (/app/node_modules/discord.js/src/client/ClientDataManager.js:81:36)
1|npm -- run start:node  |     at Guild.setup (/app/node_modules/discord.js/src/structures/Guild.js:307:68)
1|npm -- run start:node  |     at GuildCreateHandler.handle (/app/node_modules/discord.js/src/client/websocket/packets/handlers/GuildCreate.js:12:15)
1|npm -- run start:node  |     at WebSocketPacketManager.handle (/app/node_modules/discord.js/src/client/websocket/packets/WebSocketPacketManager.js:108:65)
1|npm -- run start:node  |     at WebSocketConnection.onPacket (/app/node_modules/discord.js/src/client/websocket/WebSocketConnection.js:336:35)
1|npm -- run start:node  |     at WebSocketConnection.onMessage (/app/node_modules/discord.js/src/client/websocket/WebSocketConnection.js:299:17)
1|npm -- run start:node  |     at WebSocket.onMessage (/app/node_modules/ws/lib/event-target.js:120:16)
1|npm -- run start:node  |     at emitOne (events.js:116:13)
1|npm -- run start:node  |     at WebSocket.emit (events.js:211:7)
1|npm -- run start:node  |     at Receiver.receiverOnMessage (/app/node_modules/ws/lib/websocket.js:789:20

Further details:

Relevant client options:

papaia commented 3 years ago

Discord v11 is going out of support, this will not get help. Update to v12.

icanovi commented 3 years ago

@papaia We're using node v8.11.2. We can't update to node v12 at the moment. If you confirm there's no other alternative that's ok, I just wanted to confirm that.
Thanks

iShibi commented 3 years ago

Update to v12 of discord.js.

icanovi commented 3 years ago

@iShibi v12 of discord.js states that "Node.js 12.0.0 or newer is required." in the readme file.

almostSouji commented 3 years ago

⚠️ Stage channels will crash version 11 on startup. We are aware of this and will not fix old versions. Please update to version 12 if you want to continue using discord.js.


If you still have questions about discord.js installation or usage please visit the Discord server at https://discord.gg/bRCvFy9. This issue tracker is just for bug reports and enhancement suggestions.

ajmeese7 commented 3 years ago

I found a fix, for anyone interested.

Step 1) Add GUILD_STAGE_VOICE: 13, to line 291 of node_modules\discord.js\src\util\Constants.js. Step 2) Add

case Constants.ChannelTypes.GUILD_STAGE_VOICE:
    channel = new VoiceChannel(guild, data);
    break;

to line 79 of node_modules\discord.js\src\client\ClientDataManager.js.

This isn't a great workaround, so I'm going to host a modified v11 on my fork of the project that can be referenced for people who need a way around this issue. I'll try to push the changes to v11 of the main repository, but if maintainers don't want to merge you can feel free to use my fork.

Will come back and update once I've pushed the changes.

almostSouji commented 3 years ago

Or you can stop using outdated versions, we no longer support v11 and do not accept pull requests to outdated branches.

ajmeese7 commented 3 years ago

Well as long as you refuse to allow selfbots we don't have much of a choice other than using the older versions :)

iCrawl commented 3 years ago

As long as selfbots are against ToS and get people banned, we will continue to refuse them. Good luck.