Table of Contents

Class EmbedFieldBuilder

Namespace
Discord
Assembly
Discord.Net.Core.dll

Represents a builder class for an embed field.

public class EmbedFieldBuilder
Inheritance
EmbedFieldBuilder
Inherited Members

Examples

The example will build a rich embed with an author field, a footer field, and 2 normal fields using an EmbedBuilder:

var exampleAuthor = new EmbedAuthorBuilder()
        .WithName("I am a bot")
        .WithIconUrl("https://discord.com/assets/e05ead6e6ebc08df9291738d0aa6986d.png");
var exampleFooter = new EmbedFooterBuilder()
        .WithText("I am a nice footer")
        .WithIconUrl("https://discord.com/assets/28174a34e77bb5e5310ced9f95cb480b.png");
var exampleField = new EmbedFieldBuilder()
        .WithName("Title of Another Field")
        .WithValue("I am an [example](https://example.com).")
        .WithInline(true);
var otherField = new EmbedFieldBuilder()
        .WithName("Title of a Field")
        .WithValue("Notice how I'm inline with that other field next to me.")
        .WithInline(true);
var embed = new EmbedBuilder()
        .AddField(exampleField)
        .AddField(otherField)
        .WithAuthor(exampleAuthor)
        .WithFooter(exampleFooter)
        .Build();

Fields

MaxFieldNameLength

Gets the maximum field length for name allowed by Discord.

public const int MaxFieldNameLength = 256

Field Value

int

MaxFieldValueLength

Gets the maximum field length for value allowed by Discord.

public const int MaxFieldValueLength = 1024

Field Value

int

Properties

IsInline

Gets or sets a value that indicates whether the field should be in-line with each other.

public bool IsInline { get; set; }

Property Value

bool

Name

Gets or sets the field name.

public string Name { get; set; }

Property Value

string

The name of the field.

Exceptions

ArgumentException

Field name is null, empty or entirely whitespace.

- or -

Field name length exceeds MaxFieldNameLength.

Value

Gets or sets the field value.

public object Value { get; set; }

Property Value

object

The value of the field.

Exceptions

ArgumentException

Field value is null, empty or entirely whitespace.

- or -

Field value length exceeds MaxFieldValueLength.

Methods

Build()

Builds the field builder into a EmbedField class.

public EmbedField Build()

Returns

EmbedField

The current builder.

Exceptions

ArgumentException

Name or Value is null, empty or entirely whitespace.

- or -

Name or Value exceeds the maximum length allowed by Discord.

Equals(EmbedFieldBuilder)

Determines whether the specified EmbedFieldBuilder is equal to the current EmbedFieldBuilder

public bool Equals(EmbedFieldBuilder embedFieldBuilder)

Parameters

embedFieldBuilder EmbedFieldBuilder

The EmbedFieldBuilder to compare with the current EmbedFieldBuilder

Returns

bool

Equals(object)

Determines whether the specified object is equal to the current EmbedFieldBuilder.

public override bool Equals(object obj)

Parameters

obj object

The object to compare with the current EmbedFieldBuilder

Returns

bool

Remarks

If the object passes is an EmbedFieldBuilder, Equals(EmbedFieldBuilder) will be called to compare the 2 instances

GetHashCode()

Serves as the default hash function.

public override int GetHashCode()

Returns

int

A hash code for the current object.

WithIsInline(bool)

Determines whether the field should be in-line with each other.

public EmbedFieldBuilder WithIsInline(bool isInline)

Parameters

isInline bool

Returns

EmbedFieldBuilder

The current builder.

WithName(string)

Sets the field name.

public EmbedFieldBuilder WithName(string name)

Parameters

name string

The name to set the field name to.

Returns

EmbedFieldBuilder

The current builder.

WithValue(object)

Sets the field value.

public EmbedFieldBuilder WithValue(object value)

Parameters

value object

The value to set the field value to.

Returns

EmbedFieldBuilder

The current builder.

Operators

operator ==(EmbedFieldBuilder, EmbedFieldBuilder)

public static bool operator ==(EmbedFieldBuilder left, EmbedFieldBuilder right)

Parameters

left EmbedFieldBuilder
right EmbedFieldBuilder

Returns

bool

operator !=(EmbedFieldBuilder, EmbedFieldBuilder)

public static bool operator !=(EmbedFieldBuilder left, EmbedFieldBuilder right)

Parameters

left EmbedFieldBuilder
right EmbedFieldBuilder

Returns

bool