Ability to ignore unused parameters instead of failing the command. (#915)

* Addition of FailOnTooManyArgs

* Correct name & only pass in bool
This commit is contained in:
vim2meta
2018-01-05 15:02:27 -05:00
committed by Christopher F
parent 5ce85deb9d
commit 5f46aef3a7
4 changed files with 15 additions and 4 deletions

View File

@@ -14,7 +14,7 @@ namespace Discord.Commands
QuotedParameter
}
public static async Task<ParseResult> ParseArgsAsync(CommandInfo command, ICommandContext context, IServiceProvider services, string input, int startPos)
public static async Task<ParseResult> ParseArgsAsync(CommandInfo command, ICommandContext context, bool ignoreExtraArgs, IServiceProvider services, string input, int startPos)
{
ParameterInfo curParam = null;
StringBuilder argBuilder = new StringBuilder(input.Length);
@@ -109,7 +109,12 @@ namespace Discord.Commands
if (argString != null)
{
if (curParam == null)
return ParseResult.FromError(CommandError.BadArgCount, "The input text has too many parameters.");
{
if (ignoreExtraArgs)
break;
else
return ParseResult.FromError(CommandError.BadArgCount, "The input text has too many parameters.");
}
var typeReaderResult = await curParam.ParseAsync(context, argString, services).ConfigureAwait(false);
if (!typeReaderResult.IsSuccess && typeReaderResult.Error != CommandError.MultipleMatches)