feature: Add support for setting X-RateLimit-Precision (#1354)
* support X-RateLimit-Reset sending integer or float values This changes the way that the X-RateLimit-Request header is parsed, so that it will work with both integer seconds and float values with seconds and milliseconds * Add RateLimitPrecision enum, set X-RateLimit-Precision Adds the RateLimitPrecision enum, with Second and Millisecond values. (Do we want to use an extension method to convert it into a string, or is ToString().ToLower() fine?) Adds RateLimitPrecision as a parameter to DiscordRestApiClient, and to DiscordConfig so that it can set the X-RateLimit-Precision header.
This commit is contained in:
committed by
Christopher F
parent
07f4d5f353
commit
9482204bcf
@@ -21,7 +21,7 @@ namespace Discord.Net
|
||||
Remaining = headers.TryGetValue("X-RateLimit-Remaining", out temp) &&
|
||||
int.TryParse(temp, out var remaining) ? remaining : (int?)null;
|
||||
Reset = headers.TryGetValue("X-RateLimit-Reset", out temp) &&
|
||||
int.TryParse(temp, out var reset) ? DateTimeOffset.FromUnixTimeSeconds(reset) : (DateTimeOffset?)null;
|
||||
float.TryParse(temp, out var reset) ? DateTimeOffset.FromUnixTimeMilliseconds((long)(reset * 1000)) : (DateTimeOffset?)null;
|
||||
RetryAfter = headers.TryGetValue("Retry-After", out temp) &&
|
||||
int.TryParse(temp, out var retryAfter) ? retryAfter : (int?)null;
|
||||
Lag = headers.TryGetValue("Date", out temp) &&
|
||||
|
||||
Reference in New Issue
Block a user