Merge pull request #375 from LassieME/embed/fix-urls-add-timestamp

Adds Timestamps to embeds, and removes Image and Thumbnail-Builders
This commit is contained in:
RogueException
2016-11-27 00:20:15 -04:00
committed by GitHub
5 changed files with 47 additions and 81 deletions

View File

@@ -13,6 +13,7 @@ namespace Discord
public string Url { get; }
public string Title { get; }
public string Type { get; }
public DateTimeOffset? Timestamp { get; }
public Color? Color { get; }
public EmbedImage? Image { get; }
public EmbedVideo? Video { get; }
@@ -23,10 +24,11 @@ namespace Discord
public ImmutableArray<EmbedField> Fields { get; }
internal Embed(string type,
string title,
string description,
string url,
Color? color,
string title,
string description,
string url,
DateTimeOffset? timestamp,
Color? color,
EmbedImage? image,
EmbedVideo? video,
EmbedAuthor? author,
@@ -40,6 +42,7 @@ namespace Discord
Description = description;
Url = url;
Color = color;
Timestamp = timestamp;
Image = image;
Video = video;
Author = author;
@@ -50,15 +53,15 @@ namespace Discord
}
internal static Embed Create(Model model)
{
return new Embed(model.Type, model.Title, model.Description, model.Url,
model.Color.HasValue ? new Color(model.Color.Value) : (Color?)null,
return new Embed(model.Type, model.Title, model.Description, model.Url,model.Timestamp,
model.Color.HasValue ? new Color(model.Color.Value) : (Color?)null,
model.Image.IsSpecified ? EmbedImage.Create(model.Image.Value) : (EmbedImage?)null,
model.Video.IsSpecified ? EmbedVideo.Create(model.Video.Value) : (EmbedVideo?)null,
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.Fields.IsSpecified ? model.Fields.Value.Select(x => EmbedField.Create(x)).ToImmutableArray() : ImmutableArray.Create<EmbedField>());
model.Fields.IsSpecified ? model.Fields.Value.Select(EmbedField.Create).ToImmutableArray() : ImmutableArray.Create<EmbedField>());
}
public override string ToString() => Title;