diff --git a/src/Discord.Net.Commands/CommandService.cs b/src/Discord.Net.Commands/CommandService.cs index 0d27bd178..9f6e66c20 100644 --- a/src/Discord.Net.Commands/CommandService.cs +++ b/src/Discord.Net.Commands/CommandService.cs @@ -18,7 +18,7 @@ namespace Discord.Commands private readonly ConcurrentDictionary> _typeReaders; private readonly ConcurrentDictionary _defaultTypeReaders; private readonly ImmutableList> _entityTypeReaders; //TODO: Candidate for C#7 Tuple - private readonly ConcurrentBag _moduleDefs; + private readonly HashSet _moduleDefs; private readonly CommandMap _map; internal readonly bool _caseSensitive; @@ -38,7 +38,7 @@ namespace Discord.Commands _moduleLock = new SemaphoreSlim(1, 1); _typedModuleDefs = new ConcurrentDictionary(); - _moduleDefs = new ConcurrentBag(); + _moduleDefs = new HashSet(); _map = new CommandMap(this); _typeReaders = new ConcurrentDictionary>(); @@ -160,8 +160,7 @@ namespace Discord.Commands } private bool RemoveModuleInternal(ModuleInfo module) { - var defsRemove = module; - if (!_moduleDefs.TryTake(out defsRemove)) + if (!_moduleDefs.Remove(module)) return false; foreach (var cmd in module.Commands)