|
@@ -164,35 +164,45 @@ namespace Discord |
|
|
/// <returns><see langword="true"/> if <paramref name="json"/> was succesfully parsed. <see langword="false"/> if not.</returns> |
|
|
/// <returns><see langword="true"/> if <paramref name="json"/> was succesfully parsed. <see langword="false"/> if not.</returns> |
|
|
public static bool TryParse(string json, out EmbedBuilder builder) |
|
|
public static bool TryParse(string json, out EmbedBuilder builder) |
|
|
{ |
|
|
{ |
|
|
var model = JsonConvert.DeserializeObject<Embed>(json); |
|
|
|
|
|
|
|
|
|
|
|
builder = new EmbedBuilder(); |
|
|
builder = new EmbedBuilder(); |
|
|
|
|
|
|
|
|
if (model is not null) |
|
|
|
|
|
|
|
|
try |
|
|
{ |
|
|
{ |
|
|
builder = model.ToEmbedBuilder(); |
|
|
|
|
|
return true; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
var model = JsonConvert.DeserializeObject<Embed>(json); |
|
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
|
if (model is not null) |
|
|
|
|
|
{ |
|
|
|
|
|
builder = model.ToEmbedBuilder(); |
|
|
|
|
|
return true; |
|
|
|
|
|
} |
|
|
|
|
|
return false; |
|
|
|
|
|
} |
|
|
|
|
|
catch |
|
|
|
|
|
{ |
|
|
return false; |
|
|
return false; |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/// <summary> |
|
|
/// <summary> |
|
|
/// Parses a string into an <see cref="EmbedBuilder"/>. |
|
|
/// Parses a string into an <see cref="EmbedBuilder"/>. |
|
|
/// </summary> |
|
|
/// </summary> |
|
|
/// <param name="json">The json string to parse.</param> |
|
|
/// <param name="json">The json string to parse.</param> |
|
|
/// <returns>An <see cref="EmbedBuilder"/> with populated values from the passed <paramref name="json"/></returns> |
|
|
|
|
|
|
|
|
/// <returns>An <see cref="EmbedBuilder"/> with populated values from the passed <paramref name="json"/>.</returns> |
|
|
/// <exception cref="InvalidOperationException">Thrown if the string passed is not valid json.</exception> |
|
|
/// <exception cref="InvalidOperationException">Thrown if the string passed is not valid json.</exception> |
|
|
public static EmbedBuilder Parse(string json) |
|
|
public static EmbedBuilder Parse(string json) |
|
|
{ |
|
|
{ |
|
|
var model = JsonConvert.DeserializeObject<Embed>(json); |
|
|
|
|
|
|
|
|
try |
|
|
|
|
|
{ |
|
|
|
|
|
var model = JsonConvert.DeserializeObject<Embed>(json); |
|
|
|
|
|
|
|
|
if (model is not null) |
|
|
|
|
|
return model.ToEmbedBuilder(); |
|
|
|
|
|
|
|
|
if (model is not null) |
|
|
|
|
|
return model.ToEmbedBuilder(); |
|
|
|
|
|
|
|
|
else |
|
|
|
|
|
throw new JsonSerializationException("The passed json string was not able to be parsed to an embed."); |
|
|
|
|
|
|
|
|
return new EmbedBuilder(); |
|
|
|
|
|
} |
|
|
|
|
|
catch |
|
|
|
|
|
{ |
|
|
|
|
|
throw; |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/// <summary> |
|
|
/// <summary> |
|
|