Added initial support for role hoisting and colors

This commit is contained in:
RogueException
2015-10-13 04:04:42 -03:00
parent 10f1ff1905
commit 765647732c
2 changed files with 17 additions and 3 deletions

View File

@@ -260,9 +260,13 @@ namespace Discord.API
public class RoleInfo public class RoleInfo
{ {
[JsonProperty("permissions")] [JsonProperty("permissions")]
public uint Permissions; public uint? Permissions;
[JsonProperty("name")] [JsonProperty("name")]
public string Name; public string Name;
[JsonProperty("hoist")]
public bool? Hoist;
[JsonProperty("color")]
public uint? Color;
[JsonProperty("id")] [JsonProperty("id")]
public string Id; public string Id;
} }

View File

@@ -12,6 +12,10 @@ namespace Discord
public string Id { get; } public string Id { get; }
/// <summary> Returns the name of this role. </summary> /// <summary> Returns the name of this role. </summary>
public string Name { get; private set; } public string Name { get; private set; }
/// <summary> If true, this role is displayed isolated from other users. </summary>
public bool Hoist { get; private set; }
/// <summary> Returns the color of this role. </summary>
public uint Color { get; private set; }
/// <summary> Returns the the permissions contained by this role. </summary> /// <summary> Returns the the permissions contained by this role. </summary>
public PackedServerPermissions Permissions { get; } public PackedServerPermissions Permissions { get; }
@@ -41,8 +45,14 @@ namespace Discord
internal void Update(API.RoleInfo model) internal void Update(API.RoleInfo model)
{ {
Name = model.Name; if (model.Name != null)
Permissions.SetRawValue(model.Permissions); Name = model.Name;
if (model.Hoist != null)
Hoist = model.Hoist.Value;
if (model.Color != null)
Color = model.Color.Value;
if (model.Permissions != null)
Permissions.SetRawValue(model.Permissions.Value);
foreach (var member in Members) foreach (var member in Members)
member.UpdatePermissions(); member.UpdatePermissions();