From 8ab00930f0c7d8a385935ca790cd30dfef8f05b6 Mon Sep 17 00:00:00 2001 From: FiniteReality Date: Mon, 24 Oct 2016 10:51:39 +0100 Subject: [PATCH] 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. --- src/Discord.Net.Commands/CommandService.cs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/Discord.Net.Commands/CommandService.cs b/src/Discord.Net.Commands/CommandService.cs index ef0dba7e7..b45b2cc09 100644 --- a/src/Discord.Net.Commands/CommandService.cs +++ b/src/Discord.Net.Commands/CommandService.cs @@ -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();