Browse Source

Added internal error for if a matching alias cannot be found

tags/1.0-rc
RogueException 8 years ago
parent
commit
0d209b3fdb
1 changed files with 7 additions and 4 deletions
  1. +7
    -4
      src/Discord.Net.Commands/Info/CommandInfo.cs

+ 7
- 4
src/Discord.Net.Commands/Info/CommandInfo.cs 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));
string matchingAlias = "";
var matchingAliases = Aliases.Where(alias => input.StartsWith(alias)).ToArray();
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);


Loading…
Cancel
Save