diff --git a/Present/Data/ValueConverters/UInt64ListToBytesConverter.cs b/Present/Data/ValueConverters/UInt64ListToBytesConverter.cs index 8346d06..b8bb135 100644 --- a/Present/Data/ValueConverters/UInt64ListToBytesConverter.cs +++ b/Present/Data/ValueConverters/UInt64ListToBytesConverter.cs @@ -31,7 +31,7 @@ private static List FromBytes(byte[] bytes) var list = new List(listCount); - for (var index = 0; index < list.Count; index++) + for (var index = 0; index < listCount; index++) list.Add(reader.ReadUInt64()); return list; diff --git a/Present/Present.csproj b/Present/Present.csproj index 2d92b80..ee1abe1 100644 --- a/Present/Present.csproj +++ b/Present/Present.csproj @@ -6,7 +6,7 @@ enable enable Linux - 1.0.0 + 1.1.0 @@ -28,22 +28,22 @@ - - - - + + + + all runtime; build; native; contentfiles; analyzers; buildtransitive - - - - - - - - + + + + + + + + diff --git a/Present/Services/GiveawayService.cs b/Present/Services/GiveawayService.cs index 804f43f..03d6a23 100644 --- a/Present/Services/GiveawayService.cs +++ b/Present/Services/GiveawayService.cs @@ -1,4 +1,4 @@ -using System.Collections.Concurrent; +using System.Collections.Concurrent; using System.Diagnostics.CodeAnalysis; using CSharpVitamins; using DSharpPlus; @@ -201,7 +201,7 @@ public DiscordEmbedBuilder CreateGiveawayInformationEmbed(Giveaway giveaway) List winnerIds = giveaway.WinnerIds; if (winnerIds.Count > 0) { - string winnerList = string.Join('\n', giveaway.WinnerIds.Select(w => $"• {MentionUtility.MentionUser(w)} ({w})")); + string winnerList = string.Join('\n', winnerIds.Select(w => $"• {MentionUtility.MentionUser(w)} ({w})")); embed.AddField(EmbedStrings.Winner.ToQuantity(winnerIds.Count), winnerList); } @@ -268,6 +268,8 @@ public DiscordEmbed CreateGiveawayPublicEmbed(Giveaway giveaway) /// is . public async Task EndGiveawayAsync(Giveaway giveaway) { + ArgumentNullException.ThrowIfNull(giveaway); + giveaway.EndHandled = true; giveaway.EndTime = DateTimeOffset.UtcNow; @@ -656,6 +658,8 @@ public bool ValidateUser(ulong userId, DiscordGuild guild, [NotNullWhen(true)] o private async Task UpdateFromDatabaseAsync(CancellationToken cancellationToken) { + Logger.Info("Caching giveaways from the database..."); + await using AsyncServiceScope scope = _serviceScopeFactory.CreateAsyncScope(); await using var context = scope.ServiceProvider.GetRequiredService(); await context.Database.EnsureCreatedAsync(cancellationToken: cancellationToken).ConfigureAwait(false);