Update commands with C#7 features (#689)

* C#7 features in commands, CommandInfo in ModuleBase

* Update TypeReaders with C#7 features and IServiceProvider

* Add best-choice command selection to CommandService

* Normalize type reader scores correctly

* Fix logic error and rebase onto dev

* Change GetMethod for SetMethod in ReflectionUtils

Should be checking against setters, not getters

* Ensure args/params scores do not overwhelm Priority

* Remove possibility of NaNs
This commit is contained in:
Finite Reality
2017-06-29 21:43:55 +01:00
committed by RogueException
parent 41222eafeb
commit 032aba9129
19 changed files with 213 additions and 146 deletions

View File

@@ -1,4 +1,5 @@
using System.Collections.Immutable;
using System;
using System.Collections.Immutable;
using System.Text;
using System.Threading.Tasks;
@@ -13,7 +14,7 @@ namespace Discord.Commands
QuotedParameter
}
public static async Task<ParseResult> ParseArgs(CommandInfo command, ICommandContext context, string input, int startPos)
public static async Task<ParseResult> ParseArgs(CommandInfo command, ICommandContext context, IServiceProvider services, string input, int startPos)
{
ParameterInfo curParam = null;
StringBuilder argBuilder = new StringBuilder(input.Length);
@@ -110,7 +111,7 @@ namespace Discord.Commands
if (curParam == null)
return ParseResult.FromError(CommandError.BadArgCount, "The input text has too many parameters.");
var typeReaderResult = await curParam.Parse(context, argString).ConfigureAwait(false);
var typeReaderResult = await curParam.Parse(context, argString, services).ConfigureAwait(false);
if (!typeReaderResult.IsSuccess && typeReaderResult.Error != CommandError.MultipleMatches)
return ParseResult.FromError(typeReaderResult);
@@ -133,7 +134,7 @@ namespace Discord.Commands
if (curParam != null && curParam.IsRemainder)
{
var typeReaderResult = await curParam.Parse(context, argBuilder.ToString()).ConfigureAwait(false);
var typeReaderResult = await curParam.Parse(context, argBuilder.ToString(), services).ConfigureAwait(false);
if (!typeReaderResult.IsSuccess)
return ParseResult.FromError(typeReaderResult);
argList.Add(typeReaderResult);