Class EmbedAuthorBuilder
- Namespace
- Discord
- Assembly
- Discord.Net.Core.dll
Represents a builder class for a author field.
public class EmbedAuthorBuilder
- Inheritance
-
EmbedAuthorBuilder
- 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
MaxAuthorNameLength
Gets the maximum author name length allowed by Discord.
public const int MaxAuthorNameLength = 256
Field Value
Properties
IconUrl
Gets or sets the icon URL of the author field.
public string IconUrl { get; set; }
Property Value
- string
The icon URL of the author field.
Exceptions
- ArgumentException
Url is not a well-formed Uri.
Name
Gets or sets the author name.
public string Name { get; set; }
Property Value
- string
The author name.
Exceptions
- ArgumentException
Author name length is longer than MaxAuthorNameLength.
Url
Gets or sets the URL of the author field.
public string Url { get; set; }
Property Value
- string
The URL of the author field.
Exceptions
- ArgumentException
Url is not a well-formed Uri.
Methods
Build()
Builds the author field to be used.
public EmbedAuthor Build()
Returns
- EmbedAuthor
The built author field.
Exceptions
- ArgumentException
Author name length is longer than MaxAuthorNameLength.
- or -
- or -
Equals(EmbedAuthorBuilder)
Determines whether the specified EmbedAuthorBuilder is equals to the current EmbedAuthorBuilder
public bool Equals(EmbedAuthorBuilder embedAuthorBuilder)
Parameters
embedAuthorBuilder
EmbedAuthorBuilderThe EmbedAuthorBuilder to compare with the current EmbedAuthorBuilder
Returns
Equals(object)
Determines whether the specified object is equal to the current EmbedAuthorBuilder.
public override bool Equals(object obj)
Parameters
obj
objectThe object to compare with the current EmbedAuthorBuilder
Returns
Remarks
If the object passes is an EmbedAuthorBuilder, Equals(EmbedAuthorBuilder) 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.
WithIconUrl(string)
Sets the icon URL of the author field.
public EmbedAuthorBuilder WithIconUrl(string iconUrl)
Parameters
iconUrl
stringThe icon URL of the author field.
Returns
- EmbedAuthorBuilder
The current builder.
WithName(string)
Sets the name of the author field.
public EmbedAuthorBuilder WithName(string name)
Parameters
name
stringThe name of the author field.
Returns
- EmbedAuthorBuilder
The current builder.
WithUrl(string)
Sets the URL of the author field.
public EmbedAuthorBuilder WithUrl(string url)
Parameters
url
stringThe URL of the author field.
Returns
- EmbedAuthorBuilder
The current builder.
Operators
operator ==(EmbedAuthorBuilder, EmbedAuthorBuilder)
public static bool operator ==(EmbedAuthorBuilder left, EmbedAuthorBuilder right)
Parameters
left
EmbedAuthorBuilderright
EmbedAuthorBuilder
Returns
operator !=(EmbedAuthorBuilder, EmbedAuthorBuilder)
public static bool operator !=(EmbedAuthorBuilder left, EmbedAuthorBuilder right)
Parameters
left
EmbedAuthorBuilderright
EmbedAuthorBuilder