Rate Limit Question

Hey, I have a question about the rate limit. I was told that discord.js itself already handles rate limits and that you don't have to do that as a bot creator. Is that true? And also for larger bots? In addition, there are rest events, once the Response and once the RateLimited? If I get a 429 for one of them, is it always a 429 from Discord or can it also be a 429 that Discord.js has intercepted?
5 Replies
d.js toolkit
d.js toolkit2d ago
- What's your exact discord.js npm list discord.js and node node -v version? - Not a discord.js issue? Check out #other-js-ts. - Consider reading #how-to-get-help to improve your question! - Explain what exactly your issue is. - Post the full error stack trace, not just the top part! - Show your code! - Issue solved? Press the button!
treble/luna
treble/luna2d ago
djs does handle ratelimits for you yes, this should also work for larger bots. And djs is just an api wrapper, it just returns what the api returns
BastiGameツ
BastiGameツOP2d ago
This means that if RESTEvents.Response returns a 429, do I also have this in Discord? Ah okay, is there a way to intercept something like that? I get a rate limit for a route like PATCH /channels/324/messages/1234 and when I request the route the next time, the same thing comes back with a rate limit. I thought that if a rate limit comes back on one route, discord.js will not send it to discord the next time, but since a rate limit keeps coming back, discord.js will probably send it to discord again and again. I want to prevent that I get a rate limit for a route several times in a short time. I always log in when a rate limit appears for Rest Event in Response. I then looked at the route and it was the same. Since it was after a few seconds I knew that it must be the same rate limit.
BastiGameツ
BastiGameツOP2d ago
this is for example logs which come from the rest event response.
No description
BastiGameツ
BastiGameツOP2d ago
yes, can also be seen in the screenshot Here is the complete log, which we save
PATCH /channels/id/messages/id -> 429 - Too Many Requests - {"content":"","tts":false,"enforce_nonce":false,"embeds":[{"color":16711680,"author":{"name": "remove advertising"
,"icon_url":"https://cdn.discordapp.com/icons/1212836507635945503/3f8818beef25a111e72c389e0a6ff2cc.webp?size=4096","url":null},"thumbnail":null,"description":"## blablabla","fields":[{"name":"Insgesamt","value":59,"inline":true},{"name":"Online","value":13,"inline":true},{"name":"Im Dienst","value":2,"inline":true}],"image":{"url":".png"},"footer":null}],"components":[{"type":1,"components":[{"type":2,"disabled":false,"custom_id":"support.button.duty.toggleCheckIn","label":"An/-Abtreten","style":2}]}],"allowed_mentions":{"parse":["users","roles","everyone"]},"flags":0,"attachments":[]}
PATCH /channels/id/messages/id -> 429 - Too Many Requests - {"content":"","tts":false,"enforce_nonce":false,"embeds":[{"color":16711680,"author":{"name": "remove advertising"
,"icon_url":"https://cdn.discordapp.com/icons/1212836507635945503/3f8818beef25a111e72c389e0a6ff2cc.webp?size=4096","url":null},"thumbnail":null,"description":"## blablabla","fields":[{"name":"Insgesamt","value":59,"inline":true},{"name":"Online","value":13,"inline":true},{"name":"Im Dienst","value":2,"inline":true}],"image":{"url":".png"},"footer":null}],"components":[{"type":1,"components":[{"type":2,"disabled":false,"custom_id":"support.button.duty.toggleCheckIn","label":"An/-Abtreten","style":2}]}],"allowed_mentions":{"parse":["users","roles","everyone"]},"flags":0,"attachments":[]}
ah okay, unfortunately there is nothing we can do about it, so we wouldn't needlessly request the discord api in such situations yes if you press this button that's what i thought discord.js was doing. but if that's not the case, i would make it ah i'll do the update when you get the role. maybe it's because too many people have gotten the role.

Did you find this page helpful?