Allow setting IgnoreExtraArgs on an individual basis (#998)

* Allow setting IgnoreExtraArgs on an individual basis

* Remove passing in the flag as a separate parameter

* VS plz

* Push the RunMode setting out to its own attribute, because fox wants consistency.

Bonus: Removes the need for that godawful 'RunMode.Default'.

* Revert previous commit

* Fox doesn't like module-wide switches 😒
This commit is contained in:
Joe4evr
2018-04-29 17:10:00 +02:00
committed by Christopher F
parent a3ce80c1dc
commit 6d3010065f
9 changed files with 11 additions and 20 deletions

View File

@@ -27,6 +27,7 @@ namespace Discord.Commands
public string Remarks { get; }
public int Priority { get; }
public bool HasVarArgs { get; }
public bool IgnoreExtraArgs { get; }
public RunMode RunMode { get; }
public IReadOnlyList<string> Aliases { get; }
@@ -63,6 +64,7 @@ namespace Discord.Commands
Parameters = builder.Parameters.Select(x => x.Build(this)).ToImmutableArray();
HasVarArgs = builder.Parameters.Count > 0 ? builder.Parameters[builder.Parameters.Count - 1].IsMultiple : false;
IgnoreExtraArgs = builder.IgnoreExtraArgs;
_action = builder.Callback;
_commandService = service;
@@ -119,7 +121,7 @@ namespace Discord.Commands
return ParseResult.FromError(preconditionResult);
string input = searchResult.Text.Substring(startIndex);
return await CommandParser.ParseArgsAsync(this, context, _commandService._ignoreExtraArgs, services, input, 0).ConfigureAwait(false);
return await CommandParser.ParseArgsAsync(this, context, services, input, 0).ConfigureAwait(false);
}
public Task<IResult> ExecuteAsync(ICommandContext context, ParseResult parseResult, IServiceProvider services)

View File

@@ -2,7 +2,6 @@ using System;
using System.Linq;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Reflection;
using Discord.Commands.Builders;
namespace Discord.Commands
@@ -23,8 +22,6 @@ namespace Discord.Commands
public ModuleInfo Parent { get; }
public bool IsSubmodule => Parent != null;
//public TypeInfo TypeInfo { get; }
internal ModuleInfo(ModuleBuilder builder, CommandService service, IServiceProvider services, ModuleInfo parent = null)
{
Service = service;
@@ -35,8 +32,6 @@ namespace Discord.Commands
Group = builder.Group;
Parent = parent;
//TypeInfo = builder.TypeInfo;
Aliases = BuildAliases(builder, service).ToImmutableArray();
Commands = builder.Commands.Select(x => x.Build(this, service)).ToImmutableArray();
Preconditions = BuildPreconditions(builder).ToImmutableArray();