Support Rich Embeds on Entities
This commit is contained in:
@@ -14,7 +14,7 @@ namespace Discord.API
|
||||
[JsonProperty("url")]
|
||||
public string Url { get; set; }
|
||||
[JsonProperty("color")]
|
||||
public uint Color { get; set; }
|
||||
public uint? Color { get; set; }
|
||||
[JsonProperty("author")]
|
||||
public Optional<EmbedAuthor> Author { get; set; }
|
||||
[JsonProperty("footer")]
|
||||
|
||||
29
src/Discord.Net.Core/Entities/Messages/EmbedAuthor.cs
Normal file
29
src/Discord.Net.Core/Entities/Messages/EmbedAuthor.cs
Normal file
@@ -0,0 +1,29 @@
|
||||
using System.Diagnostics;
|
||||
using Model = Discord.API.EmbedAuthor;
|
||||
|
||||
namespace Discord
|
||||
{
|
||||
[DebuggerDisplay("{DebuggerDisplay,nq}")]
|
||||
public struct EmbedAuthor
|
||||
{
|
||||
public string Name { get; set; }
|
||||
public string Url { get; set; }
|
||||
public string IconUrl { get; set; }
|
||||
public string ProxyIconUrl { get; set; }
|
||||
|
||||
private EmbedAuthor(string name, string url, string iconUrl, string proxyIconUrl)
|
||||
{
|
||||
Name = name;
|
||||
Url = url;
|
||||
IconUrl = iconUrl;
|
||||
ProxyIconUrl = proxyIconUrl;
|
||||
}
|
||||
internal static EmbedAuthor Create(Model model)
|
||||
{
|
||||
return new EmbedAuthor(model.Name, model.Url, model.IconUrl, model.ProxyIconUrl);
|
||||
}
|
||||
|
||||
private string DebuggerDisplay => $"{Name} ({Url})";
|
||||
public override string ToString() => Name;
|
||||
}
|
||||
}
|
||||
27
src/Discord.Net.Core/Entities/Messages/EmbedField.cs
Normal file
27
src/Discord.Net.Core/Entities/Messages/EmbedField.cs
Normal file
@@ -0,0 +1,27 @@
|
||||
using System.Diagnostics;
|
||||
using Model = Discord.API.EmbedField;
|
||||
|
||||
namespace Discord
|
||||
{
|
||||
[DebuggerDisplay("{DebuggerDisplay,nq}")]
|
||||
public struct EmbedField
|
||||
{
|
||||
public string Name { get; set; }
|
||||
public string Value { get; set; }
|
||||
public bool Inline { get; set; }
|
||||
|
||||
private EmbedField(string name, string value, bool inline)
|
||||
{
|
||||
Name = name;
|
||||
Value = value;
|
||||
Inline = inline;
|
||||
}
|
||||
internal static EmbedField Create(Model model)
|
||||
{
|
||||
return new EmbedField(model.Name, model.Value, model.Inline);
|
||||
}
|
||||
|
||||
private string DebuggerDisplay => $"{Name} ({Value}";
|
||||
public override string ToString() => Name;
|
||||
}
|
||||
}
|
||||
27
src/Discord.Net.Core/Entities/Messages/EmbedFooter.cs
Normal file
27
src/Discord.Net.Core/Entities/Messages/EmbedFooter.cs
Normal file
@@ -0,0 +1,27 @@
|
||||
using System.Diagnostics;
|
||||
using Model = Discord.API.EmbedFooter;
|
||||
|
||||
namespace Discord
|
||||
{
|
||||
[DebuggerDisplay("{DebuggerDisplay,nq}")]
|
||||
public struct EmbedFooter
|
||||
{
|
||||
public string Text { get; set; }
|
||||
public string IconUrl { get; set; }
|
||||
public string ProxyUrl { get; set; }
|
||||
|
||||
private EmbedFooter(string text, string iconUrl, string proxyUrl)
|
||||
{
|
||||
Text = text;
|
||||
IconUrl = iconUrl;
|
||||
ProxyUrl = proxyUrl;
|
||||
}
|
||||
internal static EmbedFooter Create(Model model)
|
||||
{
|
||||
return new EmbedFooter(model.Text, model.IconUrl, model.ProxyIconUrl);
|
||||
}
|
||||
|
||||
private string DebuggerDisplay => $"{Text} ({IconUrl})";
|
||||
public override string ToString() => Text;
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,6 @@
|
||||
namespace Discord
|
||||
using System.Collections.Immutable;
|
||||
|
||||
namespace Discord
|
||||
{
|
||||
public interface IEmbed
|
||||
{
|
||||
@@ -6,7 +8,11 @@
|
||||
string Type { get; }
|
||||
string Title { get; }
|
||||
string Description { get; }
|
||||
uint? Color { get; }
|
||||
EmbedAuthor? Author { get; }
|
||||
EmbedFooter? Footer { get; }
|
||||
EmbedProvider? Provider { get; }
|
||||
EmbedThumbnail? Thumbnail { get; }
|
||||
ImmutableArray<EmbedField> Fields { get; }
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user