Support Rich Embeds on Entities

This commit is contained in:
Christopher F
2016-11-12 23:23:38 -05:00
parent 6e8d1118ec
commit 63b06ff477
6 changed files with 113 additions and 6 deletions

View File

@@ -14,7 +14,7 @@ namespace Discord.API
[JsonProperty("url")]
public string Url { get; set; }
[JsonProperty("color")]
public uint Color { get; set; }
public uint? Color { get; set; }
[JsonProperty("author")]
public Optional<EmbedAuthor> Author { get; set; }
[JsonProperty("footer")]

View File

@@ -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;
}
}

View File

@@ -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;
}
}

View File

@@ -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;
}
}

View File

@@ -1,4 +1,6 @@
namespace Discord
using System.Collections.Immutable;
namespace Discord
{
public interface IEmbed
{
@@ -6,7 +8,11 @@
string Type { get; }
string Title { get; }
string Description { get; }
uint? Color { get; }
EmbedAuthor? Author { get; }
EmbedFooter? Footer { get; }
EmbedProvider? Provider { get; }
EmbedThumbnail? Thumbnail { get; }
ImmutableArray<EmbedField> Fields { get; }
}
}