mirror of
https://github.com/Tyrrrz/DiscordChatExporter.git
synced 2026-04-24 06:54:44 +00:00
Fix nullability errors
This commit is contained in:
20
DiscordChatExporter.Core/Utils/Extensions/JsonExtensions.cs
Normal file
20
DiscordChatExporter.Core/Utils/Extensions/JsonExtensions.cs
Normal file
@@ -0,0 +1,20 @@
|
||||
using System;
|
||||
using System.Text.Json;
|
||||
|
||||
namespace DiscordChatExporter.Core.Utils.Extensions
|
||||
{
|
||||
public static class JsonExtensions
|
||||
{
|
||||
public static string GetNonWhiteSpaceString(this JsonElement json)
|
||||
{
|
||||
if (json.ValueKind != JsonValueKind.String)
|
||||
throw new FormatException();
|
||||
|
||||
var value = json.GetString();
|
||||
if (string.IsNullOrWhiteSpace(value))
|
||||
throw new FormatException();
|
||||
|
||||
return value;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -33,7 +33,7 @@ namespace DiscordChatExporter.Core.Utils
|
||||
// on the very first request.
|
||||
if (i > 3)
|
||||
{
|
||||
var retryAfterDelay = result.Result.Headers.RetryAfter.Delta;
|
||||
var retryAfterDelay = result.Result.Headers.RetryAfter?.Delta;
|
||||
if (retryAfterDelay is not null)
|
||||
return retryAfterDelay.Value + TimeSpan.FromSeconds(1); // margin just in case
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user