From ceec287f65b297393ae50561472a741b030ff8f5 Mon Sep 17 00:00:00 2001 From: RogueException Date: Thu, 21 Jan 2016 17:45:06 -0400 Subject: [PATCH] Added a null check in Message deserialization, added missing video information --- src/Discord.Net/API/Client/Common/Message.cs | 12 ++++++------ src/Discord.Net/Models/Message.cs | 13 +++++++++---- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/src/Discord.Net/API/Client/Common/Message.cs b/src/Discord.Net/API/Client/Common/Message.cs index 7736d0ef1..7e9271dc9 100644 --- a/src/Discord.Net/API/Client/Common/Message.cs +++ b/src/Discord.Net/API/Client/Common/Message.cs @@ -18,9 +18,9 @@ namespace Discord.API.Client [JsonProperty("filename")] public string Filename { get; set; } [JsonProperty("width")] - public int Width { get; set; } + public int? Width { get; set; } [JsonProperty("height")] - public int Height { get; set; } + public int? Height { get; set; } } public class Embed @@ -40,18 +40,18 @@ namespace Discord.API.Client [JsonProperty("proxy_url")] public string ProxyUrl { get; set; } [JsonProperty("width")] - public int Width { get; set; } + public int? Width { get; set; } [JsonProperty("height")] - public int Height { get; set; } + public int? Height { get; set; } } public class VideoInfo { [JsonProperty("url")] public string Url { get; set; } [JsonProperty("width")] - public int Width { get; set; } + public int? Width { get; set; } [JsonProperty("height")] - public int Height { get; set; } + public int? Height { get; set; } } [JsonProperty("url")] diff --git a/src/Discord.Net/Models/Message.cs b/src/Discord.Net/Models/Message.cs index b6ef02a6c..e6e8b88f2 100644 --- a/src/Discord.Net/Models/Message.cs +++ b/src/Discord.Net/Models/Message.cs @@ -139,8 +139,10 @@ namespace Discord public EmbedLink Provider { get; internal set; } /// Returns the thumbnail of this embed. public File Thumbnail { get; internal set; } + /// Returns the video information of this embed. + public File Video { get; internal set; } - internal Embed() { } + internal Embed() { } } public class EmbedLink @@ -241,7 +243,7 @@ namespace Discord Embeds = model.Embeds.Select(x => { EmbedLink author = null, provider = null; - File thumbnail = null; + File thumbnail = null, video = null; if (x.Author != null) author = new EmbedLink { Url = x.Author.Url, Name = x.Author.Name }; @@ -249,8 +251,10 @@ namespace Discord provider = new EmbedLink { Url = x.Provider.Url, Name = x.Provider.Name }; if (x.Thumbnail != null) thumbnail = new File { Url = x.Thumbnail.Url, ProxyUrl = x.Thumbnail.ProxyUrl, Width = x.Thumbnail.Width, Height = x.Thumbnail.Height }; + if (x.Video != null) + video = new File { Url = x.Video.Url, ProxyUrl = x.Video.ProxyUrl, Width = x.Video.Width, Height = x.Video.Height }; - return new Embed + return new Embed { Url = x.Url, Type = x.Type, @@ -258,7 +262,8 @@ namespace Discord Description = x.Description, Author = author, Provider = provider, - Thumbnail = thumbnail + Thumbnail = thumbnail, + Video = video }; }).ToArray(); }