From 7d6a7f159bf0d96e548b9d135b02c78f9a51a04f Mon Sep 17 00:00:00 2001 From: Toastie Date: Fri, 19 Jul 2024 15:26:45 +1200 Subject: [PATCH] Show a message when 'prune fails due to already running error --- .../Administration/Prune/PruneCommands.cs | 39 +++++++++++-------- .../strings/responses/responses.en-US.json | 1 + 2 files changed, 23 insertions(+), 17 deletions(-) diff --git a/src/EllieBot/Modules/Administration/Prune/PruneCommands.cs b/src/EllieBot/Modules/Administration/Prune/PruneCommands.cs index 2317bf0..5ebafab 100644 --- a/src/EllieBot/Modules/Administration/Prune/PruneCommands.cs +++ b/src/EllieBot/Modules/Administration/Prune/PruneCommands.cs @@ -65,23 +65,6 @@ public partial class Administration await progressMsg.DeleteAsync(); } - private async Task SendResult(PruneResult result) - { - switch (result) - { - case PruneResult.Success: - break; - case PruneResult.AlreadyRunning: - break; - case PruneResult.FeatureLimit: - await Response().Pending(strs.feature_limit_reached_owner).SendAsync(); - break; - - default: - throw new ArgumentOutOfRangeException(nameof(result), result, null); - } - } - // prune x [Cmd] [RequireContext(ContextType.Guild)] @@ -218,5 +201,27 @@ public partial class Administration await Response().Confirm(strs.prune_cancelled).SendAsync(); } + + + private async Task SendResult(PruneResult result) + { + switch (result) + { + case PruneResult.Success: + break; + case PruneResult.AlreadyRunning: + var msg = await Response().Pending(strs.prune_already_running).SendAsync(); + msg.DeleteAfter(5); + break; + case PruneResult.FeatureLimit: + var msg2 = await Response().Pending(strs.feature_limit_reached_owner).SendAsync(); + msg2.DeleteAfter(10); + break; + default: + Log.Error("Unhandled result received in prune: {Result}", result); + await Response().Error(strs.error_occured).SendAsync(); + break; + } + } } } \ No newline at end of file diff --git a/src/EllieBot/data/strings/responses/responses.en-US.json b/src/EllieBot/data/strings/responses/responses.en-US.json index 37231cf..c7d5b7a 100644 --- a/src/EllieBot/data/strings/responses/responses.en-US.json +++ b/src/EllieBot/data/strings/responses/responses.en-US.json @@ -38,6 +38,7 @@ "prune_cancelled": "Pruning was cancelled.", "prune_not_found": "No active prune was found on this server.", "prune_progress": "Pruning... {0}/{1} messages deleted.", + "prune_already_running": "A prune is already running on this server.", "timeoutdm": "You have been timed out in {0} server.\nReason: {1}", "timedout_user": "User Timed Out", "remove_roles_pl": "have had their roles removed",