diff --git a/src/Discord.Net.Commands/Discord.Net.Commands.csproj b/src/Discord.Net.Commands/Discord.Net.Commands.csproj index eaac79a55..9db5fbf1e 100644 --- a/src/Discord.Net.Commands/Discord.Net.Commands.csproj +++ b/src/Discord.Net.Commands/Discord.Net.Commands.csproj @@ -6,6 +6,9 @@ A Discord.Net extension adding support for bot commands. netstandard1.1 + + 7.3 + diff --git a/src/Discord.Net.Commands/Extensions/CommandServiceExtensions.cs b/src/Discord.Net.Commands/Extensions/CommandServiceExtensions.cs index 77937fe99..519b92e5c 100644 --- a/src/Discord.Net.Commands/Extensions/CommandServiceExtensions.cs +++ b/src/Discord.Net.Commands/Extensions/CommandServiceExtensions.cs @@ -1,6 +1,5 @@ using System; using System.Collections.Generic; -using System.Linq; using System.Threading.Tasks; namespace Discord.Commands @@ -10,7 +9,7 @@ namespace Discord.Commands public static async Task> GetExecutableCommandsAsync(this IEnumerable commands, ICommandContext context, IServiceProvider provider) { var executableCommands = new List(); - + foreach (var command in commands) { var result = await command.CheckPreconditionsAsync(context, provider).ConfigureAwait(false); @@ -22,7 +21,16 @@ namespace Discord.Commands } public static Task> GetExecutableCommandsAsync(this CommandService commandService, ICommandContext context, IServiceProvider provider) => GetExecutableCommandsAsync(commandService.Commands, context, provider); - public static Task> GetExecutableCommandAsync(this ModuleInfo module, ICommandContext context, IServiceProvider provider) - => GetExecutableCommandsAsync(module.Commands.Concat(module.Submodules.SelectMany(sm => sm.Commands)), context, provider); + public static async Task> GetExecutableCommandsAsync(this ModuleInfo module, ICommandContext context, IServiceProvider provider) + { + var executableCommands = new List(); + + executableCommands.AddRange(await module.Commands.GetExecutableCommandsAsync(context, provider).ConfigureAwait(false)); + + foreach (var subModule in module.Submodules) + executableCommands.AddRange(await subModule.GetExecutableCommandsAsync(context, provider).ConfigureAwait(false)); + + return executableCommands; + } } }