private static async Task UpdateStarGivenInternalAsync(StarboardContext context, IUser starGivingUser, bool starGiven) { context.GetOrAddMessageData(); if (starGivingUser.Id == (await context.GetStarredMessageAsync()).Author.Id) { await context.RemoveReactionAsync(starGivingUser); return; } if (starGiven) { if (!context.MessageData.StarGivingUsers.AddOrUpdate(starGivingUser.Id, context.Source, StarboardSource.STARRED_MESSAGE)) { await context.RemoveReactionFromStarboardMessageAsync(starGivingUser); } } else { context.MessageData.StarGivingUsers.Remove(starGivingUser.Id, context.Source); } await CreateOrUpdateStarboardMessage(context); }
private static async Task UpdateStarsGivenInternalAsync(StarboardContext context, StarboardSource source, IAsyncEnumerable <IReadOnlyCollection <IUser> > starGivingUsers) { await starGivingUsers.ForEachAsync(async users => { foreach (IUser user in users) { if (user.Id != context.StarredMessage.Author.Id) { if (!context.MessageData.StarGivingUsers.AddOrUpdate(user.Id, source, StarboardSource.STARRED_MESSAGE)) { await context.RemoveReactionFromStarboardMessageAsync(user); } } else { await context.RemoveReactionAsync(user, source); } } }); }