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:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user