From e283ba5a6d2c226acabd6d7f45a165b2008945cf Mon Sep 17 00:00:00 2001 From: Octol1ttle Date: Sat, 30 Sep 2023 20:50:58 +0500 Subject: [PATCH] Don't forget to remove scheduled event data when notification channel is not set (#133) This PR fixes an issue that caused data of completed/cancelled scheduled events to never be collected if EventNotificationChannel wasn't set --- src/Services/Update/ScheduledEventUpdateService.cs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/Services/Update/ScheduledEventUpdateService.cs b/src/Services/Update/ScheduledEventUpdateService.cs index f9aee51..97f9329 100644 --- a/src/Services/Update/ScheduledEventUpdateService.cs +++ b/src/Services/Update/ScheduledEventUpdateService.cs @@ -317,6 +317,12 @@ public sealed class ScheduledEventUpdateService : BackgroundService private async Task SendScheduledEventCompletedMessage(ScheduledEventData eventData, GuildData data, CancellationToken ct) { + if (GuildSettings.EventNotificationChannel.Get(data.Settings).Empty()) + { + data.ScheduledEvents.Remove(eventData.Id); + return Result.FromSuccess(); + } + var completedEmbed = new EmbedBuilder().WithTitle(string.Format(Messages.EventCompleted, eventData.Name)) .WithDescription( string.Format( @@ -349,6 +355,7 @@ public sealed class ScheduledEventUpdateService : BackgroundService { if (GuildSettings.EventNotificationChannel.Get(data.Settings).Empty()) { + data.ScheduledEvents.Remove(eventData.Id); return Result.FromSuccess(); }