feat: add a control for rate limiting - #13
Conversation
gtuk
left a comment
There was a problem hiding this comment.
@TheFiordi Thanks for your PR, really appreciated. I left some comment
| Content *string `json:"content,omitempty"` | ||
| Embeds *[]Embed `json:"embeds,omitempty"` | ||
| AllowedMentions *AllowedMentions `json:"allowed_mentions,omitempty"` | ||
| Timestamp *time.Time `json:"timestamp,omitempty"` |
There was a problem hiding this comment.
What is the exact purpose of this new field?
There was a problem hiding this comment.
Oops my bad I left it there, it should be moved in type embed struct {}, see #12
There was a problem hiding this comment.
As this is not relevant for this MR i would remove it completely for now
|
Hi, I removed the timestamp from the type.go file, added a comment and handled the resp.Body.Close() better. |
|
As this is MR is about enhancing the the docs / examples, I would suggest to move the Rate limit aware example into a separate example function e.g SendMessageRateLimitAware or something similar and leave the basic example as it is as this is not really necessary for people who want to use the library in a really basic way |
Good morning, Discord implements a system for rate limiting post requests to webhooks end point, if the EP is hit too many times too fast it will block the requests and the messages sent are lost, if an ip is repeatedly rate limited discord will ban the IP.
Discord answers with the following headers:
doc: https://discord.com/developers/docs/topics/rate-limits
I'm proposing to use the X-RateLimit-Reset-After to wait for the rate limit to be reset before sending another request.
This is a naive approach as the rate limits are per webhook and not global (there's also a global rate limit but afaik is only for bots).
I'm very open to any criticism or suggestion as this is what I'm using for my application.
Also, this is my very first pull request!!