Project now magically works

This commit is contained in:
Kwoth
2016-10-10 06:38:20 +02:00
parent e60034728c
commit fd729e553d
8 changed files with 35 additions and 18 deletions

View File

@@ -150,16 +150,13 @@ namespace NadekoBot.Modules.CustomReactions
if (toDelete.GuildId == null && channel == null)
{
uow.CustomReactions.Remove(toDelete);
var toRemove = GlobalReactions.FirstOrDefault(cr => cr.Id == toDelete.Id);
GlobalReactions.TryRemove(toRemove);
GlobalReactions.RemoveWhere(cr => cr.Id == toDelete.Id);
success = true;
}
else if (toDelete.GuildId != null && channel?.Guild.Id == toDelete.GuildId)
{
uow.CustomReactions.Remove(toDelete);
var crs = GuildReactions.GetOrAdd(channel.Guild.Id, new ConcurrentHashSet<CustomReaction>());
var toRemove = crs.FirstOrDefault(cr => cr.Id == toDelete.Id);
GuildReactions.GetOrAdd(channel.Guild.Id, new ConcurrentHashSet<CustomReaction>()).RemoveWhere(cr=>cr.Id == toDelete.Id);
success = true;
}
if(success)

View File

@@ -76,9 +76,7 @@ namespace NadekoBot.Modules.Permissions
else
{
uow.BotConfig.GetOrCreate().Blacklist.RemoveWhere(bi => bi.ItemId == id && bi.Type == type);
var toRemove = BlacklistedItems.FirstOrDefault(bi => bi.ItemId == id && bi.Type == type);
if (toRemove != null)
BlacklistedItems.TryRemove(toRemove);
BlacklistedItems.RemoveWhere(bi => bi.ItemId == id && bi.Type == type);
}
await uow.CompleteAsync().ConfigureAwait(false);
}

View File

@@ -34,7 +34,7 @@ namespace NadekoBot.Modules.Permissions
using (var uow = DbHandler.UnitOfWork())
{
var configs = uow.GuildConfigs.GetAll();
commandCooldowns = new ConcurrentDictionary<ulong, ConcurrentHashSet<CommandCooldown>>(configs.ToDictionary(k => k.GuildId, v => v.CommandCooldowns));
commandCooldowns = new ConcurrentDictionary<ulong, ConcurrentHashSet<CommandCooldown>>(configs.ToDictionary(k => k.GuildId, v => new ConcurrentHashSet<CommandCooldown>(v.CommandCooldowns)));
}
}
[NadekoCommand, Usage, Description, Aliases]

View File

@@ -84,7 +84,7 @@ namespace NadekoBot.Modules.Permissions
}
else
{
InviteFilteringServers.Remove(channel.Guild.Id);
InviteFilteringServers.TryRemove(channel.Guild.Id);
await channel.SendMessageAsync("`Invite filtering disabled on this server.`").ConfigureAwait(false);
}
}
@@ -117,7 +117,7 @@ namespace NadekoBot.Modules.Permissions
}
else
{
InviteFilteringChannels.Remove(channel.Id);
InviteFilteringChannels.TryRemove(channel.Id);
await channel.SendMessageAsync("`Invite filtering disabled on this channel.`").ConfigureAwait(false);
}
}
@@ -143,7 +143,7 @@ namespace NadekoBot.Modules.Permissions
}
else
{
WordFilteringServers.Remove(channel.Guild.Id);
WordFilteringServers.TryRemove(channel.Guild.Id);
await channel.SendMessageAsync("`Word filtering disabled on this server.`").ConfigureAwait(false);
}
}
@@ -176,7 +176,7 @@ namespace NadekoBot.Modules.Permissions
}
else
{
WordFilteringChannels.Remove(channel.Id);
WordFilteringChannels.TryRemove(channel.Id);
await channel.SendMessageAsync("`Word filtering disabled on this channel.`").ConfigureAwait(false);
}
}
@@ -215,7 +215,7 @@ namespace NadekoBot.Modules.Permissions
}
else
{
filteredWords.Remove(word);
filteredWords.TryRemove(word);
await channel.SendMessageAsync($"Word `{word}` removed from the list of filtered words.")
.ConfigureAwait(false);
}

View File

@@ -195,7 +195,7 @@ namespace NadekoBot.Modules.Searches
toRemove = streams.Where(fs => fs.ChannelId == channel.Id && fs.Username.ToUpperInvariant() == username).FirstOrDefault();
if (toRemove != null)
{
config.FollowedStreams = streams.Except(new[] { toRemove }).ToList();
config.FollowedStreams = new HashSet<FollowedStream>(streams.Except(new[] { toRemove }));
await uow.CompleteAsync();
}
}