From 9a2a47cd04da66aa70aa4ea6c167f8baa2b41e57 Mon Sep 17 00:00:00 2001 From: Kwoth Date: Tue, 13 Dec 2016 06:13:36 +0100 Subject: [PATCH] Fixes to mute stuff --- .../Modules/Administration/Commands/MuteCommands.cs | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/NadekoBot/Modules/Administration/Commands/MuteCommands.cs b/src/NadekoBot/Modules/Administration/Commands/MuteCommands.cs index fac7644f..b4ce345a 100644 --- a/src/NadekoBot/Modules/Administration/Commands/MuteCommands.cs +++ b/src/NadekoBot/Modules/Administration/Commands/MuteCommands.cs @@ -74,6 +74,10 @@ namespace NadekoBot.Modules.Administration { UserId = usr.Id }); + ConcurrentHashSet muted; + if (MutedUsers.TryGetValue(usr.Guild.Id, out muted)) + muted.Add(usr.Id); + await uow.CompleteAsync().ConfigureAwait(false); } await UserMuted(usr, MuteType.All).ConfigureAwait(false); @@ -81,8 +85,8 @@ namespace NadekoBot.Modules.Administration public static async Task Unmute(IGuildUser usr) { - await usr.ModifyAsync(x => x.Mute = true).ConfigureAwait(false); - await usr.AddRolesAsync(await GetMuteRole(usr.Guild)).ConfigureAwait(false); + await usr.ModifyAsync(x => x.Mute = false).ConfigureAwait(false); + await usr.RemoveRolesAsync(await GetMuteRole(usr.Guild)).ConfigureAwait(false); using (var uow = DbHandler.UnitOfWork()) { var config = uow.GuildConfigs.For(usr.Guild.Id, set => set.Include(gc => gc.MutedUsers)); @@ -90,10 +94,11 @@ namespace NadekoBot.Modules.Administration { UserId = usr.Id }); + ConcurrentHashSet muted; + if (MutedUsers.TryGetValue(usr.Guild.Id, out muted)) + muted.TryRemove(usr.Id); await uow.CompleteAsync().ConfigureAwait(false); } - ConcurrentHashSet muted; - MutedUsers.TryGetValue(usr.Guild.Id, out muted); await UserUnmuted(usr, MuteType.All).ConfigureAwait(false); }