Browse Source

Added initial support for role hoisting and colors

tags/docs-0.9
RogueException 9 years ago
parent
commit
765647732c
2 changed files with 17 additions and 3 deletions
  1. +5
    -1
      src/Discord.Net/API/Common.cs
  2. +12
    -2
      src/Discord.Net/Models/Role.cs

+ 5
- 1
src/Discord.Net/API/Common.cs View File

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


+ 12
- 2
src/Discord.Net/Models/Role.cs View File

@@ -12,6 +12,10 @@ namespace Discord
public string Id { get; }
/// <summary> Returns the name of this role. </summary>
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>
public PackedServerPermissions Permissions { get; }
@@ -41,8 +45,14 @@ namespace Discord

internal void Update(API.RoleInfo model)
{
Name = model.Name;
Permissions.SetRawValue(model.Permissions);
if (model.Name != null)
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)
member.UpdatePermissions();


Loading…
Cancel
Save