Fixes RetryMode.RetryRatelimit being ignored (#1036)
This commit is contained in:
committed by
Christopher F
parent
b8b59d97ae
commit
c618cb3ccd
@@ -163,7 +163,7 @@ namespace Discord.Net.Queue
|
||||
if (!isRateLimited)
|
||||
throw new TimeoutException();
|
||||
else
|
||||
throw new RateLimitedException(request);
|
||||
ThrowRetryLimit(request);
|
||||
}
|
||||
|
||||
lock (_lock)
|
||||
@@ -181,13 +181,12 @@ namespace Discord.Net.Queue
|
||||
await _queue.RaiseRateLimitTriggered(Id, null).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
if ((request.Options.RetryMode & RetryMode.RetryRatelimit) == 0)
|
||||
throw new RateLimitedException(request);
|
||||
ThrowRetryLimit(request);
|
||||
|
||||
if (resetAt.HasValue)
|
||||
{
|
||||
if (resetAt > timeoutAt)
|
||||
throw new RateLimitedException(request);
|
||||
ThrowRetryLimit(request);
|
||||
int millis = (int)Math.Ceiling((resetAt.Value - DateTimeOffset.UtcNow).TotalMilliseconds);
|
||||
#if DEBUG_LIMITS
|
||||
Debug.WriteLine($"[{id}] Sleeping {millis} ms (Pre-emptive)");
|
||||
@@ -198,7 +197,7 @@ namespace Discord.Net.Queue
|
||||
else
|
||||
{
|
||||
if ((timeoutAt.Value - DateTimeOffset.UtcNow).TotalMilliseconds < 500.0)
|
||||
throw new RateLimitedException(request);
|
||||
ThrowRetryLimit(request);
|
||||
#if DEBUG_LIMITS
|
||||
Debug.WriteLine($"[{id}] Sleeping 500* ms (Pre-emptive)");
|
||||
#endif
|
||||
@@ -309,5 +308,11 @@ namespace Discord.Net.Queue
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void ThrowRetryLimit(RestRequest request)
|
||||
{
|
||||
if ((request.Options.RetryMode & RetryMode.RetryRatelimit) == 0)
|
||||
throw new RateLimitedException(request);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user