From cd6fe46c2bd1f779eec9290610d01bd20b6c7260 Mon Sep 17 00:00:00 2001 From: Kwoth Date: Wed, 31 Aug 2022 13:40:41 +0200 Subject: [PATCH] More user friendly error when parsing of a number fails. --- src/NadekoBot/Services/CommandHandler.cs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/NadekoBot/Services/CommandHandler.cs b/src/NadekoBot/Services/CommandHandler.cs index 1bb4d30ab..2054b7ee4 100644 --- a/src/NadekoBot/Services/CommandHandler.cs +++ b/src/NadekoBot/Services/CommandHandler.cs @@ -279,6 +279,7 @@ public class CommandHandler : INService, IReadyExecutor // if it errored if (error is not null) { + error = HumanizeError(error); LogErroredExecution(error, usrMsg, channel as ITextChannel, blockTime, startTime); if (guild is not null) @@ -292,6 +293,15 @@ public class CommandHandler : INService, IReadyExecutor await _behaviorHandler.RunOnNoCommandAsync(guild, usrMsg); } + private string HumanizeError(string error) + { + if (error.Contains("parse int", StringComparison.OrdinalIgnoreCase) + || error.Contains("parse float")) + return "Invalid number specified. Make sure you're specifying parameters in the correct order."; + + return error; + } + public Task<(bool Success, string Error, CommandInfo Info)> ExecuteCommandAsync( CommandContext context, string input,