60 lines
1.7 KiB
C#
60 lines
1.7 KiB
C#
using Maki.Structures.Embeds;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
|
|
namespace Maki
|
|
{
|
|
public class DiscordEmbed
|
|
{
|
|
public string Title;
|
|
public string Description;
|
|
public string Url;
|
|
public DateTime DateTime = DateTime.MinValue;
|
|
public DiscordColour Colour;
|
|
public DiscordEmbedAuthor Author;
|
|
public DiscordEmbedField[] Fields;
|
|
public DiscordEmbedFooter Footer;
|
|
public DiscordEmbedImage Image;
|
|
public DiscordEmbedThumbnail Thumbnail;
|
|
|
|
internal Embed ToStruct()
|
|
{
|
|
Embed embed = new Embed() {
|
|
Title = Title,
|
|
Description = Description,
|
|
Url = Url,
|
|
};
|
|
|
|
if (DateTime != null && DateTime != DateTime.MinValue)
|
|
embed.Timestamp = DateTime;
|
|
|
|
if (Colour != null)
|
|
embed.Colour = Colour.Raw;
|
|
|
|
if (Author != null)
|
|
embed.Author = Author.ToStruct();
|
|
|
|
if (Fields != null && Fields.Length > 0)
|
|
{
|
|
List<EmbedField> fields = new List<EmbedField>();
|
|
|
|
foreach (DiscordEmbedField field in Fields)
|
|
if (!string.IsNullOrEmpty(field.Name) && !string.IsNullOrEmpty(field.Value))
|
|
fields.Add(field.ToStruct());
|
|
|
|
embed.Fields = fields.ToArray();
|
|
}
|
|
|
|
if (Footer != null)
|
|
embed.Footer = Footer.ToStruct();
|
|
|
|
if (Image != null)
|
|
embed.Image = Image.ToStruct();
|
|
|
|
if (Thumbnail != null)
|
|
embed.Thumbnail = Thumbnail.ToStruct();
|
|
|
|
return embed;
|
|
}
|
|
}
|
|
}
|