Added ModuleManager EnableChannels and EnableServers

This commit is contained in:
RogueException
2015-11-30 14:24:37 -04:00
parent 5cf2eb6749
commit 3027abc044

View File

@@ -127,6 +127,20 @@ namespace Discord.Modules
if (!_useServerWhitelist) throw new InvalidOperationException("This module is not configured to use a server whitelist.");
lock (this)
return EnableServerInternal(server);
}
public void EnableServers(IEnumerable<Server> servers)
{
if (servers == null) throw new ArgumentNullException(nameof(servers));
if (!_useServerWhitelist) throw new InvalidOperationException("This module is not configured to use a server whitelist.");
lock (this)
{
foreach (var server in servers)
EnableServerInternal(server);
}
}
private bool EnableServerInternal(Server server)
{
if (_enabledServers.TryAdd(server.Id, server))
{
@@ -136,7 +150,7 @@ namespace Discord.Modules
}
return false;
}
}
public bool DisableServer(Server server)
{
if (server == null) throw new ArgumentNullException(nameof(server));
@@ -175,6 +189,20 @@ namespace Discord.Modules
if (!_useChannelWhitelist) throw new InvalidOperationException("This module is not configured to use a channel whitelist.");
lock (this)
return EnableChannelInternal(channel);
}
public void EnableChannels(IEnumerable<Channel> channels)
{
if (channels == null) throw new ArgumentNullException(nameof(channels));
if (!_useChannelWhitelist) throw new InvalidOperationException("This module is not configured to use a channel whitelist.");
lock (this)
{
foreach (var channel in channels)
EnableChannelInternal(channel);
}
}
private bool EnableChannelInternal(Channel channel)
{
if (_enabledChannels.TryAdd(channel.Id, channel))
{
@@ -192,7 +220,7 @@ namespace Discord.Modules
}
return false;
}
}
public bool DisableChannel(Channel channel)
{
if (channel == null) throw new ArgumentNullException(nameof(channel));