| @@ -14,7 +14,7 @@ namespace Discord.API | |||||
| [JsonProperty("url")] | [JsonProperty("url")] | ||||
| public string Url { get; set; } | public string Url { get; set; } | ||||
| [JsonProperty("color")] | [JsonProperty("color")] | ||||
| public uint Color { get; set; } | |||||
| public uint? Color { get; set; } | |||||
| [JsonProperty("author")] | [JsonProperty("author")] | ||||
| public Optional<EmbedAuthor> Author { get; set; } | public Optional<EmbedAuthor> Author { get; set; } | ||||
| [JsonProperty("footer")] | [JsonProperty("footer")] | ||||
| @@ -0,0 +1,29 @@ | |||||
| using System.Diagnostics; | |||||
| using Model = Discord.API.EmbedAuthor; | |||||
| namespace Discord | |||||
| { | |||||
| [DebuggerDisplay("{DebuggerDisplay,nq}")] | |||||
| public struct EmbedAuthor | |||||
| { | |||||
| public string Name { get; set; } | |||||
| public string Url { get; set; } | |||||
| public string IconUrl { get; set; } | |||||
| public string ProxyIconUrl { get; set; } | |||||
| private EmbedAuthor(string name, string url, string iconUrl, string proxyIconUrl) | |||||
| { | |||||
| Name = name; | |||||
| Url = url; | |||||
| IconUrl = iconUrl; | |||||
| ProxyIconUrl = proxyIconUrl; | |||||
| } | |||||
| internal static EmbedAuthor Create(Model model) | |||||
| { | |||||
| return new EmbedAuthor(model.Name, model.Url, model.IconUrl, model.ProxyIconUrl); | |||||
| } | |||||
| private string DebuggerDisplay => $"{Name} ({Url})"; | |||||
| public override string ToString() => Name; | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,27 @@ | |||||
| using System.Diagnostics; | |||||
| using Model = Discord.API.EmbedField; | |||||
| namespace Discord | |||||
| { | |||||
| [DebuggerDisplay("{DebuggerDisplay,nq}")] | |||||
| public struct EmbedField | |||||
| { | |||||
| public string Name { get; set; } | |||||
| public string Value { get; set; } | |||||
| public bool Inline { get; set; } | |||||
| private EmbedField(string name, string value, bool inline) | |||||
| { | |||||
| Name = name; | |||||
| Value = value; | |||||
| Inline = inline; | |||||
| } | |||||
| internal static EmbedField Create(Model model) | |||||
| { | |||||
| return new EmbedField(model.Name, model.Value, model.Inline); | |||||
| } | |||||
| private string DebuggerDisplay => $"{Name} ({Value}"; | |||||
| public override string ToString() => Name; | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,27 @@ | |||||
| using System.Diagnostics; | |||||
| using Model = Discord.API.EmbedFooter; | |||||
| namespace Discord | |||||
| { | |||||
| [DebuggerDisplay("{DebuggerDisplay,nq}")] | |||||
| public struct EmbedFooter | |||||
| { | |||||
| public string Text { get; set; } | |||||
| public string IconUrl { get; set; } | |||||
| public string ProxyUrl { get; set; } | |||||
| private EmbedFooter(string text, string iconUrl, string proxyUrl) | |||||
| { | |||||
| Text = text; | |||||
| IconUrl = iconUrl; | |||||
| ProxyUrl = proxyUrl; | |||||
| } | |||||
| internal static EmbedFooter Create(Model model) | |||||
| { | |||||
| return new EmbedFooter(model.Text, model.IconUrl, model.ProxyIconUrl); | |||||
| } | |||||
| private string DebuggerDisplay => $"{Text} ({IconUrl})"; | |||||
| public override string ToString() => Text; | |||||
| } | |||||
| } | |||||
| @@ -1,4 +1,6 @@ | |||||
| namespace Discord | |||||
| using System.Collections.Immutable; | |||||
| namespace Discord | |||||
| { | { | ||||
| public interface IEmbed | public interface IEmbed | ||||
| { | { | ||||
| @@ -6,7 +8,11 @@ | |||||
| string Type { get; } | string Type { get; } | ||||
| string Title { get; } | string Title { get; } | ||||
| string Description { get; } | string Description { get; } | ||||
| uint? Color { get; } | |||||
| EmbedAuthor? Author { get; } | |||||
| EmbedFooter? Footer { get; } | |||||
| EmbedProvider? Provider { get; } | EmbedProvider? Provider { get; } | ||||
| EmbedThumbnail? Thumbnail { get; } | EmbedThumbnail? Thumbnail { get; } | ||||
| ImmutableArray<EmbedField> Fields { get; } | |||||
| } | } | ||||
| } | } | ||||
| @@ -1,4 +1,6 @@ | |||||
| using System.Diagnostics; | |||||
| using System.Collections.Immutable; | |||||
| using System.Diagnostics; | |||||
| using System.Linq; | |||||
| using Model = Discord.API.Embed; | using Model = Discord.API.Embed; | ||||
| namespace Discord | namespace Discord | ||||
| @@ -10,10 +12,23 @@ namespace Discord | |||||
| public string Url { get; } | public string Url { get; } | ||||
| public string Title { get; } | public string Title { get; } | ||||
| public string Type { get; } | public string Type { get; } | ||||
| public uint? Color { get; } | |||||
| public EmbedAuthor? Author { get; } | |||||
| public EmbedFooter? Footer { get; } | |||||
| public EmbedProvider? Provider { get; } | public EmbedProvider? Provider { get; } | ||||
| public EmbedThumbnail? Thumbnail { get; } | public EmbedThumbnail? Thumbnail { get; } | ||||
| public ImmutableArray<EmbedField> Fields { get; } | |||||
| internal Embed(string type, string title, string description, string url, EmbedProvider? provider, EmbedThumbnail? thumbnail) | |||||
| internal Embed(string type, | |||||
| string title, | |||||
| string description, | |||||
| string url, | |||||
| uint? color, | |||||
| EmbedAuthor? author, | |||||
| EmbedFooter? footer, | |||||
| EmbedProvider? provider, | |||||
| EmbedThumbnail? thumbnail, | |||||
| ImmutableArray<EmbedField> fields) | |||||
| { | { | ||||
| Type = type; | Type = type; | ||||
| Title = title; | Title = title; | ||||
| @@ -24,9 +39,12 @@ namespace Discord | |||||
| } | } | ||||
| internal static Embed Create(Model model) | internal static Embed Create(Model model) | ||||
| { | { | ||||
| return new Embed(model.Type, model.Title, model.Description, model.Url, | |||||
| return new Embed(model.Type, model.Title, model.Description, model.Url, model.Color, | |||||
| model.Author.IsSpecified ? EmbedAuthor.Create(model.Author.Value) : (EmbedAuthor?)null, | |||||
| model.Footer.IsSpecified ? EmbedFooter.Create(model.Footer.Value) : (EmbedFooter?)null, | |||||
| model.Provider.IsSpecified ? EmbedProvider.Create(model.Provider.Value) : (EmbedProvider?)null, | model.Provider.IsSpecified ? EmbedProvider.Create(model.Provider.Value) : (EmbedProvider?)null, | ||||
| model.Thumbnail.IsSpecified ? EmbedThumbnail.Create(model.Thumbnail.Value) : (EmbedThumbnail?)null); | |||||
| model.Thumbnail.IsSpecified ? EmbedThumbnail.Create(model.Thumbnail.Value) : (EmbedThumbnail?)null, | |||||
| model.Fields.IsSpecified ? model.Fields.Value.Select(x => EmbedField.Create(x)).ToImmutableArray() : ImmutableArray.Create<EmbedField>()); | |||||
| } | } | ||||
| public override string ToString() => Title; | public override string ToString() => Title; | ||||