diff --git a/DeukBot4/Database/BirthdayHandler.cs b/DeukBot4/Database/BirthdayHandler.cs index a22fb67..0fbf570 100644 --- a/DeukBot4/Database/BirthdayHandler.cs +++ b/DeukBot4/Database/BirthdayHandler.cs @@ -81,30 +81,32 @@ namespace DeukBot4.Database } private static DateTime _lastCheckedDate; - // ReSharper disable once FunctionRecursiveOnAllPaths public static async Task CheckBirthdays() { - var today = DateTime.UtcNow.Date - new TimeSpan(6, 0 , 0); - while (!Program.IsConnected) + while (true) { - await Task.Delay(500); - } - try - { - if (today != _lastCheckedDate) + try { - _lastCheckedDate = today; - var db = Redis.GetDatabase(); - db.StringSet("lastCheckedBirthday", _lastCheckedDate.ToBinary().ToString("D")); - await ActualBirthdayCheck(today); + var today = DateTime.UtcNow - new TimeSpan(6, 0, 0); + while (!Program.IsConnected) + { + await Task.Delay(500); + } + + if (today.Date != _lastCheckedDate) + { + _lastCheckedDate = today.Date; + var db = Redis.GetDatabase(); + db.StringSet("lastCheckedBirthday", _lastCheckedDate.ToBinary().ToString("D")); + await ActualBirthdayCheck(today); + } } + catch (Exception e) + { + Logger.Main.LogError(e); + } + await Task.Delay(TimeSpan.FromHours(1)); } - catch (Exception e) - { - Logger.Main.LogError(e); - } - await Task.Delay(TimeSpan.FromHours(1)); - await CheckBirthdays(); }