Class EmbedBuilder
Inheritance
Inherited Members
Namespace: Discord
Assembly: Discord.Net.Core.dll
Syntax
public class EmbedBuilder
Constructors
| Improve this Doc View SourceEmbedBuilder()
Initializes a new EmbedBuilder class.
Declaration
public EmbedBuilder()
Fields
| Improve this Doc View SourceMaxDescriptionLength
Returns the maximum length of description allowed by Discord.
Declaration
public const int MaxDescriptionLength = 2048
Field Value
| Type | Description |
|---|---|
| System.Int32 |
MaxEmbedLength
Returns the maximum length of total characters allowed by Discord.
Declaration
public const int MaxEmbedLength = 6000
Field Value
| Type | Description |
|---|---|
| System.Int32 |
MaxFieldCount
Returns the maximum number of fields allowed by Discord.
Declaration
public const int MaxFieldCount = 25
Field Value
| Type | Description |
|---|---|
| System.Int32 |
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 SourceAuthor
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 |
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 |
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. |
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
|
| System.ArgumentException | Description length exceeds MaxFieldCount. |
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 |
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. |
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. |
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. |
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 |
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. |
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 SourceAddField(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. |
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. |
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. |
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. |
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. |
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. |
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. |
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. |
WithCurrentTimestamp()
Sets the timestamp of an Embed to the current time.
Declaration
public EmbedBuilder WithCurrentTimestamp()
Returns
| Type | Description |
|---|---|
| EmbedBuilder | The current builder. |
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. |
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. |
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. |
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. |
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. |
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. |
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. |
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. |
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. |