From 7a14991ed62ffb10d8735f1bca7de1cdcf54c321 Mon Sep 17 00:00:00 2001 From: Kwoth Date: Thu, 18 Jul 2024 13:20:07 +0000 Subject: [PATCH] fix: 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/NadekoBot/Modules/Administration/Prune/PruneService.cs b/src/NadekoBot/Modules/Administration/Prune/PruneService.cs index f2796a72b..4708e18bd 100644 --- a/src/NadekoBot/Modules/Administration/Prune/PruneService.cs +++ b/src/NadekoBot/Modules/Administration/Prune/PruneService.cs @@ -26,21 +26,21 @@ public class PruneService : INService ) { 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;