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

@@ -15,11 +15,11 @@ namespace Discord.Commands
return await Context.Channel.SendMessageAsync(message, isTTS, embed, options).ConfigureAwait(false);
}
protected virtual void BeforeExecute()
protected virtual void BeforeExecute(CommandInfo command)
{
}
protected virtual void AfterExecute()
protected virtual void AfterExecute(CommandInfo command)
{
}
@@ -27,13 +27,11 @@ namespace Discord.Commands
void IModuleBase.SetContext(ICommandContext context)
{
var newValue = context as T;
if (newValue == null)
throw new InvalidOperationException($"Invalid context type. Expected {typeof(T).Name}, got {context.GetType().Name}");
Context = newValue;
Context = newValue ?? throw new InvalidOperationException($"Invalid context type. Expected {typeof(T).Name}, got {context.GetType().Name}");
}
void IModuleBase.BeforeExecute() => BeforeExecute();
void IModuleBase.BeforeExecute(CommandInfo command) => BeforeExecute(command);
void IModuleBase.AfterExecute() => AfterExecute();
void IModuleBase.AfterExecute(CommandInfo command) => AfterExecute(command);
}
}