From 47c6f9ab03489b31457e05975e7eea50b9a7d734 Mon Sep 17 00:00:00 2001 From: Toastie Date: Fri, 19 Jul 2024 15:23:10 +1200 Subject: [PATCH] Possible fix for 'prune getting stuck after unsuccessful limit hit --- .../Modules/Administration/Prune/PruneService.cs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/EllieBot/Modules/Administration/Prune/PruneService.cs b/src/EllieBot/Modules/Administration/Prune/PruneService.cs index 753b56b..cad3d01 100644 --- a/src/EllieBot/Modules/Administration/Prune/PruneService.cs +++ b/src/EllieBot/Modules/Administration/Prune/PruneService.cs @@ -26,21 +26,21 @@ public class PruneService : IEService ) { ArgumentNullException.ThrowIfNull(channel, nameof(channel)); + ArgumentOutOfRangeException.ThrowIfNegativeOrZero(amount); var originalAmount = amount; - ArgumentOutOfRangeException.ThrowIfNegativeOrZero(amount); using var cancelSource = new CancellationTokenSource(); if (!_pruningGuilds.TryAdd(channel.GuildId, cancelSource)) return PruneResult.AlreadyRunning; - - if (!await _ps.LimitHitAsync(LimitedFeatureName.Prune, channel.Guild.OwnerId)) - { - return PruneResult.FeatureLimit; - } try { + if (!await _ps.LimitHitAsync(LimitedFeatureName.Prune, channel.Guild.OwnerId)) + { + return PruneResult.FeatureLimit; + } + var now = DateTime.UtcNow; IMessage[] msgs; IMessage lastMessage = null;