Added internal error for if a matching alias cannot be found
This commit is contained in:
@@ -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);
|
||||||
|
|||||||
Reference in New Issue
Block a user