Added a null check in Message deserialization, added missing video information

This commit is contained in:
RogueException
2016-01-21 17:45:06 -04:00
parent 0db0675cb5
commit ceec287f65
2 changed files with 15 additions and 10 deletions

View File

@@ -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")]

View File

@@ -139,8 +139,10 @@ namespace Discord
public EmbedLink Provider { get; internal set; }
/// <summary> Returns the thumbnail of this embed. </summary>
public File Thumbnail { get; internal set; }
/// <summary> Returns the video information of this embed. </summary>
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();
}