public async Task Mute([Summary("The user to mute")] SocketGuildUser user, [Summary("The time to mute (hh:mm:ss)")] TimeSpan time, [Summary("Reason for muting")] string reason) { var author = Context.User as SocketGuildUser; var authorsHighestRole = author.Roles.OrderByDescending(x => x.Position).First(); var usersHighestRole = user.Roles.OrderByDescending(x => x.Position).First(); if (usersHighestRole.Position >= authorsHighestRole.Position) { await ReplyAsync(":x: You cannot mute someone above or equal to you in the role hierarchy."); return; } if (_service.MuteMessage != null && _service.UnmuteMessage != "") { var dmChannel = await user.GetOrCreateDMChannelAsync(); await dmChannel.SendMessageAsync(_service.MuteMessage.Replace("{g}", user.Guild.Name) .Replace("{t}", time.Humanize(5)) .Replace("{r}", reason)); } var name = user.Nickname == null ? user.Username : $"{user.Username} (nickname: {user.Nickname})"; await _log.LogModMessageAsync($"**{author.Nickname ?? author.Username}** muted {name} for {time.Humanize(5)}. Reason: `{reason}`"); var muteRole = Context.Guild.GetRole(_config.MuteRoleId); await user.AddRoleAsync(muteRole); var mute = await _records.AddMuteAsync(new Mute { GuildId = Context.Guild.Id, SubjectId = user.Id, ModeratorId = Context.User.Id, Timestamp = DateTime.UtcNow, UnmuteAt = DateTime.UtcNow.Add(time), Reason = reason, Active = true }); _records.DisposeContext(); _unpunish.Mutes.Add(mute); await ReplyAsync(":ok:"); }