Browse Source

Cleaned up ModuleManager, added Instance

tags/docs-0.9
RogueException 9 years ago
parent
commit
45edf6fdce
2 changed files with 14 additions and 11 deletions
  1. +13
    -10
      src/Discord.Net.Modules/ModuleManager.cs
  2. +1
    -1
      src/Discord.Net.Modules/ModuleService.cs

+ 13
- 10
src/Discord.Net.Modules/ModuleManager.cs View File

@@ -51,22 +51,25 @@ namespace Discord.Modules
private readonly ConcurrentDictionary<ulong, int> _indirectServers;
private readonly AsyncLock _lock;

public DiscordClient Client => _client;
public string Name => _name;
public string Id => _id;
public FilterType FilterType => _filterType;
public IEnumerable<Server> EnabledServers => _enabledServers.Select(x => x.Value);
public DiscordClient Client { get; }
public IModule Instance { get; }
public string Name { get; }
public string Id { get; }
public FilterType FilterType { get; }

public IEnumerable<Server> EnabledServers => _enabledServers.Select(x => x.Value);
public IEnumerable<Channel> EnabledChannels => _enabledChannels.Select(x => x.Value);

internal ModuleManager(DiscordClient client, string name, FilterType filterType)
internal ModuleManager(DiscordClient client, string name, FilterType filterType, IModule instance)
{
_client = client;
_name = name;
Client = client;
Name = name;
FilterType = filterType;
Instance = instance;

_id = name.ToLowerInvariant();
Id = name.ToLowerInvariant();
_lock = new AsyncLock();

_filterType = filterType;
_allowAll = filterType == FilterType.Unrestricted;
_useServerWhitelist = filterType.HasFlag(FilterType.ServerWhitelist);
_useChannelWhitelist = filterType.HasFlag(FilterType.ChannelWhitelist);


+ 1
- 1
src/Discord.Net.Modules/ModuleService.cs View File

@@ -30,7 +30,7 @@ namespace Discord.Modules
if (_modules.ContainsKey(module))
throw new InvalidOperationException("This module has already been added.");

var manager = new ModuleManager(Client, name, type);
var manager = new ModuleManager(Client, name, type, module);
_modules.Add(module, manager);
module.Install(manager);
}


Loading…
Cancel
Save