Browse Source

Move aliases outside of CommandInfo class

pull/943/head
Chris Johnston 7 years ago
parent
commit
1a8aa96f9b
2 changed files with 4 additions and 6 deletions
  1. +3
    -3
      src/Discord.Net.Commands/CommandParser.cs
  2. +1
    -3
      src/Discord.Net.Commands/Info/CommandInfo.cs

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

@@ -14,7 +14,7 @@ namespace Discord.Commands
Parameter,
QuotedParameter
}
public static async Task<ParseResult> ParseArgsAsync(CommandInfo command, ICommandContext context, bool ignoreExtraArgs, IServiceProvider services, string input, int startPos)
public static async Task<ParseResult> ParseArgsAsync(CommandInfo command, ICommandContext context, bool ignoreExtraArgs, IServiceProvider services, string input, int startPos, IReadOnlyDictionary<char, char> aliasMap)
{
ParameterInfo curParam = null;
StringBuilder argBuilder = new StringBuilder(input.Length);
@@ -99,10 +99,10 @@ namespace Discord.Commands
continue;
}
if (IsOpenQuote(command._quotationAliases, c))
if (IsOpenQuote(aliasMap, c))
{
curPart = ParserPart.QuotedParameter;
matchQuote = GetMatch(command._quotationAliases, c);
matchQuote = GetMatch(aliasMap, c);
continue;
}
curPart = ParserPart.Parameter;


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

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

private readonly CommandService _commandService;
private readonly Func<ICommandContext, object[], IServiceProvider, CommandInfo, Task> _action;
internal readonly IReadOnlyDictionary<char,char> _quotationAliases;

public ModuleInfo Module { get; }
public string Name { get; }
@@ -66,7 +65,6 @@ namespace Discord.Commands
HasVarArgs = builder.Parameters.Count > 0 ? builder.Parameters[builder.Parameters.Count - 1].IsMultiple : false;

_action = builder.Callback;
_quotationAliases = service._quotationMarkAliasMap;
_commandService = service;
}

@@ -121,7 +119,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, _commandService._ignoreExtraArgs, services, input, 0, _commandService._quotationMarkAliasMap).ConfigureAwait(false);
}

public Task<IResult> ExecuteAsync(ICommandContext context, ParseResult parseResult, IServiceProvider services)


Loading…
Cancel
Save