discordjs / discord.js

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

Events are sent very slowly #9131

Closed MaksiRose closed 1 year ago

MaksiRose commented 1 year ago

Which package is this bug report for?

discord.js

Issue description

This issue is making people not use the bot out of frustration so it is really high priority to me. The bot is simply not receiving the events fast enough. Once they are received, they are executed within milliseconds, but the event is sent super late. Here is a comparison between the affected bot Paw and Paper (djs version 14.7.1) and River Warden (djs version 14.5.0). Both run on the same server so this is not an issue of internet being slow.

https://user-images.githubusercontent.com/96802571/218553933-4e43cfd8-73d5-4217-9f31-8ffb05aa87d9.mp4

As you can also see the delay for the event to be sent is inconsistent, whereas for the other bot it's always fast. I'm not really sure if something changed between these versions or whether there is something about my bot that makes it receive these events so slowly but I really need a fix for this ASAP.

Code sample

No response

Package version

14.7.1

Node.js version

v19.1.0, typescript is 4.9.4

Operating system

No response

Priority this issue should have

High (immediate attention needed)

Which partials do you have configured?

No Partials

Which gateway intents are you subscribing to?

Guilds, GuildMessages, MessageContent

I have tested this issue on a development release

No response

Syjalo commented 1 year ago

Probably related to https://github.com/discord/discord-api-docs/issues/5558

MaksiRose commented 1 year ago

@Syjalo No I don't see how it's related. The issue you link says that on the back-end it's reporting an Unknown Interaction, while in the front-end the user got the reply. I don't have this issue. My issue is that in the front-end, it doesn't reply. It doesn't even get the event in the back-end, I can actually see when it gets the event and it takes up to 9 seconds like you could see in the first command sent in the video. That means it took 9 seconds for my interactionCreate file to receive the event, and then it took a few milliseconds to actually send the message (in this case a normal message due to the interaction obviously having failed after 9 seconds, I had to implement this due to the large number of failed interactions the bot was giving users). The problem is therefore not misleading Unknown Interaction errors, but the events not being sent in time.

Syjalo commented 1 year ago

The issue I linked also have an issue with receiving interactions. It takes too much time and the interaction token becomes invalided so that the back-end returns the Unknown Interaction error when trying to respond to the interaction.

MaksiRose commented 1 year ago

In the server, Qjuh has figured it out, it's that I still use my old JSON database that I haven't upgraded and because that reads files synchronously, it just takes a lot of time. So the issue is on my end