Added Server.ChannelCount, UserCount, RoleCount. Updated several GatewaySocket API models.
This commit is contained in:
@@ -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("member_count")]
|
||||||
{
|
public int? MemberCount { get; set; }
|
||||||
[JsonProperty("mute")]
|
|
||||||
public bool? IsServerMuted { get; set; }
|
|
||||||
[JsonProperty("deaf")]
|
|
||||||
public bool? IsServerDeafened { get; set; }
|
|
||||||
}
|
|
||||||
|
|
||||||
[JsonProperty("channels")]
|
|
||||||
public Channel[] Channels { get; set; }
|
|
||||||
[JsonProperty("members")]
|
|
||||||
public ExtendedMemberInfo[] Members { get; set; }
|
|
||||||
[JsonProperty("presences")]
|
|
||||||
public MemberPresence[] Presences { get; set; }
|
|
||||||
[JsonProperty("voice_states")]
|
|
||||||
public MemberVoiceState[] VoiceStates { get; set; }
|
|
||||||
[JsonProperty("large")]
|
[JsonProperty("large")]
|
||||||
public bool IsLarge { get; set; }
|
public bool IsLarge { get; set; }
|
||||||
[JsonProperty("unavailable")]
|
[JsonProperty("unavailable")]
|
||||||
public bool? Unavailable { get; set; }
|
public bool? Unavailable { get; set; }
|
||||||
|
|
||||||
|
[JsonProperty("channels")]
|
||||||
|
public Channel[] Channels { get; set; }
|
||||||
|
[JsonProperty("members")]
|
||||||
|
public ExtendedMember[] Members { get; set; }
|
||||||
|
[JsonProperty("presences")]
|
||||||
|
public MemberPresence[] Presences { get; set; }
|
||||||
|
[JsonProperty("voice_states")]
|
||||||
|
public MemberVoiceState[] VoiceStates { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
12
src/Discord.Net/API/Client/Common/ExtendedMember.cs
Normal file
12
src/Discord.Net/API/Client/Common/ExtendedMember.cs
Normal file
@@ -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; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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; }
|
||||||
|
|
||||||
@@ -102,6 +103,13 @@ namespace Discord
|
|||||||
/// <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
|
||||||
|
|||||||
Reference in New Issue
Block a user