Co-authored-by: Chris Johnston <chris@thejohnstons.net> commitpull/1219/head23f5abba48
Author: Christopher Felegy <foxbot@protonmail.com> Date: Thu Dec 20 17:10:21 2018 -0500 lint: clean up some long lines commit4a8a809db0
Author: Chris Johnston <chris@thejohnstons.net> Date: Sat Dec 15 00:33:05 2018 -0800 Explain why CreatorId can be null sometimes commit9442e4e635
Author: Chris Johnston <chris@thejohnstons.net> Date: Fri Dec 14 23:59:01 2018 -0800 Add the CreatorId property to GuildEmote implementation commite0eb94d44c
Author: Chris Johnston <chris@thejohnstons.net> Date: Fri Dec 14 23:41:54 2018 -0800 Update the Emoji API model to add User? attribute
@@ -30,12 +30,20 @@ namespace Discord | |||||
/// A read-only list containing snowflake identifiers for roles that are allowed to use this emoji. | /// A read-only list containing snowflake identifiers for roles that are allowed to use this emoji. | ||||
/// </returns> | /// </returns> | ||||
public IReadOnlyList<ulong> RoleIds { get; } | public IReadOnlyList<ulong> RoleIds { get; } | ||||
/// <summary> | |||||
/// Gets the user Id that created this emoji. | |||||
/// </summary> | |||||
/// <returns> | |||||
/// A user Id of the user who created this emoji, which may be null. A null value only indicates that the creator was not supplied as part of the API response. | |||||
/// </returns> | |||||
public ulong? CreatorId { get; } | |||||
internal GuildEmote(ulong id, string name, bool animated, bool isManaged, bool requireColons, IReadOnlyList<ulong> roleIds) : base(id, name, animated) | |||||
internal GuildEmote(ulong id, string name, bool animated, bool isManaged, bool requireColons, IReadOnlyList<ulong> roleIds, ulong? userId) : base(id, name, animated) | |||||
{ | { | ||||
IsManaged = isManaged; | IsManaged = isManaged; | ||||
RequireColons = requireColons; | RequireColons = requireColons; | ||||
RoleIds = roleIds; | RoleIds = roleIds; | ||||
CreatorId = userId; | |||||
} | } | ||||
private string DebuggerDisplay => $"{Name} ({Id})"; | private string DebuggerDisplay => $"{Name} ({Id})"; | ||||
@@ -1,4 +1,4 @@ | |||||
#pragma warning disable CS1591 | |||||
#pragma warning disable CS1591 | |||||
using Newtonsoft.Json; | using Newtonsoft.Json; | ||||
namespace Discord.API | namespace Discord.API | ||||
@@ -17,5 +17,7 @@ namespace Discord.API | |||||
public bool RequireColons { get; set; } | public bool RequireColons { get; set; } | ||||
[JsonProperty("managed")] | [JsonProperty("managed")] | ||||
public bool Managed { get; set; } | public bool Managed { get; set; } | ||||
[JsonProperty("user")] | |||||
public Optional<User> User { get; set; } | |||||
} | } | ||||
} | } |
@@ -1,4 +1,4 @@ | |||||
using System.Collections.Immutable; | |||||
using System.Collections.Immutable; | |||||
using System.Linq; | using System.Linq; | ||||
namespace Discord.Rest | namespace Discord.Rest | ||||
@@ -6,9 +6,13 @@ namespace Discord.Rest | |||||
internal static class EntityExtensions | internal static class EntityExtensions | ||||
{ | { | ||||
public static GuildEmote ToEntity(this API.Emoji model) | public static GuildEmote ToEntity(this API.Emoji model) | ||||
{ | |||||
return new GuildEmote(model.Id.Value, model.Name, model.Animated.GetValueOrDefault(), model.Managed, model.RequireColons, ImmutableArray.Create(model.Roles)); | |||||
} | |||||
=> new GuildEmote(model.Id.Value, | |||||
model.Name, | |||||
model.Animated.GetValueOrDefault(), | |||||
model.Managed, | |||||
model.RequireColons, | |||||
ImmutableArray.Create(model.Roles), | |||||
model.User.IsSpecified ? model.User.Value.Id : (ulong?)null); | |||||
public static Embed ToEntity(this API.Embed model) | public static Embed ToEntity(this API.Embed model) | ||||
{ | { | ||||