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

[Enhancement #3] Better post handling to avoid rate-limiting #8

Open
Andrew-J-Larson opened this issue Apr 18, 2021 · 4 comments
Open
Assignees
Labels
enhancement New feature or request

Comments

@Andrew-J-Larson
Copy link
Owner

Andrew-J-Larson commented Apr 18, 2021

Current implementation is fine for now, but rather a dirty fix...

It'd be better to use a sort of stack implementation for posting. Any bot posts/responses, would need to go onto the stack, and then the stack would correctly pop each post off under a correct amount of delay to avoid the rate-limiting (of 50 posts per second, at least globally).

The upside of doing this will remove the sometimes overuse of delay when it doesn't need to be used, aka making the bot faster again, even if slightly.

EDIT: I'm likely going to push this off until one of the bots has 50+ servers, because then it'll be absolute necessity.

@Andrew-J-Larson Andrew-J-Larson self-assigned this Apr 18, 2021
@Andrew-J-Larson Andrew-J-Larson added the enhancement New feature or request label Apr 18, 2021
@Andrew-J-Larson Andrew-J-Larson changed the title [Enhancement #3] Best post handling to avoid rate-limiting [Enhancement #3] Better post handling to avoid rate-limiting Apr 18, 2021
@Andrew-J-Larson
Copy link
Owner Author

Biggest reason why

Because we may change rate limits at any time and rate limits can be different per application, rate limits should not be hard coded into your bot/application. In order to properly support our dynamic rate limits, your bot/application should parse for our rate limits in response headers and locally prevent exceeding the limits as they change.

@Andrew-J-Larson
Copy link
Owner Author

This will likely help with checking for rate limits that are active: https://www.codegrepper.com/code-examples/javascript/Check+ratelimit+discord+js

@Andrew-J-Larson
Copy link
Owner Author

Official documentation at https://discord.com/developers/docs/topics/rate-limits

@Andrew-J-Larson
Copy link
Owner Author

Oh, didn't know this, but apparently, Discord.js should be handling the rate-limits... discordjs/discord.js#1637

In any case though, I still need to implement the message queue, as to check when messages aren't going through to attempt resends.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant