Commit graph

4 commits

Author SHA1 Message Date
Necroforger
013faa1da4 Hardcoded reactions ratelimit (#398)
* add custom ratelimits

* check for nil ratelimiter

* Don't expose custom ratelimits to Session

* attempt to fix race conditions

* use defer instead

* Slightly improved ratelimiter

You shouldn't need to change the ratelimiters ratelimits while its
running so I removed the functions SetCustomRatelimit and
RemoveCustomRatelimit.
2017-07-29 07:53:02 -07:00
jonas747
c26f14d3b6 Replace global ratelimit bucket with atomic (#343) 2017-03-26 19:46:34 -10:00
AI
982cd7d7c3 Add support for the prune endpoint (#282)
* Add support for the prune endpoint

Adds functions to get the amount of members that could be pruned
and to prune members using the prune endpoint.
May close: bwmarrin/discordgo#147

* Deal with the go vet error

Removed the json tags from the unexported struct.
Should pass the tests now.

* Make the PR consistent with the rest of the file.

Removes url building in favour of string concatenation.

* Fix the previous commit

Adds back the result struct.
Converts the uint32 to string.

* Deal with golint comments

* Remove the failing test

Cleans up the uri concatenation.
Removes the failing test due to incorrect permissions.
2016-11-07 16:06:08 -08:00
jonas747
56b19073d3 Ratelimits (#273)
* Added ratelimiter

Handles the new ratelimit headers
 - X-RateLimit-Remaining
 - X-RateLimit-Reset
 - X-RateLimit-Global

* Pad only reset time with a second

* Moved ratelimiter out of internal package

* Change for loop, move global ratelimit check inside sleep check

* Moved ratelimiter locking to getBucket

* Added global bucket

* Changed how bucket id's are done

Now each request function will need to specify the bucket id if the
endpoint contains minor variables

* Allow empty bucketID in request

* Remove some uneeded Endpoint* function calls

* Added test for global ratelimits

* Fixed a silly little mistake causing incorrect ratelimits

* Update test comments, Fixed treating a endpoint as 2 in ratelimiting

* Use date header from discord instead of relying on sys time sync

* Update all REST functions to use RequestWithBucketID

* Embed mutex into bucket

* Added webhook and reaction buckets
2016-11-04 08:07:22 -07:00