Exemplo n.º 1
0
        public async Task Unmute([Summary("The user to unmute")] SocketGuildUser user)
        {
            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 unmute someone above or equal to you in the role hierarchy.");

                return;
            }

            if (_service.UnmuteMessage != null && _service.UnmuteMessage != "")
            {
                var dmChannel = await user.GetOrCreateDMChannelAsync();

                await dmChannel.SendMessageAsync(_service.UnmuteMessage.Replace("{g}", user.Guild.Name));
            }

            var muteRole = Context.Guild.GetRole(_config.MuteRoleId);
            await user.RemoveRoleAsync(muteRole);

            await _records.DeactivateMutesForUserAsync(user.Id);

            _records.DisposeContext();
            _unpunish.Mutes.RemoveAll(x => x.SubjectId == user.Id);
            await ReplyAsync(":ok:");
        }