Added a null check in Message deserialization, added missing video information
This commit is contained in:
@@ -18,9 +18,9 @@ namespace Discord.API.Client
|
|||||||
[JsonProperty("filename")]
|
[JsonProperty("filename")]
|
||||||
public string Filename { get; set; }
|
public string Filename { get; set; }
|
||||||
[JsonProperty("width")]
|
[JsonProperty("width")]
|
||||||
public int Width { get; set; }
|
public int? Width { get; set; }
|
||||||
[JsonProperty("height")]
|
[JsonProperty("height")]
|
||||||
public int Height { get; set; }
|
public int? Height { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class Embed
|
public class Embed
|
||||||
@@ -40,18 +40,18 @@ namespace Discord.API.Client
|
|||||||
[JsonProperty("proxy_url")]
|
[JsonProperty("proxy_url")]
|
||||||
public string ProxyUrl { get; set; }
|
public string ProxyUrl { get; set; }
|
||||||
[JsonProperty("width")]
|
[JsonProperty("width")]
|
||||||
public int Width { get; set; }
|
public int? Width { get; set; }
|
||||||
[JsonProperty("height")]
|
[JsonProperty("height")]
|
||||||
public int Height { get; set; }
|
public int? Height { get; set; }
|
||||||
}
|
}
|
||||||
public class VideoInfo
|
public class VideoInfo
|
||||||
{
|
{
|
||||||
[JsonProperty("url")]
|
[JsonProperty("url")]
|
||||||
public string Url { get; set; }
|
public string Url { get; set; }
|
||||||
[JsonProperty("width")]
|
[JsonProperty("width")]
|
||||||
public int Width { get; set; }
|
public int? Width { get; set; }
|
||||||
[JsonProperty("height")]
|
[JsonProperty("height")]
|
||||||
public int Height { get; set; }
|
public int? Height { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
[JsonProperty("url")]
|
[JsonProperty("url")]
|
||||||
|
|||||||
@@ -139,8 +139,10 @@ namespace Discord
|
|||||||
public EmbedLink Provider { get; internal set; }
|
public EmbedLink Provider { get; internal set; }
|
||||||
/// <summary> Returns the thumbnail of this embed. </summary>
|
/// <summary> Returns the thumbnail of this embed. </summary>
|
||||||
public File Thumbnail { get; internal set; }
|
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
|
public class EmbedLink
|
||||||
@@ -241,7 +243,7 @@ namespace Discord
|
|||||||
Embeds = model.Embeds.Select(x =>
|
Embeds = model.Embeds.Select(x =>
|
||||||
{
|
{
|
||||||
EmbedLink author = null, provider = null;
|
EmbedLink author = null, provider = null;
|
||||||
File thumbnail = null;
|
File thumbnail = null, video = null;
|
||||||
|
|
||||||
if (x.Author != null)
|
if (x.Author != null)
|
||||||
author = new EmbedLink { Url = x.Author.Url, Name = x.Author.Name };
|
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 };
|
provider = new EmbedLink { Url = x.Provider.Url, Name = x.Provider.Name };
|
||||||
if (x.Thumbnail != null)
|
if (x.Thumbnail != null)
|
||||||
thumbnail = new File { Url = x.Thumbnail.Url, ProxyUrl = x.Thumbnail.ProxyUrl, Width = x.Thumbnail.Width, Height = x.Thumbnail.Height };
|
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,
|
Url = x.Url,
|
||||||
Type = x.Type,
|
Type = x.Type,
|
||||||
@@ -258,7 +262,8 @@ namespace Discord
|
|||||||
Description = x.Description,
|
Description = x.Description,
|
||||||
Author = author,
|
Author = author,
|
||||||
Provider = provider,
|
Provider = provider,
|
||||||
Thumbnail = thumbnail
|
Thumbnail = thumbnail,
|
||||||
|
Video = video
|
||||||
};
|
};
|
||||||
}).ToArray();
|
}).ToArray();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user