Browse Source

Fix #328 by excluding nested types in CommandService

Apparently a nested type counts as an exported type and it is
returned by Assembly.ExportedTypes - so we do a check to ensure that
the type isn't nested before adding it ourselves.
pull/334/head
FiniteReality 8 years ago
parent
commit
8ab00930f0
1 changed files with 10 additions and 0 deletions
  1. +10
    -0
      src/Discord.Net.Commands/CommandService.cs

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

@@ -95,6 +95,16 @@ namespace Discord.Commands
{
foreach (var type in assembly.ExportedTypes)
{
//Ensure that we weren't declared as a submodule
if (type.DeclaringType != null)
{
if (_moduleDefs.ContainsKey(type.DeclaringType))
continue;

var declaringTypeInfo = type.DeclaringType.GetTypeInfo();
if (_moduleTypeInfo.IsAssignableFrom(declaringTypeInfo))
continue;
}
if (!_moduleDefs.ContainsKey(type))
{
var typeInfo = type.GetTypeInfo();


Loading…
Cancel
Save