diff --git a/src/Core/Interactions/Embed/Embed.cs b/src/Core/Interactions/Embed/Embed.cs
index 1669a2d..fd994a8 100644
--- a/src/Core/Interactions/Embed/Embed.cs
+++ b/src/Core/Interactions/Embed/Embed.cs
@@ -1,23 +1,24 @@
using System;
using System.Collections.Generic;
+using System.Drawing;
using System.Text.Json.Serialization;
namespace Geekbot.Core.Interactions.Embed
{
///
- public record Embed
+ public class Embed
{
///
/// title of embed
///
[JsonPropertyName("title")]
public string Title { get; set; }
-
+
///
/// type of embed (always "rich" for webhook embeds)
///
[JsonPropertyName("type")]
- public EmbedTypes Type { get; set; }
+ public EmbedTypes Type { get; set; } = EmbedTypes.Rich;
///
/// description of embed
@@ -41,7 +42,7 @@ namespace Geekbot.Core.Interactions.Embed
/// color code of the embed
///
[JsonPropertyName("color")]
- public int Color { get; set; }
+ public uint Color { get; set; }
///
/// footer information
@@ -78,11 +79,31 @@ namespace Geekbot.Core.Interactions.Embed
///
[JsonPropertyName("author")]
public EmbedAuthor Author { get; set; }
-
+
///
/// fields information
///
[JsonPropertyName("fields")]
- public List Fields { get; set; }
+ public List Fields { get; set; } = new List();
+
+ 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);
+ }
}
}
\ No newline at end of file
diff --git a/src/Core/Interactions/InteractionBase.cs b/src/Core/Interactions/InteractionBase.cs
index b763dcb..e0735d3 100644
--- a/src/Core/Interactions/InteractionBase.cs
+++ b/src/Core/Interactions/InteractionBase.cs
@@ -30,9 +30,7 @@ namespace Geekbot.Core.Interactions
return SimpleResponse(Localization.Internal.SomethingWentWrong);
}
- protected InteractionResponse SimpleResponse(string message)
- {
- return new InteractionResponse()
+ protected InteractionResponse SimpleResponse(string message) => new InteractionResponse()
{
Type = InteractionResponseType.ChannelMessageWithSource,
Data = new()
@@ -40,7 +38,19 @@ namespace Geekbot.Core.Interactions
Content = message
}
};
- }
+
+ protected InteractionResponse SimpleResponse(Embed.Embed embed) => new InteractionResponse()
+ {
+ Type = InteractionResponseType.ChannelMessageWithSource,
+ Data = new ()
+ {
+ Content = string.Empty,
+ Embeds = new ()
+ {
+ embed
+ }
+ }
+ };
public abstract Command GetCommandInfo();
public abstract Task Exec(Interaction interaction);