diff --git a/DiscordChatExporter.Core/DiscordChatExporter.Core.csproj b/DiscordChatExporter.Core/DiscordChatExporter.Core.csproj index 7f38c08e..65a04368 100644 --- a/DiscordChatExporter.Core/DiscordChatExporter.Core.csproj +++ b/DiscordChatExporter.Core/DiscordChatExporter.Core.csproj @@ -21,9 +21,9 @@ + - diff --git a/DiscordChatExporter.Core/Services/DataService.cs b/DiscordChatExporter.Core/Services/DataService.cs index eb2668e7..dc5ba1db 100644 --- a/DiscordChatExporter.Core/Services/DataService.cs +++ b/DiscordChatExporter.Core/Services/DataService.cs @@ -8,7 +8,7 @@ using DiscordChatExporter.Core.Exceptions; using DiscordChatExporter.Core.Models; using Newtonsoft.Json.Linq; using DiscordChatExporter.Core.Internal; -using Polly; +using Failsafe; using Tyrrrz.Extensions; namespace DiscordChatExporter.Core.Services @@ -20,13 +20,14 @@ namespace DiscordChatExporter.Core.Services private async Task GetApiResponseAsync(AuthToken token, string resource, string endpoint, params string[] parameters) { - // Create request policy - var policy = Policy - .Handle(e => (int) e.StatusCode == 429) - .WaitAndRetryAsync(10, i => TimeSpan.FromSeconds(0.4)); + // Create retry policy + var retry = Retry.Create() + .Catch(false, e => (int) e.StatusCode == 429) + .WithMaxTryCount(10) + .WithDelay(TimeSpan.FromSeconds(0.4)); // Send request - return await policy.ExecuteAsync(async () => + return await retry.ExecuteAsync(async () => { // Create request const string apiRoot = "https://discordapp.com/api/v6"; diff --git a/Readme.md b/Readme.md index 7756fc33..be8e7582 100644 --- a/Readme.md +++ b/Readme.md @@ -32,8 +32,8 @@ DiscordChatExporter can be used to export message history from a [Discord](https - [MaterialDesignInXamlToolkit](https://github.com/ButchersBoy/MaterialDesignInXamlToolkit) - [Newtonsoft.Json](http://www.newtonsoft.com/json) - [Scriban](https://github.com/lunet-io/scriban) -- [Polly](https://github.com/App-vNext/Polly) -- [Onova](https://github.com/Tyrrrz/Onova) - [CommandLineParser](https://github.com/commandlineparser/commandline) +- [Failsafe](https://github.com/Tyrrrz/Failsafe) +- [Onova](https://github.com/Tyrrrz/Onova) - [Tyrrrz.Extensions](https://github.com/Tyrrrz/Extensions) - [Tyrrrz.Settings](https://github.com/Tyrrrz/Settings)