Add helper classes to simplify embed creation for interactions
This commit is contained in:
parent
c15a66255f
commit
ea17ce2866
2 changed files with 41 additions and 10 deletions
|
@ -1,23 +1,24 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace Geekbot.Core.Interactions.Embed
|
||||
{
|
||||
/// <see href="https://discord.com/developers/docs/resources/channel#embed-object" />
|
||||
public record Embed
|
||||
public class Embed
|
||||
{
|
||||
/// <summary>
|
||||
/// title of embed
|
||||
/// </summary>
|
||||
[JsonPropertyName("title")]
|
||||
public string Title { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// type of embed (always "rich" for webhook embeds)
|
||||
/// </summary>
|
||||
[JsonPropertyName("type")]
|
||||
public EmbedTypes Type { get; set; }
|
||||
public EmbedTypes Type { get; set; } = EmbedTypes.Rich;
|
||||
|
||||
/// <summary>
|
||||
/// description of embed
|
||||
|
@ -41,7 +42,7 @@ namespace Geekbot.Core.Interactions.Embed
|
|||
/// color code of the embed
|
||||
/// </summary>
|
||||
[JsonPropertyName("color")]
|
||||
public int Color { get; set; }
|
||||
public uint Color { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// footer information
|
||||
|
@ -78,11 +79,31 @@ namespace Geekbot.Core.Interactions.Embed
|
|||
/// </summary>
|
||||
[JsonPropertyName("author")]
|
||||
public EmbedAuthor Author { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// fields information
|
||||
/// </summary>
|
||||
[JsonPropertyName("fields")]
|
||||
public List<EmbedField> Fields { get; set; }
|
||||
public List<EmbedField> Fields { get; set; } = new List<EmbedField>();
|
||||
|
||||
public void AddField(string name, string value, bool inline = false)
|
||||
{
|
||||
Fields.Add(new EmbedField()
|
||||
{
|
||||
Name = name,
|
||||
Value = value,
|
||||
Inline = inline
|
||||
});
|
||||
}
|
||||
|
||||
public void AddInlineField(string name, string value)
|
||||
{
|
||||
AddField(name, value, true);
|
||||
}
|
||||
|
||||
public void SetColor(Color c)
|
||||
{
|
||||
Color = (uint)(c.R << 16 | c.G << 8 | c.B);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue