Browse Source

Add role emoji. Fixes #295

pull/1923/head
quin lynch 3 years ago
parent
commit
cd993a6d72
4 changed files with 34 additions and 3 deletions
  1. +7
    -0
      src/Discord.Net.Core/Entities/Roles/IRole.cs
  2. +3
    -1
      src/Discord.Net.Rest/API/Common/Role.cs
  3. +12
    -1
      src/Discord.Net.Rest/Entities/Roles/RestRole.cs
  4. +12
    -1
      src/Discord.Net.WebSocket/Entities/Roles/SocketRole.cs

+ 7
- 0
src/Discord.Net.Core/Entities/Roles/IRole.cs View File

@@ -58,6 +58,13 @@ namespace Discord
/// A string containing the hash of this role's icon. /// A string containing the hash of this role's icon.
/// </returns> /// </returns>
string Icon { get; } string Icon { get; }
/// <summary>
/// Gets the unicode emoji of this role.
/// </summary>
/// <remarks>
/// This field is mutually exclusive with <see cref="Icon"/>, either icon is set or emoji is set.
/// </remarks>
Emoji Emoji { get; }
/// <summary> /// <summary>
/// Gets the permissions granted to members of this role. /// Gets the permissions granted to members of this role.
/// </summary> /// </summary>


+ 3
- 1
src/Discord.Net.Rest/API/Common/Role.cs View File

@@ -9,7 +9,9 @@ namespace Discord.API
[JsonProperty("name")] [JsonProperty("name")]
public string Name { get; set; } public string Name { get; set; }
[JsonProperty("icon")] [JsonProperty("icon")]
public string Icon { get; set; }
public Optional<string> Icon { get; set; }
[JsonProperty("unicode_emoji")]
public Optional<string> Emoji { get; set; }
[JsonProperty("color")] [JsonProperty("color")]
public uint Color { get; set; } public uint Color { get; set; }
[JsonProperty("hoist")] [JsonProperty("hoist")]


+ 12
- 1
src/Discord.Net.Rest/Entities/Roles/RestRole.cs View File

@@ -25,6 +25,8 @@ namespace Discord.Rest
public string Name { get; private set; } public string Name { get; private set; }
/// <inheritdoc /> /// <inheritdoc />
public string Icon { get; private set; } public string Icon { get; private set; }
/// <inheritdoc>/>
public Emoji Emoji { get; private set; }
/// <inheritdoc /> /// <inheritdoc />
public GuildPermissions Permissions { get; private set; } public GuildPermissions Permissions { get; private set; }
/// <inheritdoc /> /// <inheritdoc />
@@ -55,7 +57,6 @@ namespace Discord.Rest
internal void Update(Model model) internal void Update(Model model)
{ {
Name = model.Name; Name = model.Name;
Icon = model.Icon;
IsHoisted = model.Hoist; IsHoisted = model.Hoist;
IsManaged = model.Managed; IsManaged = model.Managed;
IsMentionable = model.Mentionable; IsMentionable = model.Mentionable;
@@ -64,6 +65,16 @@ namespace Discord.Rest
Permissions = new GuildPermissions(model.Permissions); Permissions = new GuildPermissions(model.Permissions);
if (model.Tags.IsSpecified) if (model.Tags.IsSpecified)
Tags = model.Tags.Value.ToEntity(); Tags = model.Tags.Value.ToEntity();

if (model.Icon.IsSpecified)
{
Icon = model.Icon.Value;
}

if (model.Emoji.IsSpecified)
{
Emoji = new Emoji(model.Emoji.Value);
}
} }


/// <inheritdoc /> /// <inheritdoc />


+ 12
- 1
src/Discord.Net.WebSocket/Entities/Roles/SocketRole.cs View File

@@ -33,6 +33,8 @@ namespace Discord.WebSocket
public bool IsMentionable { get; private set; } public bool IsMentionable { get; private set; }
/// <inheritdoc /> /// <inheritdoc />
public string Name { get; private set; } public string Name { get; private set; }
/// <inheritdoc/>
public Emoji Emoji { get; private set; }
/// <inheritdoc /> /// <inheritdoc />
public string Icon { get; private set; } public string Icon { get; private set; }
/// <inheritdoc /> /// <inheritdoc />
@@ -74,7 +76,6 @@ namespace Discord.WebSocket
internal void Update(ClientState state, Model model) internal void Update(ClientState state, Model model)
{ {
Name = model.Name; Name = model.Name;
Icon = model.Icon;
IsHoisted = model.Hoist; IsHoisted = model.Hoist;
IsManaged = model.Managed; IsManaged = model.Managed;
IsMentionable = model.Mentionable; IsMentionable = model.Mentionable;
@@ -83,6 +84,16 @@ namespace Discord.WebSocket
Permissions = new GuildPermissions(model.Permissions); Permissions = new GuildPermissions(model.Permissions);
if (model.Tags.IsSpecified) if (model.Tags.IsSpecified)
Tags = model.Tags.Value.ToEntity(); Tags = model.Tags.Value.ToEntity();

if (model.Icon.IsSpecified)
{
Icon = model.Icon.Value;
}

if (model.Emoji.IsSpecified)
{
Emoji = new Emoji(model.Emoji.Value);
}
} }


/// <inheritdoc /> /// <inheritdoc />


Loading…
Cancel
Save