Class DiscordEmbedBuilder
Constructs embeds.
Inheritance
Namespace: DisCatSharp.Entities
Assembly: DisCatSharp.dll
Syntax
public sealed class DiscordEmbedBuilder
Constructors
| Improve this Doc View SourceDiscordEmbedBuilder()
Constructs a new empty embed builder.
Declaration
public DiscordEmbedBuilder()
DiscordEmbedBuilder(DiscordEmbed)
Constructs a new embed builder using another embed as prototype.
Declaration
public DiscordEmbedBuilder(DiscordEmbed original)
Parameters
Type | Name | Description |
---|---|---|
DiscordEmbed | original | Embed to use as prototype. |
Properties
| Improve this Doc View SourceAuthor
Gets or sets the embed's author.
Declaration
public DiscordEmbedBuilder.EmbedAuthor Author { get; set; }
Property Value
Type | Description |
---|---|
DiscordEmbedBuilder.EmbedAuthor |
Color
Gets or sets the embed's color.
Declaration
public Optional<DiscordColor> Color { get; set; }
Property Value
Type | Description |
---|---|
Optional<DiscordColor> |
Description
Gets or sets the embed's description.
Declaration
public string Description { get; set; }
Property Value
Type | Description |
---|---|
System.String |
Fields
Gets the embed's fields.
Declaration
public IReadOnlyList<DiscordEmbedField> Fields { get; }
Property Value
Type | Description |
---|---|
System.Collections.Generic.IReadOnlyList<DiscordEmbedField> |
Footer
Gets or sets the embed's footer.
Declaration
public DiscordEmbedBuilder.EmbedFooter Footer { get; set; }
Property Value
Type | Description |
---|---|
DiscordEmbedBuilder.EmbedFooter |
ImageUrl
Gets or sets the embed's image url.
Declaration
public string ImageUrl { get; set; }
Property Value
Type | Description |
---|---|
System.String |
Thumbnail
Gets or sets the embed's thumbnail.
Declaration
public DiscordEmbedBuilder.EmbedThumbnail Thumbnail { get; set; }
Property Value
Type | Description |
---|---|
DiscordEmbedBuilder.EmbedThumbnail |
Timestamp
Gets or sets the embed's timestamp.
Declaration
public DateTimeOffset? Timestamp { get; set; }
Property Value
Type | Description |
---|---|
System.Nullable<System.DateTimeOffset> |
Title
Gets or sets the embed's title.
Declaration
public string Title { get; set; }
Property Value
Type | Description |
---|---|
System.String |
Url
Gets or sets the url for the embed's title.
Declaration
public string Url { get; set; }
Property Value
Type | Description |
---|---|
System.String |
Methods
| Improve this Doc View SourceAddField(DiscordEmbedField)
Adds a field to this embed.
Declaration
public DiscordEmbedBuilder AddField(DiscordEmbedField field)
Parameters
Type | Name | Description |
---|---|---|
DiscordEmbedField | field | The field to add. |
Returns
Type | Description |
---|---|
DiscordEmbedBuilder | This embed builder. |
AddField(String, String, Boolean)
Adds a field to this embed.
Declaration
[Obsolete("DiscordEmbedFields should be constructed manually.")]
public DiscordEmbedBuilder AddField(string name, string value, bool inline = false)
Parameters
Type | Name | Description |
---|---|---|
System.String | name | Name of the field to add. |
System.String | value | Value of the field to add. |
System.Boolean | inline | Whether the field is to be inline or not. |
Returns
Type | Description |
---|---|
DiscordEmbedBuilder | This embed builder. |
AddFields(DiscordEmbedField[])
Adds multiple fields to this embed.
Declaration
public DiscordEmbedBuilder AddFields(params DiscordEmbedField[] fields)
Parameters
Type | Name | Description |
---|---|---|
DiscordEmbedField[] | fields | The fields to add. |
Returns
Type | Description |
---|---|
DiscordEmbedBuilder | This embed builder. |
AddFields(IEnumerable<DiscordEmbedField>)
Adds multiple fields to this embed.
Declaration
public DiscordEmbedBuilder AddFields(IEnumerable<DiscordEmbedField> fields)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IEnumerable<DiscordEmbedField> | fields | The fields to add. |
Returns
Type | Description |
---|---|
DiscordEmbedBuilder | This embed builder. |
Build()
Constructs a new embed from data supplied to this builder.
Declaration
public DiscordEmbed Build()
Returns
Type | Description |
---|---|
DiscordEmbed | New discord embed. |
ClearFields()
Removes all fields from this embed.
Declaration
public DiscordEmbedBuilder ClearFields()
Returns
Type | Description |
---|---|
DiscordEmbedBuilder | This embed builder. |
RemoveField(DiscordEmbedField)
Removes a field from this embed, if it is part of it.
Declaration
public DiscordEmbedBuilder RemoveField(DiscordEmbedField field)
Parameters
Type | Name | Description |
---|---|---|
DiscordEmbedField | field | The field to remove. |
Returns
Type | Description |
---|---|
DiscordEmbedBuilder | This embed builder. |
RemoveFieldAt(Int32)
Removes a field of the specified index from this embed.
Declaration
public DiscordEmbedBuilder RemoveFieldAt(int index)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | index | Index of the field to remove. |
Returns
Type | Description |
---|---|
DiscordEmbedBuilder | This embed builder. |
RemoveFieldRange(Int32, Int32)
Removes fields of the specified range from this embed.
Declaration
public DiscordEmbedBuilder RemoveFieldRange(int index, int count)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | index | Index of the first field to remove. |
System.Int32 | count | Number of fields to remove. |
Returns
Type | Description |
---|---|
DiscordEmbedBuilder | This embed builder. |
RemoveFields(DiscordEmbedField[])
Removes multiple fields from this embed, if they are part of it.
Declaration
public DiscordEmbedBuilder RemoveFields(params DiscordEmbedField[] fields)
Parameters
Type | Name | Description |
---|---|---|
DiscordEmbedField[] | fields | The fields to remove. |
Returns
Type | Description |
---|---|
DiscordEmbedBuilder | This embed builder. |
RemoveFields(IEnumerable<DiscordEmbedField>)
Removes multiple fields from this embed, if they are part of it.
Declaration
public DiscordEmbed RemoveFields(IEnumerable<DiscordEmbedField> fields)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IEnumerable<DiscordEmbedField> | fields | The fields to remove. |
Returns
Type | Description |
---|---|
DiscordEmbed | This embed builder. |
WithAuthor(String, String, String)
Sets the embed's author.
Declaration
public DiscordEmbedBuilder WithAuthor(string name = null, string url = null, string iconUrl = null)
Parameters
Type | Name | Description |
---|---|---|
System.String | name | Author's name. |
System.String | url | Author's url. |
System.String | iconUrl | Author icon's url. |
Returns
Type | Description |
---|---|
DiscordEmbedBuilder | This embed builder. |
WithColor(DiscordColor)
Sets the embed's color.
Declaration
public DiscordEmbedBuilder WithColor(DiscordColor color)
Parameters
Type | Name | Description |
---|---|---|
DiscordColor | color | Embed color to set. |
Returns
Type | Description |
---|---|
DiscordEmbedBuilder | This embed builder. |
WithDescription(String)
Sets the embed's description.
Declaration
public DiscordEmbedBuilder WithDescription(string description)
Parameters
Type | Name | Description |
---|---|---|
System.String | description | Description to set. |
Returns
Type | Description |
---|---|
DiscordEmbedBuilder | This embed builder. |
WithFooter(String, String)
Sets the embed's footer.
Declaration
public DiscordEmbedBuilder WithFooter(string text = null, string iconUrl = null)
Parameters
Type | Name | Description |
---|---|---|
System.String | text | Footer's text. |
System.String | iconUrl | Footer icon's url. |
Returns
Type | Description |
---|---|
DiscordEmbedBuilder | This embed builder. |
WithImageUrl(String)
Sets the embed's image url.
Declaration
public DiscordEmbedBuilder WithImageUrl(string url)
Parameters
Type | Name | Description |
---|---|---|
System.String | url | Image url to set. |
Returns
Type | Description |
---|---|
DiscordEmbedBuilder | This embed builder. |
WithImageUrl(Uri)
Sets the embed's image url.
Declaration
public DiscordEmbedBuilder WithImageUrl(Uri url)
Parameters
Type | Name | Description |
---|---|---|
System.Uri | url | Image url to set. |
Returns
Type | Description |
---|---|
DiscordEmbedBuilder | This embed builder. |
WithThumbnail(String, Int32, Int32)
Sets the embed's thumbnail.
Declaration
public DiscordEmbedBuilder WithThumbnail(string url, int height = 0, int width = 0)
Parameters
Type | Name | Description |
---|---|---|
System.String | url | Thumbnail url to set. |
System.Int32 | height | The height of the thumbnail to set. |
System.Int32 | width | The width of the thumbnail to set. |
Returns
Type | Description |
---|---|
DiscordEmbedBuilder | This embed builder. |
WithThumbnail(Uri, Int32, Int32)
Sets the embed's thumbnail.
Declaration
public DiscordEmbedBuilder WithThumbnail(Uri url, int height = 0, int width = 0)
Parameters
Type | Name | Description |
---|---|---|
System.Uri | url | Thumbnail url to set. |
System.Int32 | height | The height of the thumbnail to set. |
System.Int32 | width | The width of the thumbnail to set. |
Returns
Type | Description |
---|---|
DiscordEmbedBuilder | This embed builder. |
WithTimestamp(Nullable<DateTime>)
Sets the embed's timestamp.
Declaration
public DiscordEmbedBuilder WithTimestamp(DateTime? timestamp)
Parameters
Type | Name | Description |
---|---|---|
System.Nullable<System.DateTime> | timestamp | Timestamp to set. |
Returns
Type | Description |
---|---|
DiscordEmbedBuilder | This embed builder. |
WithTimestamp(Nullable<DateTimeOffset>)
Sets the embed's timestamp.
Declaration
public DiscordEmbedBuilder WithTimestamp(DateTimeOffset? timestamp)
Parameters
Type | Name | Description |
---|---|---|
System.Nullable<System.DateTimeOffset> | timestamp | Timestamp to set. |
Returns
Type | Description |
---|---|
DiscordEmbedBuilder | This embed builder. |
WithTimestamp(UInt64)
Sets the embed's timestamp based on a snowflake.
Declaration
public DiscordEmbedBuilder WithTimestamp(ulong snowflake)
Parameters
Type | Name | Description |
---|---|---|
System.UInt64 | snowflake | Snowflake to calculate timestamp from. |
Returns
Type | Description |
---|---|
DiscordEmbedBuilder | This embed builder. |
WithTitle(String)
Sets the embed's title.
Declaration
public DiscordEmbedBuilder WithTitle(string title)
Parameters
Type | Name | Description |
---|---|---|
System.String | title | Title to set. |
Returns
Type | Description |
---|---|
DiscordEmbedBuilder | This embed builder. |
WithUrl(String)
Sets the embed's title url.
Declaration
public DiscordEmbedBuilder WithUrl(string url)
Parameters
Type | Name | Description |
---|---|---|
System.String | url | Title url to set. |
Returns
Type | Description |
---|---|
DiscordEmbedBuilder | This embed builder. |
WithUrl(Uri)
Sets the embed's title url.
Declaration
public DiscordEmbedBuilder WithUrl(Uri url)
Parameters
Type | Name | Description |
---|---|---|
System.Uri | url | Title url to set. |
Returns
Type | Description |
---|---|
DiscordEmbedBuilder | This embed builder. |
Operators
| Improve this Doc View SourceImplicit(DiscordEmbedBuilder to DiscordEmbed)
Implicitly converts this builder to an embed.
Declaration
public static implicit operator DiscordEmbed(DiscordEmbedBuilder builder)
Parameters
Type | Name | Description |
---|---|---|
DiscordEmbedBuilder | builder | Builder to convert. |
Returns
Type | Description |
---|---|
DiscordEmbed |