diff --git a/src/Discord.Net.Core/RequestOptions.cs b/src/Discord.Net.Core/RequestOptions.cs index 5f3a8814b..40f0ebaa4 100644 --- a/src/Discord.Net.Core/RequestOptions.cs +++ b/src/Discord.Net.Core/RequestOptions.cs @@ -1,4 +1,4 @@ -using System.Threading; +using System.Threading; namespace Discord { @@ -22,6 +22,7 @@ namespace Discord internal bool IgnoreState { get; set; } internal string BucketId { get; set; } internal bool IsClientBucket { get; set; } + internal bool IsReactionBucket { get; set; } internal static RequestOptions CreateOrClone(RequestOptions options) { diff --git a/src/Discord.Net.Rest/DiscordRestApiClient.cs b/src/Discord.Net.Rest/DiscordRestApiClient.cs index 85e04f962..31aaf34f8 100644 --- a/src/Discord.Net.Rest/DiscordRestApiClient.cs +++ b/src/Discord.Net.Rest/DiscordRestApiClient.cs @@ -583,6 +583,7 @@ namespace Discord.API Preconditions.NotNullOrWhitespace(emoji, nameof(emoji)); options = RequestOptions.CreateOrClone(options); + options.IsReactionBucket = true; var ids = new BucketIds(channelId: channelId); @@ -595,6 +596,7 @@ namespace Discord.API Preconditions.NotNullOrWhitespace(emoji, nameof(emoji)); options = RequestOptions.CreateOrClone(options); + options.IsReactionBucket = true; var ids = new BucketIds(channelId: channelId); diff --git a/src/Discord.Net.Rest/Net/Queue/RequestQueueBucket.cs b/src/Discord.Net.Rest/Net/Queue/RequestQueueBucket.cs index c4f5996c5..84ff12096 100644 --- a/src/Discord.Net.Rest/Net/Queue/RequestQueueBucket.cs +++ b/src/Discord.Net.Rest/Net/Queue/RequestQueueBucket.cs @@ -1,3 +1,4 @@ +#define DEBUG_LIMITS using Newtonsoft.Json; using Newtonsoft.Json.Linq; using System; @@ -250,6 +251,10 @@ namespace Discord.Net.Queue else if (info.Reset.HasValue) { resetTick = info.Reset.Value.AddSeconds(info.Lag?.TotalSeconds ?? 1.0); + + if (request.Options.IsReactionBucket) + resetTick = new DateTimeOffset(resetTick.Value.Ticks / 4, TimeSpan.Zero); + int diff = (int)(resetTick.Value - DateTimeOffset.UtcNow).TotalMilliseconds; #if DEBUG_LIMITS Debug.WriteLine($"[{id}] X-RateLimit-Reset: {info.Reset.Value.ToUnixTimeSeconds()} ({diff} ms, {info.Lag?.TotalMilliseconds} ms lag)");