diff --git a/src/Services/Update/ScheduledEventUpdateService.cs b/src/Services/Update/ScheduledEventUpdateService.cs index 20d23fa..792eef9 100644 --- a/src/Services/Update/ScheduledEventUpdateService.cs +++ b/src/Services/Update/ScheduledEventUpdateService.cs @@ -286,7 +286,7 @@ public sealed class ScheduledEventUpdateService : BackgroundService }; var contentResult = await _utility.GetEventNotificationMentions( - scheduledEvent, data.Settings, ct); + scheduledEvent, data, ct); if (!contentResult.IsDefined(out var content)) { return Result.FromError(contentResult); @@ -412,7 +412,7 @@ public sealed class ScheduledEventUpdateService : BackgroundService IGuildScheduledEvent scheduledEvent, GuildData data, CancellationToken ct) { var contentResult = await _utility.GetEventNotificationMentions( - scheduledEvent, data.Settings, ct); + scheduledEvent, data, ct); if (!contentResult.IsDefined(out var content)) { return Result.FromError(contentResult); diff --git a/src/Services/UtilityService.cs b/src/Services/UtilityService.cs index b144ca7..5bc06ea 100644 --- a/src/Services/UtilityService.cs +++ b/src/Services/UtilityService.cs @@ -160,16 +160,16 @@ public sealed class UtilityService : IHostedService /// /// The scheduled event whose subscribers will be mentioned. /// - /// The settings of the guild containing the scheduled event + /// The data of the guild containing the scheduled event. /// The cancellation token for this operation. /// A result containing the string which may or may not have succeeded. public async Task> GetEventNotificationMentions( - IGuildScheduledEvent scheduledEvent, JsonNode settings, CancellationToken ct = default) + IGuildScheduledEvent scheduledEvent, GuildData data, CancellationToken ct = default) { var builder = new StringBuilder(); - var role = GuildSettings.EventNotificationRole.Get(settings); + var role = GuildSettings.EventNotificationRole.Get(data.Settings); var subscribersResult = await _eventApi.GetGuildScheduledEventUsersAsync( - scheduledEvent.GuildID, scheduledEvent.ID, withMember: true, ct: ct); + scheduledEvent.GuildID, scheduledEvent.ID, ct: ct); if (!subscribersResult.IsDefined(out var subscribers)) { return Result.FromError(subscribersResult); @@ -181,7 +181,7 @@ public sealed class UtilityService : IHostedService } builder = subscribers.Where( - subscriber => subscriber.GuildMember.IsDefined(out var member) && !member.Roles.Contains(role)) + subscriber => !data.GetOrCreateMemberData(subscriber.User.ID).Roles.Contains(role.Value)) .Aggregate(builder, (current, subscriber) => current.Append($"{Mention.User(subscriber.User)} ")); return builder.ToString(); }