| @@ -14,7 +14,7 @@ namespace Discord.Commands | |||||
| QuotedParameter | QuotedParameter | ||||
| } | } | ||||
| public static async Task<ParseResult> ParseArgsAsync(CommandInfo command, ICommandContext context, CommandService commandService, 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; | ParameterInfo curParam = null; | ||||
| StringBuilder argBuilder = new StringBuilder(input.Length); | StringBuilder argBuilder = new StringBuilder(input.Length); | ||||
| @@ -110,10 +110,10 @@ namespace Discord.Commands | |||||
| { | { | ||||
| if (curParam == null) | if (curParam == null) | ||||
| { | { | ||||
| if (commandService._failOnTooManyArgs) | |||||
| return ParseResult.FromError(CommandError.BadArgCount, "The input text has too many parameters."); | |||||
| else | |||||
| if (ignoreExtraArgs) | |||||
| break; | break; | ||||
| else | |||||
| return ParseResult.FromError(CommandError.BadArgCount, "The input text has too many parameters."); | |||||
| } | } | ||||
| var typeReaderResult = await curParam.ParseAsync(context, argString, services).ConfigureAwait(false); | var typeReaderResult = await curParam.ParseAsync(context, argString, services).ConfigureAwait(false); | ||||
| @@ -27,7 +27,7 @@ namespace Discord.Commands | |||||
| private readonly HashSet<ModuleInfo> _moduleDefs; | private readonly HashSet<ModuleInfo> _moduleDefs; | ||||
| private readonly CommandMap _map; | private readonly CommandMap _map; | ||||
| internal readonly bool _caseSensitive, _throwOnError, _failOnTooManyArgs; | |||||
| internal readonly bool _caseSensitive, _throwOnError, _ignoreExtraArgs; | |||||
| internal readonly char _separatorChar; | internal readonly char _separatorChar; | ||||
| internal readonly RunMode _defaultRunMode; | internal readonly RunMode _defaultRunMode; | ||||
| internal readonly Logger _cmdLogger; | internal readonly Logger _cmdLogger; | ||||
| @@ -42,7 +42,7 @@ namespace Discord.Commands | |||||
| { | { | ||||
| _caseSensitive = config.CaseSensitiveCommands; | _caseSensitive = config.CaseSensitiveCommands; | ||||
| _throwOnError = config.ThrowOnError; | _throwOnError = config.ThrowOnError; | ||||
| _failOnTooManyArgs = config.FailOnTooManyArgs; | |||||
| _ignoreExtraArgs = config.IgnoreExtraArgs; | |||||
| _separatorChar = config.SeparatorChar; | _separatorChar = config.SeparatorChar; | ||||
| _defaultRunMode = config.DefaultRunMode; | _defaultRunMode = config.DefaultRunMode; | ||||
| if (_defaultRunMode == RunMode.Default) | if (_defaultRunMode == RunMode.Default) | ||||
| @@ -16,7 +16,7 @@ | |||||
| /// <summary> Determines whether RunMode.Sync commands should push exceptions up to the caller. </summary> | /// <summary> Determines whether RunMode.Sync commands should push exceptions up to the caller. </summary> | ||||
| public bool ThrowOnError { get; set; } = true; | public bool ThrowOnError { get; set; } = true; | ||||
| /// <summary> Determines whether the command execution should fail if too many parameters are provided. </summary> | |||||
| public bool FailOnTooManyArgs { get; set; } = true; | |||||
| /// <summary> Determines whether extra parameters should be ignored. </summary> | |||||
| public bool IgnoreExtraArgs { get; set; } = false; | |||||
| } | } | ||||
| } | } | ||||
| @@ -20,7 +20,7 @@ namespace Discord.Commands | |||||
| private readonly CommandService _commandService; | private readonly CommandService _commandService; | ||||
| private readonly Func<ICommandContext, object[], IServiceProvider, CommandInfo, Task> _action; | private readonly Func<ICommandContext, object[], IServiceProvider, CommandInfo, Task> _action; | ||||
| public ModuleInfo Module { get; } | public ModuleInfo Module { get; } | ||||
| public string Name { get; } | public string Name { get; } | ||||
| public string Summary { get; } | public string Summary { get; } | ||||
| @@ -119,7 +119,7 @@ namespace Discord.Commands | |||||
| return ParseResult.FromError(preconditionResult); | return ParseResult.FromError(preconditionResult); | ||||
| string input = searchResult.Text.Substring(startIndex); | string input = searchResult.Text.Substring(startIndex); | ||||
| return await CommandParser.ParseArgsAsync(this, context, _commandService, services, input, 0).ConfigureAwait(false); | |||||
| return await CommandParser.ParseArgsAsync(this, context, _commandService._ignoreExtraArgs, services, input, 0).ConfigureAwait(false); | |||||
| } | } | ||||
| public Task<IResult> ExecuteAsync(ICommandContext context, ParseResult parseResult, IServiceProvider services) | public Task<IResult> ExecuteAsync(ICommandContext context, ParseResult parseResult, IServiceProvider services) | ||||