diff --git a/src/Miha.Discord/Miha.Discord.csproj b/src/Miha.Discord/Miha.Discord.csproj
index f89e1f6..d4a29cd 100644
--- a/src/Miha.Discord/Miha.Discord.csproj
+++ b/src/Miha.Discord/Miha.Discord.csproj
@@ -10,10 +10,10 @@
-
+
-
-
+
+
diff --git a/src/Miha.Discord/Services/Hosted/GuildEventMonitorService.cs b/src/Miha.Discord/Services/Hosted/GuildEventMonitorService.cs
index 4f29708..7e719f1 100644
--- a/src/Miha.Discord/Services/Hosted/GuildEventMonitorService.cs
+++ b/src/Miha.Discord/Services/Hosted/GuildEventMonitorService.cs
@@ -36,28 +36,37 @@ public partial class GuildEventMonitorService(
protected override async Task ExecuteAsync(CancellationToken stoppingToken)
{
_logger.LogInformation("Waiting for client to be ready...");
-
+
await Client.WaitForReadyAsync(stoppingToken);
while (!stoppingToken.IsCancellationRequested)
{
- await CheckScheduledEventsAsync();
+ try
+ {
+ await CheckScheduledEventsAsync();
+
+ var utcNow = easternStandardZonedClock.GetCurrentInstant().ToDateTimeUtc();
+ var nextUtc = _cron.GetNextOccurrence(DateTimeOffset.UtcNow, easternStandardZonedClock.GetTimeZoneInfo());
+
+ if (nextUtc is null)
+ {
+ _logger.LogWarning("Next utc occurence is null");
+ await Task.Delay(TimeSpan.FromMinutes(1), stoppingToken);
+ continue;
+ }
+
+ var next = nextUtc.Value - utcNow;
- var utcNow = easternStandardZonedClock.GetCurrentInstant().ToDateTimeUtc();
- var nextUtc = _cron.GetNextOccurrence(DateTimeOffset.UtcNow, easternStandardZonedClock.GetTimeZoneInfo());
+ _logger.LogDebug("Waiting {Time} until next operation", next.Humanize(3));
- if (nextUtc is null)
+ await Task.Delay(nextUtc.Value - utcNow, stoppingToken);
+ }
+ catch (Exception e)
{
- _logger.LogWarning("Next utc occurence is null");
+ _logger.LogError(e, "Exception encountered in GuildEventMonitorService");
+
await Task.Delay(TimeSpan.FromMinutes(1), stoppingToken);
- continue;
}
-
- var next = nextUtc.Value - utcNow;
-
- _logger.LogDebug("Waiting {Time} until next operation", next.Humanize(3));
-
- await Task.Delay(nextUtc.Value - utcNow, stoppingToken);
}
}
diff --git a/src/Miha.Logic/Miha.Logic.csproj b/src/Miha.Logic/Miha.Logic.csproj
index e360038..7c538a2 100644
--- a/src/Miha.Logic/Miha.Logic.csproj
+++ b/src/Miha.Logic/Miha.Logic.csproj
@@ -9,7 +9,7 @@
-
+
diff --git a/src/Miha.Redis/Miha.Redis.csproj b/src/Miha.Redis/Miha.Redis.csproj
index 67b4255..d471518 100644
--- a/src/Miha.Redis/Miha.Redis.csproj
+++ b/src/Miha.Redis/Miha.Redis.csproj
@@ -10,7 +10,7 @@
-
+
diff --git a/src/Miha.Shared/Miha.Shared.csproj b/src/Miha.Shared/Miha.Shared.csproj
index e436505..a006c4c 100644
--- a/src/Miha.Shared/Miha.Shared.csproj
+++ b/src/Miha.Shared/Miha.Shared.csproj
@@ -17,13 +17,13 @@
-
+
-
+
-
+