mirror of
https://gitlab.com/Kwoth/nadekobot.git
synced 2025-09-11 17:58:26 -04:00
More user friendly error when parsing of a number fails.
This commit is contained in:
@@ -279,6 +279,7 @@ public class CommandHandler : INService, IReadyExecutor
|
|||||||
// if it errored
|
// if it errored
|
||||||
if (error is not null)
|
if (error is not null)
|
||||||
{
|
{
|
||||||
|
error = HumanizeError(error);
|
||||||
LogErroredExecution(error, usrMsg, channel as ITextChannel, blockTime, startTime);
|
LogErroredExecution(error, usrMsg, channel as ITextChannel, blockTime, startTime);
|
||||||
|
|
||||||
if (guild is not null)
|
if (guild is not null)
|
||||||
@@ -292,6 +293,15 @@ public class CommandHandler : INService, IReadyExecutor
|
|||||||
await _behaviorHandler.RunOnNoCommandAsync(guild, usrMsg);
|
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(
|
public Task<(bool Success, string Error, CommandInfo Info)> ExecuteCommandAsync(
|
||||||
CommandContext context,
|
CommandContext context,
|
||||||
string input,
|
string input,
|
||||||
|
Reference in New Issue
Block a user