From a06376443fa45c3c4ec0ae4206994b8837c0bc0e Mon Sep 17 00:00:00 2001 From: l1ttleO Date: Fri, 15 Jul 2022 18:32:54 +0500 Subject: [PATCH] Remove timeout from user if it exists, but there is a mute role configured --- Boyfriend/Commands/UnmuteCommand.cs | 7 ++----- Boyfriend/EventHandler.cs | 3 +-- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/Boyfriend/Commands/UnmuteCommand.cs b/Boyfriend/Commands/UnmuteCommand.cs index f0e7951..5659e17 100644 --- a/Boyfriend/Commands/UnmuteCommand.cs +++ b/Boyfriend/Commands/UnmuteCommand.cs @@ -39,7 +39,7 @@ public class UnmuteCommand : Command { var requestOptions = Utils.GetRequestOptions($"({author}) {reason}"); var role = Utils.GetMuteRole(ref guild); - if (role != null) { + if (role != null && toUnmute.Roles.Contains(role)) { var rolesRemoved = Boyfriend.GetRemovedRoles(guild.Id); if (rolesRemoved.ContainsKey(toUnmute.Id)) { @@ -48,10 +48,7 @@ public class UnmuteCommand : Command { CommandHandler.ConfigWriteScheduled = true; } - if (toUnmute.Roles.Contains(role)) { await toUnmute.RemoveRoleAsync(role, requestOptions); } else { - Error(Messages.MemberNotMuted, false); - return; - } + await toUnmute.RemoveRoleAsync(role, requestOptions); } else { if (toUnmute.TimedOutUntil == null || toUnmute.TimedOutUntil.Value.ToUnixTimeMilliseconds() < DateTimeOffset.Now.ToUnixTimeMilliseconds()) { diff --git a/Boyfriend/EventHandler.cs b/Boyfriend/EventHandler.cs index fd31995..f562d38 100644 --- a/Boyfriend/EventHandler.cs +++ b/Boyfriend/EventHandler.cs @@ -57,9 +57,8 @@ public class EventHandler { } private static async Task MessageReceivedEvent(SocketMessage messageParam) { - if (messageParam is not SocketUserMessage message) return; + if (messageParam is not SocketUserMessage { Author: SocketGuildUser user } message) return; - var user = (SocketGuildUser)message.Author; var guild = user.Guild; var guildConfig = Boyfriend.GetGuildConfig(guild.Id);