| @@ -67,6 +67,9 @@ | |||||
| <Compile Include="..\Discord.Net\API\Client\Common\ExtendedGuild.cs"> | <Compile Include="..\Discord.Net\API\Client\Common\ExtendedGuild.cs"> | ||||
| <Link>API\Client\Common\ExtendedGuild.cs</Link> | <Link>API\Client\Common\ExtendedGuild.cs</Link> | ||||
| </Compile> | </Compile> | ||||
| <Compile Include="..\Discord.Net\API\Client\Common\ExtendedMember.cs"> | |||||
| <Link>API\Client\Common\ExtendedMember.cs</Link> | |||||
| </Compile> | |||||
| <Compile Include="..\Discord.Net\API\Client\Common\Guild.cs"> | <Compile Include="..\Discord.Net\API\Client\Common\Guild.cs"> | ||||
| <Link>API\Client\Common\Guild.cs</Link> | <Link>API\Client\Common\Guild.cs</Link> | ||||
| </Compile> | </Compile> | ||||
| @@ -4,25 +4,20 @@ namespace Discord.API.Client | |||||
| { | { | ||||
| public class ExtendedGuild : Guild | public class ExtendedGuild : Guild | ||||
| { | { | ||||
| public class ExtendedMemberInfo : Member | |||||
| { | |||||
| [JsonProperty("mute")] | |||||
| public bool? IsServerMuted { get; set; } | |||||
| [JsonProperty("deaf")] | |||||
| public bool? IsServerDeafened { get; set; } | |||||
| } | |||||
| [JsonProperty("member_count")] | |||||
| public int? MemberCount { get; set; } | |||||
| [JsonProperty("large")] | |||||
| public bool IsLarge { get; set; } | |||||
| [JsonProperty("unavailable")] | |||||
| public bool? Unavailable { get; set; } | |||||
| [JsonProperty("channels")] | [JsonProperty("channels")] | ||||
| public Channel[] Channels { get; set; } | public Channel[] Channels { get; set; } | ||||
| [JsonProperty("members")] | [JsonProperty("members")] | ||||
| public ExtendedMemberInfo[] Members { get; set; } | |||||
| public ExtendedMember[] Members { get; set; } | |||||
| [JsonProperty("presences")] | [JsonProperty("presences")] | ||||
| public MemberPresence[] Presences { get; set; } | public MemberPresence[] Presences { get; set; } | ||||
| [JsonProperty("voice_states")] | [JsonProperty("voice_states")] | ||||
| public MemberVoiceState[] VoiceStates { get; set; } | public MemberVoiceState[] VoiceStates { get; set; } | ||||
| [JsonProperty("large")] | |||||
| public bool IsLarge { get; set; } | |||||
| [JsonProperty("unavailable")] | |||||
| public bool? Unavailable { get; set; } | |||||
| } | } | ||||
| } | } | ||||
| @@ -0,0 +1,12 @@ | |||||
| using Newtonsoft.Json; | |||||
| namespace Discord.API.Client | |||||
| { | |||||
| public class ExtendedMember : Member | |||||
| { | |||||
| [JsonProperty("mute")] | |||||
| public bool? IsServerMuted { get; set; } | |||||
| [JsonProperty("deaf")] | |||||
| public bool? IsServerDeafened { get; set; } | |||||
| } | |||||
| } | |||||
| @@ -44,5 +44,7 @@ namespace Discord.API.Client | |||||
| public EmojiData[] Emojis { get; set; } | public EmojiData[] Emojis { get; set; } | ||||
| [JsonProperty("splash")] | [JsonProperty("splash")] | ||||
| public string Splash { get; set; } | public string Splash { get; set; } | ||||
| [JsonProperty("verification_level")] | |||||
| public int VerificationLevel { get; set; } | |||||
| } | } | ||||
| } | } | ||||
| @@ -8,6 +8,6 @@ namespace Discord.API.Client.GatewaySocket | |||||
| [JsonProperty("guild_id"), JsonConverter(typeof(LongStringConverter))] | [JsonProperty("guild_id"), JsonConverter(typeof(LongStringConverter))] | ||||
| public ulong GuildId { get; set; } | public ulong GuildId { get; set; } | ||||
| [JsonProperty("members")] | [JsonProperty("members")] | ||||
| public Member[] Members { get; set; } | |||||
| public ExtendedMember[] Members { get; set; } | |||||
| } | } | ||||
| } | } | ||||
| @@ -34,5 +34,7 @@ namespace Discord.API.Client.GatewaySocket | |||||
| public object UserSettings { get; set; } | public object UserSettings { get; set; } | ||||
| [JsonProperty("user_guild_settings")] | [JsonProperty("user_guild_settings")] | ||||
| public object UserGuildSettings { get; set; } | public object UserGuildSettings { get; set; } | ||||
| [JsonProperty("tutorial")] | |||||
| public object Tutorial { get; set; } | |||||
| } | } | ||||
| } | } | ||||
| @@ -72,7 +72,7 @@ namespace Discord | |||||
| public IEnumerable<Message> Messages => _messages?.Values ?? Enumerable.Empty<Message>(); | public IEnumerable<Message> Messages => _messages?.Values ?? Enumerable.Empty<Message>(); | ||||
| /// <summary> Gets a collection of all custom permissions used for this channel. </summary> | /// <summary> Gets a collection of all custom permissions used for this channel. </summary> | ||||
| public IEnumerable<PermissionOverwrite> PermissionOverwrites => _permissionOverwrites.Select(x => x.Value); | public IEnumerable<PermissionOverwrite> PermissionOverwrites => _permissionOverwrites.Select(x => x.Value); | ||||
| /// <summary> Gets a collection of all users with read access to this channel. </summary> | /// <summary> Gets a collection of all users with read access to this channel. </summary> | ||||
| public IEnumerable<User> Users | public IEnumerable<User> Users | ||||
| { | { | ||||
| @@ -104,7 +104,7 @@ namespace Discord | |||||
| return Enumerable.Empty<User>(); | return Enumerable.Empty<User>(); | ||||
| } | } | ||||
| } | } | ||||
| internal Channel(DiscordClient client, ulong id, Server server) | internal Channel(DiscordClient client, ulong id, Server server) | ||||
| : this(client, id) | : this(client, id) | ||||
| { | { | ||||
| @@ -51,6 +51,7 @@ namespace Discord | |||||
| private readonly ConcurrentDictionary<ulong, Channel> _channels; | private readonly ConcurrentDictionary<ulong, Channel> _channels; | ||||
| private ulong _ownerId; | private ulong _ownerId; | ||||
| private ulong? _afkChannelId; | private ulong? _afkChannelId; | ||||
| private int _userCount; | |||||
| public DiscordClient Client { get; } | public DiscordClient Client { get; } | ||||
| @@ -101,7 +102,14 @@ namespace Discord | |||||
| public IEnumerable<User> Users => _users.Select(x => x.Value.User); | public IEnumerable<User> Users => _users.Select(x => x.Value.User); | ||||
| /// <summary> Gets a collection of all roles in this server. </summary> | /// <summary> Gets a collection of all roles in this server. </summary> | ||||
| public IEnumerable<Role> Roles => _roles.Select(x => x.Value); | public IEnumerable<Role> Roles => _roles.Select(x => x.Value); | ||||
| /// <summary> Gets the number of channels in this server. </summary> | |||||
| public int ChannelCount => _channels.Count; | |||||
| /// <summary> Gets the number of users in this server. </summary> | |||||
| public int UserCount => _userCount; | |||||
| /// <summary> Gets the number of roles in this server. </summary> | |||||
| public int RoleCount => _channels.Count; | |||||
| internal Server(DiscordClient client, ulong id) | internal Server(DiscordClient client, ulong id) | ||||
| { | { | ||||
| Client = client; | Client = client; | ||||
| @@ -179,6 +187,8 @@ namespace Discord | |||||
| foreach (var subModel in model.Presences) | foreach (var subModel in model.Presences) | ||||
| GetUser(subModel.User.Id)?.Update(subModel); | GetUser(subModel.User.Id)?.Update(subModel); | ||||
| } | } | ||||
| if (model.MemberCount != null) | |||||
| _userCount = model.MemberCount.Value; | |||||
| } | } | ||||
| /// <summary> Edits this server, changing only non-null attributes. </summary> | /// <summary> Edits this server, changing only non-null attributes. </summary> | ||||
| @@ -436,6 +446,7 @@ namespace Discord | |||||
| #region Users | #region Users | ||||
| internal User AddUser(ulong id) | internal User AddUser(ulong id) | ||||
| { | { | ||||
| _userCount++; | |||||
| Member member = new Member(new User(Client, id, this), ServerPermissions.None); | Member member = new Member(new User(Client, id, this), ServerPermissions.None); | ||||
| if (id == Client.CurrentUser.Id) | if (id == Client.CurrentUser.Id) | ||||
| { | { | ||||
| @@ -452,6 +463,7 @@ namespace Discord | |||||
| } | } | ||||
| internal User RemoveUser(ulong id) | internal User RemoveUser(ulong id) | ||||
| { | { | ||||
| _userCount--; | |||||
| Member member; | Member member; | ||||
| if (_users.TryRemove(id, out member)) | if (_users.TryRemove(id, out member)) | ||||
| { | { | ||||
| @@ -169,7 +169,7 @@ namespace Discord | |||||
| if (model.Roles != null) | if (model.Roles != null) | ||||
| UpdateRoles(model.Roles.Select(x => Server.GetRole(x))); | UpdateRoles(model.Roles.Select(x => Server.GetRole(x))); | ||||
| } | } | ||||
| internal void Update(ExtendedGuild.ExtendedMemberInfo model) | |||||
| internal void Update(ExtendedMember model) | |||||
| { | { | ||||
| Update(model as APIMember); | Update(model as APIMember); | ||||
| @@ -1,5 +1,8 @@ | |||||
| using Discord.Logging; | using Discord.Logging; | ||||
| using Newtonsoft.Json; | using Newtonsoft.Json; | ||||
| #if TEST_RESPONSES | |||||
| using System; | |||||
| #endif | |||||
| using System.IO; | using System.IO; | ||||
| namespace Discord.Net.Rest | namespace Discord.Net.Rest | ||||