Cleaned up ModuleManager, added Instance
This commit is contained in:
@@ -51,22 +51,25 @@ namespace Discord.Modules
|
|||||||
private readonly ConcurrentDictionary<ulong, int> _indirectServers;
|
private readonly ConcurrentDictionary<ulong, int> _indirectServers;
|
||||||
private readonly AsyncLock _lock;
|
private readonly AsyncLock _lock;
|
||||||
|
|
||||||
public DiscordClient Client => _client;
|
public DiscordClient Client { get; }
|
||||||
public string Name => _name;
|
public IModule Instance { get; }
|
||||||
public string Id => _id;
|
public string Name { get; }
|
||||||
public FilterType FilterType => _filterType;
|
public string Id { get; }
|
||||||
public IEnumerable<Server> EnabledServers => _enabledServers.Select(x => x.Value);
|
public FilterType FilterType { get; }
|
||||||
|
|
||||||
|
public IEnumerable<Server> EnabledServers => _enabledServers.Select(x => x.Value);
|
||||||
public IEnumerable<Channel> EnabledChannels => _enabledChannels.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;
|
Client = client;
|
||||||
_name = name;
|
Name = name;
|
||||||
|
FilterType = filterType;
|
||||||
|
Instance = instance;
|
||||||
|
|
||||||
_id = name.ToLowerInvariant();
|
Id = name.ToLowerInvariant();
|
||||||
_lock = new AsyncLock();
|
_lock = new AsyncLock();
|
||||||
|
|
||||||
_filterType = filterType;
|
|
||||||
_allowAll = filterType == FilterType.Unrestricted;
|
_allowAll = filterType == FilterType.Unrestricted;
|
||||||
_useServerWhitelist = filterType.HasFlag(FilterType.ServerWhitelist);
|
_useServerWhitelist = filterType.HasFlag(FilterType.ServerWhitelist);
|
||||||
_useChannelWhitelist = filterType.HasFlag(FilterType.ChannelWhitelist);
|
_useChannelWhitelist = filterType.HasFlag(FilterType.ChannelWhitelist);
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ namespace Discord.Modules
|
|||||||
if (_modules.ContainsKey(module))
|
if (_modules.ContainsKey(module))
|
||||||
throw new InvalidOperationException("This module has already been added.");
|
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);
|
_modules.Add(module, manager);
|
||||||
module.Install(manager);
|
module.Install(manager);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user