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
This commit is contained in:
Octol1ttle 2023-09-30 20:50:58 +05:00 committed by GitHub
parent f3da876d6d
commit e283ba5a6d
Signed by: GitHub
GPG key ID: 4AEE18F83AFDEB23

View file

@ -317,6 +317,12 @@ public sealed class ScheduledEventUpdateService : BackgroundService
private async Task<Result> 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();
}