Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError: Cannot read properties of undefined (reading '_add') #7749

Closed
DaStormer opened this issue Apr 5, 2022 · 3 comments · Fixed by #7755
Closed

TypeError: Cannot read properties of undefined (reading '_add') #7749

DaStormer opened this issue Apr 5, 2022 · 3 comments · Fixed by #7755

Comments

@DaStormer
Copy link
Contributor

Which package is this bug report for?

discord.js

Issue description

     this.message = this.channel?.messages._add(data.message) ?? data.message;
                                          ^

 TypeError: Cannot read properties of undefined (reading '_add')
     at new MessageComponentInteraction (/home/stormbeatz/StormBeatz/node_modules/discord.js/src/structures/MessageComponentInteraction.js:27:42)
     at new ButtonInteraction (/home/stormbeatz/StormBeatz/node_modules/discord.js/src/structures/ButtonInteraction.js:9:1)
     at InteractionCreateAction.handle (/home/stormbeatz/StormBeatz/node_modules/discord.js/src/client/actions/InteractionCreate.js:67:25)
     at Object.module.exports [as INTERACTION_CREATE] (/home/stormbeatz/StormBeatz/node_modules/discord.js/src/client/websocket/handlers/INTERACTION_CREATE.js:4:36)

I haven't had the chance to look into exactly how to reproduce this yet, but I'm fairly certain it has to do with the new VC text chats as it started happening around the same time.

I marked this as high priority as it causes the bot to crash.

Code sample

No response

Package version

discord.js@13.6.0

Node.js version

v16.4.0

Operating system

No response

Priority this issue should have

High (immediate attention needed)

Which partials do you have configured?

User, Channel, Message

Which gateway intents are you subscribing to?

Guilds, GuildMembers, GuildVoiceStates, GuildMessages, DirectMessages

I have tested this issue on a development release

No response

@Jiralite
Copy link
Member

Jiralite commented Apr 5, 2022

Hi, thank you for this bug report.

I was able to reproduce this (both on stable and main) - it is indeed caused by receiving an INTERACTION_CREATE event from a button (and alike) in a text-in-voice channel.

This will be resolved with #6921, but perhaps we should make the library more resilient to this behaviour before the feature is documented by Discord.

@kyranet kyranet added has PR and removed need repro labels Apr 5, 2022
@DaStormer
Copy link
Contributor Author

Thanks for confirming.

If possible, I believe this should be resolved as soon as possible since it causes a crash. To be specific, my bot has crashed 3 times over the past 2 days.

@Jiralite
Copy link
Member

Jiralite commented Apr 6, 2022

Hi @DaStormer! I've made a fix for this in both main and stable:

You can run npm install Jiralite/discord.js#13-resilient-interaction-message-cache to install the branch this fix is on for version 13. I have opted for simply stopping interactions received in text-in-voice channels as Discord has not documented them yet and discord.js does not support them yet. When documentation is available from Discord, discord.js will be able to safely emit them in those channels again.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 12, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants