Possible fix for 'prune getting stuck after unsuccessful limit hit

This commit is contained in:
Toastie (DCS Team) 2024-07-19 15:23:10 +12:00
parent afa00c8d4f
commit 47c6f9ab03
Signed by: toastie_t0ast
GPG key ID: 27F3B6855AFD40A4

View file

@ -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;