Browse Source

Added a check before adding a module manually. Adding outer subtypes now seem to work, but they don't bind with parent modules properly yet.

pull/1399/head
LtLi0n 5 years ago
parent
commit
5b63591ac4
1 changed files with 7 additions and 1 deletions
  1. +7
    -1
      src/Discord.Net.Commands/CommandService.cs

+ 7
- 1
src/Discord.Net.Commands/CommandService.cs View File

@@ -197,7 +197,13 @@ namespace Discord.Commands
if (_typedModuleDefs.ContainsKey(type))
throw new ArgumentException("This module has already been added.");

var module = (await ModuleClassBuilder.BuildAsync(this, services, typeInfo).ConfigureAwait(false)).FirstOrDefault();
bool isModuleType = await typeInfo.IsValidModuleType(logger: _cmdLogger);
if(!isModuleType)
{
throw new InvalidOperationException($"Type {typeInfo.FullName} cannot be transformed into a module. Look at the logs for more details.");
}

var module = (await ModuleClassBuilder.BuildAsync(this, services, _typedModuleDefs, typeInfo).ConfigureAwait(false)).FirstOrDefault();

if (module.Value == default(ModuleInfo))
throw new InvalidOperationException($"Could not build the module {type.FullName}, did you pass an invalid type?");


Loading…
Cancel
Save