allows users to add reactions quicklypull/1108/head
| @@ -1,4 +1,4 @@ | |||||
| using System.Threading; | |||||
| using System.Threading; | |||||
| namespace Discord | namespace Discord | ||||
| { | { | ||||
| @@ -22,6 +22,7 @@ namespace Discord | |||||
| internal bool IgnoreState { get; set; } | internal bool IgnoreState { get; set; } | ||||
| internal string BucketId { get; set; } | internal string BucketId { get; set; } | ||||
| internal bool IsClientBucket { get; set; } | internal bool IsClientBucket { get; set; } | ||||
| internal bool IsReactionBucket { get; set; } | |||||
| internal static RequestOptions CreateOrClone(RequestOptions options) | internal static RequestOptions CreateOrClone(RequestOptions options) | ||||
| { | { | ||||
| @@ -583,6 +583,7 @@ namespace Discord.API | |||||
| Preconditions.NotNullOrWhitespace(emoji, nameof(emoji)); | Preconditions.NotNullOrWhitespace(emoji, nameof(emoji)); | ||||
| options = RequestOptions.CreateOrClone(options); | options = RequestOptions.CreateOrClone(options); | ||||
| options.IsReactionBucket = true; | |||||
| var ids = new BucketIds(channelId: channelId); | var ids = new BucketIds(channelId: channelId); | ||||
| @@ -595,6 +596,7 @@ namespace Discord.API | |||||
| Preconditions.NotNullOrWhitespace(emoji, nameof(emoji)); | Preconditions.NotNullOrWhitespace(emoji, nameof(emoji)); | ||||
| options = RequestOptions.CreateOrClone(options); | options = RequestOptions.CreateOrClone(options); | ||||
| options.IsReactionBucket = true; | |||||
| var ids = new BucketIds(channelId: channelId); | var ids = new BucketIds(channelId: channelId); | ||||
| @@ -1,3 +1,4 @@ | |||||
| #define DEBUG_LIMITS | |||||
| using Newtonsoft.Json; | using Newtonsoft.Json; | ||||
| using Newtonsoft.Json.Linq; | using Newtonsoft.Json.Linq; | ||||
| using System; | using System; | ||||
| @@ -250,6 +251,10 @@ namespace Discord.Net.Queue | |||||
| else if (info.Reset.HasValue) | else if (info.Reset.HasValue) | ||||
| { | { | ||||
| resetTick = info.Reset.Value.AddSeconds(info.Lag?.TotalSeconds ?? 1.0); | 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; | int diff = (int)(resetTick.Value - DateTimeOffset.UtcNow).TotalMilliseconds; | ||||
| #if DEBUG_LIMITS | #if DEBUG_LIMITS | ||||
| Debug.WriteLine($"[{id}] X-RateLimit-Reset: {info.Reset.Value.ToUnixTimeSeconds()} ({diff} ms, {info.Lag?.TotalMilliseconds} ms lag)"); | Debug.WriteLine($"[{id}] X-RateLimit-Reset: {info.Reset.Value.ToUnixTimeSeconds()} ({diff} ms, {info.Lag?.TotalMilliseconds} ms lag)"); | ||||