Default DependencyMap to an empty map when not supplied
This commit is contained in:
@@ -87,6 +87,9 @@ namespace Discord.Commands
|
|||||||
|
|
||||||
public async Task<PreconditionResult> CheckPreconditions(CommandContext context, IDependencyMap map = null)
|
public async Task<PreconditionResult> CheckPreconditions(CommandContext context, IDependencyMap map = null)
|
||||||
{
|
{
|
||||||
|
if (map == null)
|
||||||
|
map = DependencyMap.Empty;
|
||||||
|
|
||||||
foreach (PreconditionAttribute precondition in Module.Preconditions)
|
foreach (PreconditionAttribute precondition in Module.Preconditions)
|
||||||
{
|
{
|
||||||
var result = await precondition.CheckPermissions(context, this, map).ConfigureAwait(false);
|
var result = await precondition.CheckPermissions(context, this, map).ConfigureAwait(false);
|
||||||
@@ -150,6 +153,9 @@ namespace Discord.Commands
|
|||||||
}
|
}
|
||||||
public async Task<ExecuteResult> Execute(CommandContext context, IEnumerable<object> argList, IEnumerable<object> paramList, IDependencyMap map)
|
public async Task<ExecuteResult> Execute(CommandContext context, IEnumerable<object> argList, IEnumerable<object> paramList, IDependencyMap map)
|
||||||
{
|
{
|
||||||
|
if (map == null)
|
||||||
|
map = DependencyMap.Empty;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var args = GenerateArgs(argList, paramList);
|
var args = GenerateArgs(argList, paramList);
|
||||||
|
|||||||
@@ -195,6 +195,8 @@ namespace Discord.Commands
|
|||||||
=> Execute(context, context.Message.Content.Substring(argPos), dependencyMap, multiMatchHandling);
|
=> Execute(context, context.Message.Content.Substring(argPos), dependencyMap, multiMatchHandling);
|
||||||
public async Task<IResult> Execute(CommandContext context, string input, IDependencyMap dependencyMap = null, MultiMatchHandling multiMatchHandling = MultiMatchHandling.Exception)
|
public async Task<IResult> Execute(CommandContext context, string input, IDependencyMap dependencyMap = null, MultiMatchHandling multiMatchHandling = MultiMatchHandling.Exception)
|
||||||
{
|
{
|
||||||
|
dependencyMap = dependencyMap ?? DependencyMap.Empty;
|
||||||
|
|
||||||
var searchResult = Search(context, input);
|
var searchResult = Search(context, input);
|
||||||
if (!searchResult.IsSuccess)
|
if (!searchResult.IsSuccess)
|
||||||
return searchResult;
|
return searchResult;
|
||||||
|
|||||||
@@ -7,6 +7,8 @@ namespace Discord.Commands
|
|||||||
{
|
{
|
||||||
private Dictionary<Type, object> map;
|
private Dictionary<Type, object> map;
|
||||||
|
|
||||||
|
public static DependencyMap Empty => new DependencyMap();
|
||||||
|
|
||||||
public DependencyMap()
|
public DependencyMap()
|
||||||
{
|
{
|
||||||
map = new Dictionary<Type, object>();
|
map = new Dictionary<Type, object>();
|
||||||
|
|||||||
Reference in New Issue
Block a user