Browse Source

Correct name & only pass in bool

pull/915/head
John 7 years ago
parent
commit
30936c6164
4 changed files with 10 additions and 10 deletions
  1. +4
    -4
      src/Discord.Net.Commands/CommandParser.cs
  2. +2
    -2
      src/Discord.Net.Commands/CommandService.cs
  3. +2
    -2
      src/Discord.Net.Commands/CommandServiceConfig.cs
  4. +2
    -2
      src/Discord.Net.Commands/Info/CommandInfo.cs

+ 4
- 4
src/Discord.Net.Commands/CommandParser.cs View File

@@ -14,7 +14,7 @@ namespace Discord.Commands
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;
StringBuilder argBuilder = new StringBuilder(input.Length);
@@ -110,10 +110,10 @@ namespace Discord.Commands
{
if (curParam == null)
{
if (commandService._failOnTooManyArgs)
return ParseResult.FromError(CommandError.BadArgCount, "The input text has too many parameters.");
else
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);


+ 2
- 2
src/Discord.Net.Commands/CommandService.cs View File

@@ -27,7 +27,7 @@ namespace Discord.Commands
private readonly HashSet<ModuleInfo> _moduleDefs;
private readonly CommandMap _map;

internal readonly bool _caseSensitive, _throwOnError, _failOnTooManyArgs;
internal readonly bool _caseSensitive, _throwOnError, _ignoreExtraArgs;
internal readonly char _separatorChar;
internal readonly RunMode _defaultRunMode;
internal readonly Logger _cmdLogger;
@@ -42,7 +42,7 @@ namespace Discord.Commands
{
_caseSensitive = config.CaseSensitiveCommands;
_throwOnError = config.ThrowOnError;
_failOnTooManyArgs = config.FailOnTooManyArgs;
_ignoreExtraArgs = config.IgnoreExtraArgs;
_separatorChar = config.SeparatorChar;
_defaultRunMode = config.DefaultRunMode;
if (_defaultRunMode == RunMode.Default)


+ 2
- 2
src/Discord.Net.Commands/CommandServiceConfig.cs View File

@@ -16,7 +16,7 @@
/// <summary> Determines whether RunMode.Sync commands should push exceptions up to the caller. </summary>
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;
}
}

+ 2
- 2
src/Discord.Net.Commands/Info/CommandInfo.cs View File

@@ -20,7 +20,7 @@ namespace Discord.Commands

private readonly CommandService _commandService;
private readonly Func<ICommandContext, object[], IServiceProvider, CommandInfo, Task> _action;
public ModuleInfo Module { get; }
public string Name { get; }
public string Summary { get; }
@@ -119,7 +119,7 @@ namespace Discord.Commands
return ParseResult.FromError(preconditionResult);

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)


Loading…
Cancel
Save