Hello,
I am trying to create a few Embed Builder helpers and was wondering if anyone has any ideas for a better approach. Currently I'm creating extensions based off of strings.
public static Embed ToSuccessfulEmbed(this string description, string? title = null, string? thumbnailUrl = null,
string? imageUrl = default, (string name, string iconUrl, string url) author = default, DateTimeOffset? timeStamp = default)
{
return description.ToEmbedBuilder(title, thumbnailUrl, imageUrl, Color.Green, author, timeStamp).Build();
}
public static EmbedBuilder ToEmbedBuilder(this string description, string? title = null, string? thumbnailUrl = null,
string? imageUrl = null, Color color = default, (string name, string iconUrl, string url) author = default,
DateTimeOffset? timeStamp = default)
{
var builder = new EmbedBuilder()
.WithTitle(title)
.WithDescription(description)
.WithColor(color)
.WithThumbnailUrl(thumbnailUrl)
.WithImageUrl(imageUrl);
if (timeStamp != default)
builder.Timestamp = DateTimeOffset.UtcNow.ConvertToDiscordTimestamp(TimestampFormat.RelativeTime);
if (author != default)
builder.WithAuthor(author.name, author.iconUrl, author.url);
return builder;
}
