diff --git a/src/Miha.Discord/Services/Hosted/GuildEventScheduleService.cs b/src/Miha.Discord/Services/Hosted/GuildEventScheduleService.cs index 6484cc8..57ecb68 100644 --- a/src/Miha.Discord/Services/Hosted/GuildEventScheduleService.cs +++ b/src/Miha.Discord/Services/Hosted/GuildEventScheduleService.cs @@ -3,6 +3,7 @@ using Discord; using Discord.Addons.Hosting; using Discord.Addons.Hosting.Util; +using Discord.Net; using Discord.WebSocket; using Humanizer; using Microsoft.Extensions.Logging; @@ -53,7 +54,18 @@ protected override async Task ExecuteAsync(CancellationToken stoppingToken) while (!stoppingToken.IsCancellationRequested) { - await PostWeeklyScheduleAsync(); + try + { + await PostWeeklyScheduleAsync(); + } + catch (HttpException e) + { + _logger.LogWarning(e, "Discord dotnet http exception caught, likely caused by rate-limits, waiting a few minutes before continuing"); + + await Task.Delay(TimeSpan.FromMinutes(3), stoppingToken); + + continue; + } var utcNow = _easternStandardZonedClock.GetCurrentInstant().ToDateTimeUtc(); var nextUtc = _cron.GetNextOccurrence(DateTimeOffset.UtcNow, _easternStandardZonedClock.GetTimeZoneInfo());