Don't load modules that are already loaded

Previously, if a user autoloaded commands more than once, commands that were already in the command map would be readded. 

If the module list already contains a module with the same type as the module being loaded, it will not load the new instance of this module.
This commit is contained in:
Christopher F
2016-07-30 18:23:12 -04:00
parent 15dd6016e7
commit 9348e087b0

View File

@@ -117,6 +117,9 @@ namespace Discord.Commands
}
private Module LoadInternal(object moduleInstance, ModuleAttribute moduleAttr, TypeInfo typeInfo)
{
if (_modules.Any(m => m.Key.GetType().GetTypeInfo() == typeInfo))
return _modules.FirstOrDefault(m => m.Key.GetType().GetTypeInfo() == typeInfo).Value;
var loadedModule = new Module(this, moduleInstance, moduleAttr, typeInfo);
_modules[moduleInstance] = loadedModule;