Browse Source

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.
tags/1.0-rc
Christopher F 9 years ago
parent
commit
9348e087b0
1 changed files with 3 additions and 0 deletions
  1. +3
    -0
      src/Discord.Net.Commands/CommandService.cs

+ 3
- 0
src/Discord.Net.Commands/CommandService.cs 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;



Loading…
Cancel
Save