Class EmbedBuilder
A builder for creating rich embeds with validation and a fluent API. Based on Fluxer.Net's EmbedBuilder implementation.
public class EmbedBuilder
- Inheritance
-
objectEmbedBuilder
Properties
Author
Gets or sets the author field of the embed.
public EmbedAuthorBuilder? Author { get; set; }
Property Value
Color
Gets or sets the color of the embed.
public int? Color { get; set; }
Property Value
- int?
Description
Gets or sets the description of the embed.
public string? Description { get; set; }
Property Value
Exceptions
- ArgumentException
Description length exceeds MaxDescriptionLength.
Fields
Gets the list of field builders for the embed.
public List<EmbedFieldBuilder> Fields { get; set; }
Property Value
Footer
Gets or sets the footer field of the embed.
public EmbedFooterBuilder? Footer { get; set; }
Property Value
ImageUrl
Gets or sets the image URL of the embed.
public string? ImageUrl { get; set; }
Property Value
Length
Gets the total length of all embed content.
public int Length { get; }
Property Value
MaxDescriptionLength
Maximum length of the description.
public static int MaxDescriptionLength { get; }
Property Value
MaxEmbedLength
Maximum total length of all embed content.
public static int MaxEmbedLength { get; }
Property Value
MaxFieldCount
Maximum number of fields allowed in an embed.
public static int MaxFieldCount { get; }
Property Value
MaxTitleLength
Maximum length of the title.
public static int MaxTitleLength { get; }
Property Value
ThumbnailUrl
Gets or sets the thumbnail URL of the embed.
public string? ThumbnailUrl { get; set; }
Property Value
Timestamp
Gets or sets the timestamp of the embed.
public DateTimeOffset? Timestamp { get; set; }
Property Value
Title
Gets or sets the title of the embed.
public string? Title { get; set; }
Property Value
Exceptions
- ArgumentException
Title length exceeds MaxTitleLength.
Url
Gets or sets the URL of the embed.
public string? Url { get; set; }
Property Value
Methods
AddField(EmbedFieldBuilder)
Adds a field to the embed.
public EmbedBuilder AddField(EmbedFieldBuilder field)
Parameters
fieldEmbedFieldBuilderThe field builder to add.
Returns
- EmbedBuilder
The current builder.
Exceptions
- ArgumentException
Field count exceeds MaxFieldCount.
AddField(Action<EmbedFieldBuilder>)
Adds a field to the embed using an action.
public EmbedBuilder AddField(Action<EmbedFieldBuilder> action)
Parameters
actionAction<EmbedFieldBuilder>The action to configure the field builder.
Returns
- EmbedBuilder
The current builder.
Exceptions
- ArgumentException
Field count exceeds MaxFieldCount.
AddField(string, object, bool)
Adds a field to the embed.
public EmbedBuilder AddField(string name, object value, bool inline = false)
Parameters
namestringThe name of the field.
valueobjectThe value of the field.
inlineboolWhether the field should be inline.
Returns
- EmbedBuilder
The current builder.
Exceptions
- ArgumentException
Field count exceeds MaxFieldCount.
Build()
Builds the embed.
public EmbedRequest Build()
Returns
- EmbedRequest
A new Fluxer.Net.EmbedJson object.
Exceptions
- InvalidOperationException
The embed exceeds MaxEmbedLength.
WithAuthor(EmbedAuthorBuilder)
Sets the author field of the embed.
public EmbedBuilder WithAuthor(EmbedAuthorBuilder author)
Parameters
authorEmbedAuthorBuilderThe author builder to set.
Returns
- EmbedBuilder
The current builder.
WithAuthor(Action<EmbedAuthorBuilder>)
Sets the author field of the embed using an action.
public EmbedBuilder WithAuthor(Action<EmbedAuthorBuilder> action)
Parameters
actionAction<EmbedAuthorBuilder>The action to configure the author builder.
Returns
- EmbedBuilder
The current builder.
WithAuthor(string, string?, string?)
Sets the author field of the embed.
public EmbedBuilder WithAuthor(string name, string? iconUrl = null, string? url = null)
Parameters
namestringThe name of the author.
iconUrlstringThe icon URL of the author.
urlstringThe URL of the author.
Returns
- EmbedBuilder
The current builder.
WithColor(byte, byte, byte)
Sets the color of the embed using RGB values.
public EmbedBuilder WithColor(byte r, byte g, byte b)
Parameters
Returns
- EmbedBuilder
The current builder.
WithColor(int)
Sets the color of the embed.
public EmbedBuilder WithColor(int color)
Parameters
colorintThe color to set as an integer (RGB).
Returns
- EmbedBuilder
The current builder.
WithCurrentTimestamp()
Sets the timestamp of the embed to the current UTC time.
public EmbedBuilder WithCurrentTimestamp()
Returns
- EmbedBuilder
The current builder.
WithDescription(string?)
Sets the description of the embed.
public EmbedBuilder WithDescription(string? description)
Parameters
descriptionstringThe description to set.
Returns
- EmbedBuilder
The current builder.
WithFooter(EmbedFooterBuilder)
Sets the footer field of the embed.
public EmbedBuilder WithFooter(EmbedFooterBuilder footer)
Parameters
footerEmbedFooterBuilderThe footer builder to set.
Returns
- EmbedBuilder
The current builder.
WithFooter(Action<EmbedFooterBuilder>)
Sets the footer field of the embed using an action.
public EmbedBuilder WithFooter(Action<EmbedFooterBuilder> action)
Parameters
actionAction<EmbedFooterBuilder>The action to configure the footer builder.
Returns
- EmbedBuilder
The current builder.
WithFooter(string, string?)
Sets the footer field of the embed.
public EmbedBuilder WithFooter(string text, string? iconUrl = null)
Parameters
Returns
- EmbedBuilder
The current builder.
WithImageUrl(string?)
Sets the image URL of the embed.
public EmbedBuilder WithImageUrl(string? imageUrl)
Parameters
imageUrlstringThe image URL to set.
Returns
- EmbedBuilder
The current builder.
WithThumbnailUrl(string?)
Sets the thumbnail URL of the embed.
public EmbedBuilder WithThumbnailUrl(string? thumbnailUrl)
Parameters
thumbnailUrlstringThe thumbnail URL to set.
Returns
- EmbedBuilder
The current builder.
WithTimestamp(DateTimeOffset)
Sets the timestamp of the embed.
public EmbedBuilder WithTimestamp(DateTimeOffset timestamp)
Parameters
timestampDateTimeOffsetThe timestamp to set.
Returns
- EmbedBuilder
The current builder.
WithTitle(string?)
Sets the title of the embed.
public EmbedBuilder WithTitle(string? title)
Parameters
titlestringThe title to set.
Returns
- EmbedBuilder
The current builder.
WithUrl(string?)
Sets the URL of the embed.
public EmbedBuilder WithUrl(string? url)
Parameters
urlstringThe URL to set.
Returns
- EmbedBuilder
The current builder.