|
|
@@ -1,6 +1,10 @@ |
|
|
|
using Discord.API; |
|
|
|
using Discord.Net.Rest; |
|
|
|
using Newtonsoft.Json; |
|
|
|
using System; |
|
|
|
using System.Collections.Generic; |
|
|
|
using System.Globalization; |
|
|
|
using System.IO; |
|
|
|
|
|
|
|
namespace Discord.Net |
|
|
|
{ |
|
|
@@ -25,7 +29,7 @@ namespace Discord.Net |
|
|
|
public DateTimeOffset? Reset { get; } |
|
|
|
|
|
|
|
/// <inheritdoc/> |
|
|
|
public TimeSpan? ResetAfter { get; } |
|
|
|
public TimeSpan? ResetAfter { get; private set; } |
|
|
|
|
|
|
|
/// <inheritdoc/> |
|
|
|
public string Bucket { get; } |
|
|
@@ -56,5 +60,23 @@ namespace Discord.Net |
|
|
|
Lag = headers.TryGetValue("Date", out temp) && |
|
|
|
DateTimeOffset.TryParse(temp, CultureInfo.InvariantCulture, DateTimeStyles.None, out var date) ? DateTimeOffset.UtcNow - date : (TimeSpan?)null; |
|
|
|
} |
|
|
|
|
|
|
|
internal void ReadRatelimitPayload(Stream response) |
|
|
|
{ |
|
|
|
try |
|
|
|
{ |
|
|
|
if (response != null && response.Length != 0) |
|
|
|
{ |
|
|
|
using (TextReader text = new StreamReader(response)) |
|
|
|
using (JsonReader reader = new JsonTextReader(text)) |
|
|
|
{ |
|
|
|
var ratelimit = Discord.Rest.DiscordRestClient.Serializer.Deserialize<Ratelimit>(reader); |
|
|
|
|
|
|
|
ResetAfter = TimeSpan.FromSeconds(ratelimit.RetryAfter); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
catch { } |
|
|
|
} |
|
|
|
} |
|
|
|
} |