private void CheckDefinitions(SelfUnverifyConfig selfUnverifyConfig, string name)
 {
     if (!ExistsInKeepDefinition(selfUnverifyConfig.RolesToKeep, name))
     {
         throw new ValidationException($"`{name.ToUpper()}` není ponechatelné.");
     }
 }
        private async Task SetRolesAsync(UnverifyUserProfile profile, SocketGuildUser user, SocketGuild guild, bool selfUnverify, List <string> toKeep,
                                         SelfUnverifyConfig selfUnverifyConfig, SocketRole mutedRole)
        {
            profile.RolesToRemove.AddRange(user.Roles);

            await FilterHigherRolesIfSelfunverifyAsync(profile, selfUnverify, guild);

            FilterUnavailableRoles(profile, mutedRole);

            if (toKeep == null || selfUnverifyConfig == null)
            {
                return;
            }

            foreach (var toKeepItem in toKeep)
            {
                CheckDefinitions(selfUnverifyConfig, toKeepItem);
                var role = profile.RolesToRemove.Find(o => string.Equals(o.Name, toKeepItem, StringComparison.InvariantCultureIgnoreCase));

                if (role != null)
                {
                    profile.RolesToKeep.Add(role);
                    profile.RolesToRemove.Remove(role);

                    continue;
                }

                foreach (var group in selfUnverifyConfig.RolesToKeep)
                {
                    if (group.Value == null)
                    {
                        continue;
                    }

                    if (group.Value.Contains(toKeepItem))
                    {
                        var roleItem = profile.RolesToRemove.Find(o => string.Equals(o.Name, group.Key == "_" ? toKeepItem : group.Key, StringComparison.InvariantCultureIgnoreCase));

                        if (roleItem != null)
                        {
                            profile.RolesToKeep.Add(roleItem);
                            profile.RolesToRemove.Remove(roleItem);
                        }
                    }
                }
            }
        }
        private void SetChannels(UnverifyUserProfile profile, SocketGuildUser user, List <string> toKeep, SelfUnverifyConfig selfUnverifyConfig)
        {
            var channels = user.Guild.Channels
                           .Select(channel => new ChannelOverwrite(channel, channel.GetPermissionOverwrite(user)))
                           .Where(channel => channel.Permissions != null && (channel.AllowValue > 0 || channel.DenyValue > 0))
                           .ToList();

            profile.ChannelsToRemove.AddRange(channels);

            if (toKeep == null || selfUnverifyConfig == null)
            {
                return;
            }

            foreach (var itemToKeep in toKeep)
            {
                CheckDefinitions(selfUnverifyConfig, itemToKeep);
                var overwrite = profile.ChannelsToRemove.Find(o => o.Channel.Name.Equals(itemToKeep, StringComparison.InvariantCultureIgnoreCase));

                if (overwrite != null)
                {
                    profile.ChannelsToKeep.Add(overwrite);
                    profile.ChannelsToRemove.RemoveAll(o => o.Channel.Id == overwrite.Channel.Id);
                }
            }
        }