More user friendly error when parsing of a number fails.

This commit is contained in:
Kwoth
2022-08-31 13:40:41 +02:00
parent fb4f470b44
commit cd6fe46c2b

View File

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