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

@@ -1,4 +1,6 @@
using System.Diagnostics;
using System.Collections.Immutable;
using System.Diagnostics;
using System.Linq;
using Model = Discord.API.Embed;
namespace Discord
@@ -10,10 +12,23 @@ namespace Discord
public string Url { get; }
public string Title { get; }
public string Type { get; }
public uint? Color { get; }
public EmbedAuthor? Author { get; }
public EmbedFooter? Footer { get; }
public EmbedProvider? Provider { 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;
Title = title;
@@ -24,9 +39,12 @@ namespace Discord
}
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.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;