Added ModuleManager EnableChannels and EnableServers
This commit is contained in:
@@ -127,6 +127,20 @@ namespace Discord.Modules
|
|||||||
if (!_useServerWhitelist) throw new InvalidOperationException("This module is not configured to use a server whitelist.");
|
if (!_useServerWhitelist) throw new InvalidOperationException("This module is not configured to use a server whitelist.");
|
||||||
|
|
||||||
lock (this)
|
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))
|
if (_enabledServers.TryAdd(server.Id, server))
|
||||||
{
|
{
|
||||||
@@ -136,7 +150,7 @@ namespace Discord.Modules
|
|||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
public bool DisableServer(Server server)
|
public bool DisableServer(Server server)
|
||||||
{
|
{
|
||||||
if (server == null) throw new ArgumentNullException(nameof(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.");
|
if (!_useChannelWhitelist) throw new InvalidOperationException("This module is not configured to use a channel whitelist.");
|
||||||
|
|
||||||
lock (this)
|
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))
|
if (_enabledChannels.TryAdd(channel.Id, channel))
|
||||||
{
|
{
|
||||||
@@ -192,7 +220,7 @@ namespace Discord.Modules
|
|||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
public bool DisableChannel(Channel channel)
|
public bool DisableChannel(Channel channel)
|
||||||
{
|
{
|
||||||
if (channel == null) throw new ArgumentNullException(nameof(channel));
|
if (channel == null) throw new ArgumentNullException(nameof(channel));
|
||||||
|
|||||||
Reference in New Issue
Block a user