<commit_before>﻿using Discord.API.Client;
using Discord.API.Client.Rest;
using Discord.Net;
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.Threading.Tasks;

namespace Discord
{
    /// <summary> Represents a Discord server (also known as a guild). </summary>
	public sealed class Server
    {
        internal static string GetIconUrl(ulong serverId, string iconId)
            => iconId != null ? $"{DiscordConfig.CDNUrl}icons/{serverId}/{iconId}.jpg" : null;

        private struct Member
        {
            public readonly User User;
            public readonly ServerPermissions Permissions;
            public Member(User user)
            {
                User = user;
                Permissions = new ServerPermissions();
                Permissions.Lock();
            }
        }        

        private readonly ConcurrentDictionary<ulong, Role> _roles;
        private readonly ConcurrentDictionary<ulong, Member> _users;
        private readonly ConcurrentDictionary<ulong, Channel> _channels;
        private ulong _ownerId;
        private ulong? _afkChannelId;
        
        internal DiscordClient Client { get; }

        /// <summary> Gets the unique identifier for this server. </summary>
        public ulong Id { get; }
        /// <summary> Gets the default channel for this server. </summary>
        public Channel DefaultChannel { get; }
        /// <summary> Gets the the role representing all users in a server. </summary>
        public Role EveryoneRole { get; }

        /// <summary> Gets the name of this server. </summary>
        public string Name { get; private set; }
        /// <summary> Gets the voice region for this server. </summary>
        public Region Region { get; private set; }
        /// <summary> Gets the unique identifier for this user's current avatar. </summary>
        public string IconId { get; private set; }
        /// <summary> Gets the amount of time (in seconds) a user must be inactive for until they are automatically moved to the AFK voice channel, if one is set. </summary>
        public int AFKTimeout { get; private set; }
        /// <summary> Gets the date and time you joined this server. </summary>
        public DateTime JoinedAt { get; private set; }

        /// <summary> Gets the user that created this server. </summary>
        public User Owner => GetUser(_ownerId);
        /// <summary> Gets the AFK voice channel for this server. </summary>
        public Channel AFKChannel => _afkChannelId != null ? GetChannel(_afkChannelId.Value) : null;
        /// <summary> Gets the current user in this server. </summary>
        public User CurrentUser => GetUser(Client.CurrentUser.Id);
        /// <summary> Gets the URL to this user's current avatar. </summary>
        public string IconUrl => GetIconUrl(Id, IconId);
        
        /// <summary> Gets a collection of all channels in this server. </summary>
        public IEnumerable<Channel> AllChannels => _channels.Select(x => x.Value);
        /// <summary> Gets a collection of text channels in this server. </summary>
        public IEnumerable<Channel> TextChannels => _channels.Select(x => x.Value).Where(x => x.Type == ChannelType.Text);
        /// <summary> Gets a collection of voice channels in this server. </summary><commit_msg>Added Server.IsOwner<commit_after>﻿using Discord.API.Client;
using Discord.API.Client.Rest;
using Discord.Net;
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.Threading.Tasks;

namespace Discord
{
    /// <summary> Represents a Discord server (also known as a guild). </summary>
	public sealed class Server
    {
        internal static string GetIconUrl(ulong serverId, string iconId)
            => iconId != null ? $"{DiscordConfig.CDNUrl}icons/{serverId}/{iconId}.jpg" : null;

        private struct Member
        {
            public readonly User User;
            public readonly ServerPermissions Permissions;
            public Member(User user)
            {
                User = user;
                Permissions = new ServerPermissions();
                Permissions.Lock();
            }
        }        

        private readonly ConcurrentDictionary<ulong, Role> _roles;
        private readonly ConcurrentDictionary<ulong, Member> _users;
        private readonly ConcurrentDictionary<ulong, Channel> _channels;
        private ulong _ownerId;
        private ulong? _afkChannelId;
        
        internal DiscordClient Client { get; }

        /// <summary> Gets the unique identifier for this server. </summary>
        public ulong Id { get; }
        /// <summary> Gets the default channel for this server. </summary>
        public Channel DefaultChannel { get; }
        /// <summary> Gets the the role representing all users in a server. </summary>
        public Role EveryoneRole { get; }

        /// <summary> Gets the name of this server. </summary>
        public string Name { get; private set; }
        /// <summary> Gets the voice region for this server. </summary>
        public Region Region { get; private set; }
        /// <summary> Gets the unique identifier for this user's current avatar. </summary>
        public string IconId { get; private set; }
        /// <summary> Gets the amount of time (in seconds) a user must be inactive for until they are automatically moved to the AFK voice channel, if one is set. </summary>
        public int AFKTimeout { get; private set; }
        /// <summary> Gets the date and time you joined this server. </summary>
        public DateTime JoinedAt { get; private set; }

        /// <summary> Gets the user that created this server. </summary>
        public User Owner => GetUser(_ownerId);
        /// <summary> Returns true if the current user owns this server. </summary>
        public bool IsOwner => _ownerId == Client.CurrentUser.Id;
        /// <summary> Gets the AFK voice channel for this server. </summary>
        public Channel AFKChannel => _afkChannelId != null ? GetChannel(_afkChannelId.Value) : null;
        /// <summary> Gets the current user in this server. </summary>
        public User CurrentUser => GetUser(Client.CurrentUser.Id);
        /// <summary> Gets the URL to this user's current avatar. </summary>
        public string IconUrl => GetIconUrl(Id, IconId);
        
        /// <summary> Gets a collection of all channels in this server. </summary>
        public IEnumerable<Channel> AllChannels => _channels.Select(x => x.Value);
        /// <summary> Gets a collection of text channels in this server. </summary>
        public IEnumerable<Channel> TextChannels => _channels.Select(x => x.Value).Where(x => x.Type == ChannelType.Text);
        /// <summary> Gets a collection of voice channels in this server. </summary>
{'fraction_non_alphanumeric': 0.0971362786012376, 'fraction_numerical': 0.0, 'mean_word_length': 2.4767383691845923, 'pattern_counts': {'":': 0, '<': 79, '<?xml version=': 0, '>': 100, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4418609', 'n_tokens_mistral': 1759, 'n_tokens_neox': 1736, 'n_words': 688}