Skip to main content

Class ButtonBuilder

Represents a class used to build Discord.ButtonComponent's.

Assembly: Discord.Net.Core.dll​
View Source​
Declaration
public class ButtonBuilder

Properties​

Label​

Gets or sets the label of the current button.

View Source​
Declaration
public string Label { get; set; }

CustomId​

Gets or sets the custom id of the current button.

View Source​
Declaration
public string CustomId { get; set; }

Style​

Gets or sets the Discord.ButtonStyle of the current button.

View Source​
Declaration
public ButtonStyle Style { get; set; }

Emote​

Gets or sets the Discord.IEmote of the current button.

View Source​
Declaration
public IEmote Emote { get; set; }

Url​

Gets or sets the url of the current button.

View Source​
Declaration
public string Url { get; set; }

IsDisabled​

Gets or sets whether the current button is disabled.

View Source​
Declaration
public bool IsDisabled { get; set; }

Fields​

MaxButtonLabelLength​

The max length of a Discord.ButtonComponent.Label.

View Source​
Declaration
public const int MaxButtonLabelLength = 80

Methods​

CreateLinkButton(String, String, IEmote)​

Creates a button with the Discord.ButtonStyle.Link style.

View Source​
Declaration
public static ButtonBuilder CreateLinkButton(string label, string url, IEmote emote = null)
Returns​

Discord.ButtonBuilder: A builder with the newly created button.

Parameters​
TypeNameDescription
System.StringlabelThe label for this link button.
System.StringurlThe url for this link button to go to.
Discord.IEmoteemoteThe emote for this link button.

CreateDangerButton(String, String, IEmote)​

Creates a button with the Discord.ButtonStyle.Danger style.

View Source​
Declaration
public static ButtonBuilder CreateDangerButton(string label, string customId, IEmote emote = null)
Returns​

Discord.ButtonBuilder: A builder with the newly created button.

Parameters​
TypeNameDescription
System.StringlabelThe label for this danger button.
System.StringcustomIdThe custom id for this danger button.
Discord.IEmoteemoteThe emote for this danger button.

CreatePrimaryButton(String, String, IEmote)​

Creates a button with the Discord.ButtonStyle.Primary style.

View Source​
Declaration
public static ButtonBuilder CreatePrimaryButton(string label, string customId, IEmote emote = null)
Returns​

Discord.ButtonBuilder: A builder with the newly created button.

Parameters​
TypeNameDescription
System.StringlabelThe label for this primary button.
System.StringcustomIdThe custom id for this primary button.
Discord.IEmoteemoteThe emote for this primary button.

CreateSecondaryButton(String, String, IEmote)​

Creates a button with the Discord.ButtonStyle.Secondary style.

View Source​
Declaration
public static ButtonBuilder CreateSecondaryButton(string label, string customId, IEmote emote = null)
Returns​

Discord.ButtonBuilder: A builder with the newly created button.

Parameters​
TypeNameDescription
System.StringlabelThe label for this secondary button.
System.StringcustomIdThe custom id for this secondary button.
Discord.IEmoteemoteThe emote for this secondary button.

CreateSuccessButton(String, String, IEmote)​

Creates a button with the Discord.ButtonStyle.Success style.

View Source​
Declaration
public static ButtonBuilder CreateSuccessButton(string label, string customId, IEmote emote = null)
Returns​

Discord.ButtonBuilder: A builder with the newly created button.

Parameters​
TypeNameDescription
System.StringlabelThe label for this success button.
System.StringcustomIdThe custom id for this success button.
Discord.IEmoteemoteThe emote for this success button.

WithLabel(String)​

Sets the current buttons label to the specified text.

View Source​
Declaration
public ButtonBuilder WithLabel(string label)
Returns​

Discord.ButtonBuilder: The current builder.

Parameters​
TypeNameDescription
System.StringlabelThe text for the label.

WithStyle(ButtonStyle)​

Sets the current buttons style.

View Source​
Declaration
public ButtonBuilder WithStyle(ButtonStyle style)
Returns​

Discord.ButtonBuilder: The current builder.

Parameters​
TypeNameDescription
Discord.ButtonStylestyleThe style for this builders button.

WithEmote(IEmote)​

Sets the current buttons emote.

View Source​
Declaration
public ButtonBuilder WithEmote(IEmote emote)
Returns​

Discord.ButtonBuilder: The current builder.

Parameters​
TypeNameDescription
Discord.IEmoteemoteThe emote to use for the current button.

WithUrl(String)​

Sets the current buttons url.

View Source​
Declaration
public ButtonBuilder WithUrl(string url)
Returns​

Discord.ButtonBuilder: The current builder.

Parameters​
TypeNameDescription
System.StringurlThe url to use for the current button.

WithCustomId(String)​

Sets the custom id of the current button.

View Source​
Declaration
public ButtonBuilder WithCustomId(string id)
Returns​

Discord.ButtonBuilder: The current builder.

Parameters​
TypeNameDescription
System.StringidThe id to use for the current button.

WithDisabled(Boolean)​

Sets whether the current button is disabled.

View Source​
Declaration
public ButtonBuilder WithDisabled(bool isDisabled)
Returns​

Discord.ButtonBuilder: The current builder.

Parameters​
TypeNameDescription
System.BooleanisDisabledWhether the current button is disabled or not.

Build()​

Builds this builder into a Discord.ButtonComponent to be used in a Discord.ComponentBuilder.

View Source​
Declaration
public ButtonComponent Build()
Returns​

Discord.ButtonComponent: A Discord.ButtonComponent to be used in a Discord.ComponentBuilder.