Added internal error for if a matching alias cannot be found

This commit is contained in:
RogueException
2016-12-18 14:18:33 -04:00
parent 6676a54655
commit 0d209b3fdb

View File

@@ -93,15 +93,18 @@ namespace Discord.Commands
return ParseResult.FromError(preconditionResult.Value); return ParseResult.FromError(preconditionResult.Value);
string input = searchResult.Text; string input = searchResult.Text;
var matchingAliases = Aliases.Where(alias => input.StartsWith(alias)); var matchingAliases = Aliases.Where(alias => input.StartsWith(alias)).ToArray();
string matchingAlias = ""; string matchingAlias = null;
foreach (string alias in matchingAliases) foreach (string alias in matchingAliases)
{ {
if (alias.Length > matchingAlias.Length) if (alias.Length > matchingAlias.Length)
matchingAlias = alias; matchingAlias = alias;
} }
if (matchingAlias == null)
return ParseResult.FromError(CommandError.ParseFailed, "Unable to find matching alias");
input = input.Substring(matchingAlias.Length); input = input.Substring(matchingAlias.Length);
return await CommandParser.ParseArgs(this, context, input, 0).ConfigureAwait(false); return await CommandParser.ParseArgs(this, context, input, 0).ConfigureAwait(false);