diff --git a/src/Discord.Net.Commands/CommandService.cs b/src/Discord.Net.Commands/CommandService.cs index 7efc1bc62..d79a3a03b 100644 --- a/src/Discord.Net.Commands/CommandService.cs +++ b/src/Discord.Net.Commands/CommandService.cs @@ -95,9 +95,11 @@ namespace Discord.Commands _moduleLock.Release(); } } - public Task AddModuleAsync(IServiceProvider services) => AddModuleAsync(typeof(T), services); - public async Task AddModuleAsync(Type type, IServiceProvider services) + public Task AddModuleAsync(IServiceProvider services = null) => AddModuleAsync(typeof(T), services); + public async Task AddModuleAsync(Type type, IServiceProvider services = null) { + services = services ?? EmptyServiceProvider.Instance; + await _moduleLock.WaitAsync().ConfigureAwait(false); try { @@ -120,8 +122,10 @@ namespace Discord.Commands _moduleLock.Release(); } } - public async Task> AddModulesAsync(Assembly assembly, IServiceProvider services) + public async Task> AddModulesAsync(Assembly assembly, IServiceProvider services = null) { + services = services ?? EmptyServiceProvider.Instance; + await _moduleLock.WaitAsync().ConfigureAwait(false); try { diff --git a/src/Discord.Net.Commands/Utilities/ReflectionUtils.cs b/src/Discord.Net.Commands/Utilities/ReflectionUtils.cs index ab88f66ae..30dd7c36b 100644 --- a/src/Discord.Net.Commands/Utilities/ReflectionUtils.cs +++ b/src/Discord.Net.Commands/Utilities/ReflectionUtils.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Linq; using System.Reflection;