Browse Source

Default DependencyMap to an empty map when not supplied

tags/1.0-rc
RogueException 8 years ago
parent
commit
b8102a6767
3 changed files with 10 additions and 0 deletions
  1. +6
    -0
      src/Discord.Net.Commands/CommandInfo.cs
  2. +2
    -0
      src/Discord.Net.Commands/CommandService.cs
  3. +2
    -0
      src/Discord.Net.Commands/Dependencies/DependencyMap.cs

+ 6
- 0
src/Discord.Net.Commands/CommandInfo.cs View File

@@ -87,6 +87,9 @@ namespace Discord.Commands

public async Task<PreconditionResult> CheckPreconditions(CommandContext context, IDependencyMap map = null)
{
if (map == null)
map = DependencyMap.Empty;

foreach (PreconditionAttribute precondition in Module.Preconditions)
{
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)
{
if (map == null)
map = DependencyMap.Empty;

try
{
var args = GenerateArgs(argList, paramList);


+ 2
- 0
src/Discord.Net.Commands/CommandService.cs View File

@@ -195,6 +195,8 @@ namespace Discord.Commands
=> 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)
{
dependencyMap = dependencyMap ?? DependencyMap.Empty;

var searchResult = Search(context, input);
if (!searchResult.IsSuccess)
return searchResult;


+ 2
- 0
src/Discord.Net.Commands/Dependencies/DependencyMap.cs View File

@@ -7,6 +7,8 @@ namespace Discord.Commands
{
private Dictionary<Type, object> map;

public static DependencyMap Empty => new DependencyMap();

public DependencyMap()
{
map = new Dictionary<Type, object>();


Loading…
Cancel
Save