From fa25efa2161e9550b7b1fe00ef1269759a776278 Mon Sep 17 00:00:00 2001 From: Oliver Booth Date: Wed, 8 Mar 2023 11:42:28 +0000 Subject: [PATCH 1/2] Merge branch 'hotfix/duration_sum' into develop --- Hammer/Commands/Infractions/InfractionCommand.Stats.cs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/Hammer/Commands/Infractions/InfractionCommand.Stats.cs b/Hammer/Commands/Infractions/InfractionCommand.Stats.cs index 5c99549..23170b3 100644 --- a/Hammer/Commands/Infractions/InfractionCommand.Stats.cs +++ b/Hammer/Commands/Infractions/InfractionCommand.Stats.cs @@ -54,13 +54,14 @@ public async Task StatsAsync(InteractionContext context) int banCount = infractions.Count(i => i.Type is InfractionType.Ban); var bans = $"{banCount + tempBanCount} ({tempBanCount}T / {banCount}P)"; - long totalMuteDuration = _muteService.GetTemporaryMutes(context.Guild).Sum(m => m.ExpiresAt!.Value.Ticks); - long totalBanDuration = _banService.GetTemporaryBans(context.Guild).Sum(m => m.ExpiresAt.Ticks); + DateTimeOffset now = DateTimeOffset.UtcNow; + long remainingMuteDuration = _muteService.GetTemporaryMutes(context.Guild).Sum(m => (now - m.ExpiresAt!.Value).Ticks); + long remainingBanDuration = _banService.GetTemporaryBans(context.Guild).Sum(b => (now - b.ExpiresAt).Ticks); embed.WithTitle("Infraction Statistics"); embed.AddField("Total Infractions", totalInfractions.ToString("N0"), true); - embed.AddField("Total Mute Duration", TimeSpan.FromTicks(totalMuteDuration).Humanize(), true); - embed.AddField("Total Ban Duration", TimeSpan.FromTicks(totalBanDuration).Humanize(), true); + embed.AddField("Remaining Mute Duration", TimeSpan.FromTicks(remainingMuteDuration).Humanize(), true); + embed.AddField("Remaining Ban Duration", TimeSpan.FromTicks(remainingBanDuration).Humanize(), true); embed.AddField("Total Infracted Users", infractedUsers.ToString("N0"), true); embed.AddField("Total Warned Users", warnedUsers.ToString("N0"), true); From 0c814830b0f251bff335646d9eb94413f31c936f Mon Sep 17 00:00:00 2001 From: Oliver Booth Date: Wed, 8 Mar 2023 11:42:41 +0000 Subject: [PATCH 2/2] Bump to 5.0.1 --- Hammer/Hammer.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Hammer/Hammer.csproj b/Hammer/Hammer.csproj index bcb84b3..9b83dc4 100644 --- a/Hammer/Hammer.csproj +++ b/Hammer/Hammer.csproj @@ -6,7 +6,7 @@ enable enable Linux - 5.0.0 + 5.0.1