|
@@ -1,6 +1,5 @@ |
|
|
using System; |
|
|
using System; |
|
|
using System.Collections.Generic; |
|
|
using System.Collections.Generic; |
|
|
using System.Linq; |
|
|
|
|
|
using System.Threading.Tasks; |
|
|
using System.Threading.Tasks; |
|
|
|
|
|
|
|
|
namespace Discord.Commands |
|
|
namespace Discord.Commands |
|
@@ -10,7 +9,7 @@ namespace Discord.Commands |
|
|
public static async Task<IReadOnlyCollection<CommandInfo>> GetExecutableCommandsAsync(this IEnumerable<CommandInfo> commands, ICommandContext context, IServiceProvider provider) |
|
|
public static async Task<IReadOnlyCollection<CommandInfo>> GetExecutableCommandsAsync(this IEnumerable<CommandInfo> commands, ICommandContext context, IServiceProvider provider) |
|
|
{ |
|
|
{ |
|
|
var executableCommands = new List<CommandInfo>(); |
|
|
var executableCommands = new List<CommandInfo>(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
foreach (var command in commands) |
|
|
foreach (var command in commands) |
|
|
{ |
|
|
{ |
|
|
var result = await command.CheckPreconditionsAsync(context, provider).ConfigureAwait(false); |
|
|
var result = await command.CheckPreconditionsAsync(context, provider).ConfigureAwait(false); |
|
@@ -22,7 +21,16 @@ namespace Discord.Commands |
|
|
} |
|
|
} |
|
|
public static Task<IReadOnlyCollection<CommandInfo>> GetExecutableCommandsAsync(this CommandService commandService, ICommandContext context, IServiceProvider provider) |
|
|
public static Task<IReadOnlyCollection<CommandInfo>> GetExecutableCommandsAsync(this CommandService commandService, ICommandContext context, IServiceProvider provider) |
|
|
=> GetExecutableCommandsAsync(commandService.Commands, context, provider); |
|
|
=> GetExecutableCommandsAsync(commandService.Commands, context, provider); |
|
|
public static Task<IReadOnlyCollection<CommandInfo>> GetExecutableCommandAsync(this ModuleInfo module, ICommandContext context, IServiceProvider provider) |
|
|
|
|
|
=> GetExecutableCommandsAsync(module.Commands.Concat(module.Submodules.SelectMany(sm => sm.Commands)), context, provider); |
|
|
|
|
|
|
|
|
public static async Task<IReadOnlyCollection<CommandInfo>> GetExecutableCommandsAsync(this ModuleInfo module, ICommandContext context, IServiceProvider provider) |
|
|
|
|
|
{ |
|
|
|
|
|
var executableCommands = new List<CommandInfo>(); |
|
|
|
|
|
|
|
|
|
|
|
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; |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |