Show / Hide Table of Contents

# Class EmbedBuilder

Represents a builder class for creating a Rich Embed.

##### Inheritance

System.Object
EmbedBuilder

##### Inherited Members

System.Object.ToString()
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()

###### Namespace: Discord

###### Assembly: Discord.Net.Core.dll

##### Syntax

    public class EmbedBuilder

### Constructors

| Improve this Doc View Source

#### EmbedBuilder()

Initializes a new EmbedBuilder class.

##### Declaration

    public EmbedBuilder()

### Fields

| Improve this Doc View Source

#### MaxDescriptionLength

Returns the maximum length of description allowed by Discord.

##### Declaration

    public const int MaxDescriptionLength = 2048

##### Field Value

Type | Description
--- | ---
System.Int32 |

| Improve this Doc View Source

#### MaxEmbedLength

Returns the maximum length of total characters allowed by Discord.

##### Declaration

    public const int MaxEmbedLength = 6000

##### Field Value

Type | Description
--- | ---
System.Int32 |

| Improve this Doc View Source

#### MaxFieldCount

Returns the maximum number of fields allowed by Discord.

##### Declaration

    public const int MaxFieldCount = 25

##### Field Value

Type | Description
--- | ---
System.Int32 |

| Improve this Doc View Source

#### MaxTitleLength

Returns the maximum length of title allowed by Discord.

##### Declaration

    public const int MaxTitleLength = 256

##### Field Value

Type | Description
--- | ---
System.Int32 |

### Properties

| Improve this Doc View Source

#### Author

Gets or sets the EmbedAuthorBuilder of an Embed.

##### Declaration

    public EmbedAuthorBuilder Author { get; set; }

##### Property Value

Type | Description
--- | ---
EmbedAuthorBuilder | The author field builder of the embed, or `null` if none is set.

| Improve this Doc View Source

#### Color

Gets or sets the sidebar color of an Embed.

##### Declaration

    public Color? Color { get; set; }

##### Property Value

Type | Description
--- | ---
System.Nullable<Color> | The color of the embed, or `null` if none is set.

| Improve this Doc View Source

#### Description

Gets or sets the description of an Embed.

##### Declaration

    public string Description { get; set; }

##### Property Value

Type | Description
--- | ---
System.String | The description of the embed.

##### Exceptions

Type | Condition
--- | ---
System.ArgumentException | Description length exceeds MaxDescriptionLength.

| Improve this Doc View Source

#### Fields

Gets or sets the list of EmbedFieldBuilder of an Embed.

##### Declaration

    public List<EmbedFieldBuilder> Fields { get; set; }

##### Property Value

Type | Description
--- | ---
System.Collections.Generic.List<EmbedFieldBuilder> | The list of existing EmbedFieldBuilder.

##### Exceptions

Type | Condition
--- | ---
System.ArgumentNullException | An embed builder's fields collection is set to `null`.
System.ArgumentException | Description length exceeds MaxFieldCount.

| Improve this Doc View Source

#### Footer

Gets or sets the EmbedFooterBuilder of an Embed.

##### Declaration

    public EmbedFooterBuilder Footer { get; set; }

##### Property Value

Type | Description
--- | ---
EmbedFooterBuilder | The footer field builder of the embed, or `null` if none is set.

| Improve this Doc View Source

#### ImageUrl

Gets or sets the image URL of an Embed.

##### Declaration

    public string ImageUrl { get; set; }

##### Property Value

Type | Description
--- | ---
System.String | The image URL of the embed.

##### Exceptions

Type | Condition
--- | ---
System.ArgumentException | Url is not a well-formed System.Uri.

| Improve this Doc View Source

#### Length

Gets the total length of all embed properties.

##### Declaration

    public int Length { get; }

##### Property Value

Type | Description
--- | ---
System.Int32 | The combined length of Title, Name, Description, Text, Name, and Value.

| Improve this Doc View Source

#### ThumbnailUrl

Gets or sets the thumbnail URL of an Embed.

##### Declaration

    public string ThumbnailUrl { get; set; }

##### Property Value

Type | Description
--- | ---
System.String | The thumbnail URL of the embed.

##### Exceptions

Type | Condition
--- | ---
System.ArgumentException | Url is not a well-formed System.Uri.

| Improve this Doc View Source

#### Timestamp

Gets or sets the timestamp of an Embed.

##### Declaration

    public DateTimeOffset? Timestamp { get; set; }

##### Property Value

Type | Description
--- | ---
System.Nullable<System.DateTimeOffset> | The timestamp of the embed, or `null` if none is set.

| Improve this Doc View Source

#### Title

Gets or sets the title of an Embed.

##### Declaration

    public string Title { get; set; }

##### Property Value

Type | Description
--- | ---
System.String | The title of the embed.

##### Exceptions

Type | Condition
--- | ---
System.ArgumentException | Title length exceeds MaxTitleLength.

| Improve this Doc View Source

#### Url

Gets or sets the URL of an Embed.

##### Declaration

    public string Url { get; set; }

##### Property Value

Type | Description
--- | ---
System.String | The URL of the embed.

##### Exceptions

Type | Condition
--- | ---
System.ArgumentException | Url is not a well-formed System.Uri.

### Methods

| Improve this Doc View Source

#### AddField(EmbedFieldBuilder)

Adds a field with the provided EmbedFieldBuilder to an Embed.

##### Declaration

    public EmbedBuilder AddField(EmbedFieldBuilder field)

##### Parameters

Type | Name | Description
--- | --- | ---
EmbedFieldBuilder | field | The field builder class containing the field properties.

##### Returns

Type | Description
--- | ---
EmbedBuilder | The current builder.

##### Exceptions

Type | Condition
--- | ---
System.ArgumentException | Field count exceeds MaxFieldCount.

| Improve this Doc View Source

#### AddField(Action<EmbedFieldBuilder>)

Adds an Embed field with the provided properties.

##### Declaration

    public EmbedBuilder AddField(Action<EmbedFieldBuilder> action)

##### Parameters

Type | Name | Description
--- | --- | ---
System.Action<EmbedFieldBuilder> | action | The delegate containing the field properties.

##### Returns

Type | Description
--- | ---
EmbedBuilder | The current builder.

| Improve this Doc View Source

#### AddField(String, Object, Boolean)

Adds an Embed field with the provided name and value.

##### Declaration

    public EmbedBuilder AddField(string name, object value, bool inline = false)

##### Parameters

Type | Name | Description
--- | --- | ---
System.String | name | The title of the field.
System.Object | value | The value of the field.
System.Boolean | inline | Indicates whether the field is in-line or not.

##### Returns

Type | Description
--- | ---
EmbedBuilder | The current builder.

| Improve this Doc View Source

#### Build()

Builds the Embed into a Rich Embed ready to be sent.

##### Declaration

    public Embed Build()

##### Returns

Type | Description
--- | ---
Embed | The built embed object.

##### Exceptions

Type | Condition
--- | ---
System.InvalidOperationException | Total embed length exceeds MaxEmbedLength.

| Improve this Doc View Source

#### WithAuthor(EmbedAuthorBuilder)

Sets the EmbedAuthorBuilder of an Embed.

##### Declaration

    public EmbedBuilder WithAuthor(EmbedAuthorBuilder author)

##### Parameters

Type | Name | Description
--- | --- | ---
EmbedAuthorBuilder | author | The author builder class containing the author field properties.

##### Returns

Type | Description
--- | ---
EmbedBuilder | The current builder.

| Improve this Doc View Source

#### WithAuthor(Action<EmbedAuthorBuilder>)

Sets the author field of an Embed with the provided properties.

##### Declaration

    public EmbedBuilder WithAuthor(Action<EmbedAuthorBuilder> action)

##### Parameters

Type | Name | Description
--- | --- | ---
System.Action<EmbedAuthorBuilder> | action | The delegate containing the author field properties.

##### Returns

Type | Description
--- | ---
EmbedBuilder | The current builder.

| Improve this Doc View Source

#### WithAuthor(String, String, String)

Sets the author field of an Embed with the provided name, icon URL, and URL.

##### Declaration

    public EmbedBuilder WithAuthor(string name, string iconUrl = null, string url = null)

##### Parameters

Type | Name | Description
--- | --- | ---
System.String | name | The title of the author field.
System.String | iconUrl | The icon URL of the author field.
System.String | url | The URL of the author field.

##### Returns

Type | Description
--- | ---
EmbedBuilder | The current builder.

| Improve this Doc View Source

#### WithColor(Color)

Sets the sidebar color of an Embed.

##### Declaration

    public EmbedBuilder WithColor(Color color)

##### Parameters

Type | Name | Description
--- | --- | ---
Color | color | The color to be set.

##### Returns

Type | Description
--- | ---
EmbedBuilder | The current builder.

| Improve this Doc View Source

#### WithCurrentTimestamp()

Sets the timestamp of an Embed to the current time.

##### Declaration

    public EmbedBuilder WithCurrentTimestamp()

##### Returns

Type | Description
--- | ---
EmbedBuilder | The current builder.

| Improve this Doc View Source

#### WithDescription(String)

Sets the description of an Embed.

##### Declaration

    public EmbedBuilder WithDescription(string description)

##### Parameters

Type | Name | Description
--- | --- | ---
System.String | description | The description to be set.

##### Returns

Type | Description
--- | ---
EmbedBuilder | The current builder.

| Improve this Doc View Source

#### WithFooter(EmbedFooterBuilder)

Sets the EmbedFooterBuilder of an Embed.

##### Declaration

    public EmbedBuilder WithFooter(EmbedFooterBuilder footer)

##### Parameters

Type | Name | Description
--- | --- | ---
EmbedFooterBuilder | footer | The footer builder class containing the footer field properties.

##### Returns

Type | Description
--- | ---
EmbedBuilder | The current builder.

| Improve this Doc View Source

#### WithFooter(Action<EmbedFooterBuilder>)

Sets the footer field of an Embed with the provided properties.

##### Declaration

    public EmbedBuilder WithFooter(Action<EmbedFooterBuilder> action)

##### Parameters

Type | Name | Description
--- | --- | ---
System.Action<EmbedFooterBuilder> | action | The delegate containing the footer field properties.

##### Returns

Type | Description
--- | ---
EmbedBuilder | The current builder.

| Improve this Doc View Source

#### WithFooter(String, String)

Sets the footer field of an Embed with the provided name, icon URL.

##### Declaration

    public EmbedBuilder WithFooter(string text, string iconUrl = null)

##### Parameters

Type | Name | Description
--- | --- | ---
System.String | text | The title of the footer field.
System.String | iconUrl | The icon URL of the footer field.

##### Returns

Type | Description
--- | ---
EmbedBuilder | The current builder.

| Improve this Doc View Source

#### WithImageUrl(String)

Sets the image URL of an Embed.

##### Declaration

    public EmbedBuilder WithImageUrl(string imageUrl)

##### Parameters

Type | Name | Description
--- | --- | ---
System.String | imageUrl | The image URL to be set.

##### Returns

Type | Description
--- | ---
EmbedBuilder | The current builder.

| Improve this Doc View Source

#### WithThumbnailUrl(String)

Sets the thumbnail URL of an Embed.

##### Declaration

    public EmbedBuilder WithThumbnailUrl(string thumbnailUrl)

##### Parameters

Type | Name | Description
--- | --- | ---
System.String | thumbnailUrl | The thumbnail URL to be set.

##### Returns

Type | Description
--- | ---
EmbedBuilder | The current builder.

| Improve this Doc View Source

#### WithTimestamp(DateTimeOffset)

Sets the timestamp of an Embed.

##### Declaration

    public EmbedBuilder WithTimestamp(DateTimeOffset dateTimeOffset)

##### Parameters

Type | Name | Description
--- | --- | ---
System.DateTimeOffset | dateTimeOffset | The timestamp to be set.

##### Returns

Type | Description
--- | ---
EmbedBuilder | The current builder.

| Improve this Doc View Source

#### WithTitle(String)

Sets the title of an Embed.

##### Declaration

    public EmbedBuilder WithTitle(string title)

##### Parameters

Type | Name | Description
--- | --- | ---
System.String | title | The title to be set.

##### Returns

Type | Description
--- | ---
EmbedBuilder | The current builder.

| Improve this Doc View Source

#### WithUrl(String)

Sets the URL of an Embed.

##### Declaration

    public EmbedBuilder WithUrl(string url)

##### Parameters

Type | Name | Description
--- | --- | ---
System.String | url | The URL to be set.

##### Returns

Type | Description
--- | ---
EmbedBuilder | The current builder.

### Extension Methods

EmbedBuilderExtensions.WithColor(EmbedBuilder, UInt32)
EmbedBuilderExtensions.WithColor(EmbedBuilder, Byte, Byte, Byte)
EmbedBuilderExtensions.WithColor(EmbedBuilder, Int32, Int32, Int32)
EmbedBuilderExtensions.WithColor(EmbedBuilder, Single, Single, Single)
EmbedBuilderExtensions.WithAuthor(EmbedBuilder, IUser)
EmbedBuilderExtensions.WithFields(EmbedBuilder, IEnumerable<EmbedFieldBuilder>)
EmbedBuilderExtensions.WithFields(EmbedBuilder, EmbedFieldBuilder[])