Skip to main content

Class ComponentBuilder

Represents a builder for creating a Discord.MessageComponent.

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

Properties​

ActionRows​

Gets or sets the Action Rows for this Component Builder.

View Source​
Declaration
public List<ActionRowBuilder> ActionRows { get; set; }

Fields​

MaxCustomIdLength​

The max length of a Discord.ButtonComponent.CustomId.

View Source​
Declaration
public const int MaxCustomIdLength = 100

MaxActionRowCount​

The max amount of rows a message can have.

View Source​
Declaration
public const int MaxActionRowCount = 5

Methods​

FromMessage(IMessage)​

Creates a new builder from a message.

View Source​
Declaration
public static ComponentBuilder FromMessage(IMessage message)
Returns​

Discord.ComponentBuilder: The newly created builder.

Parameters​
TypeNameDescription
Discord.IMessagemessageThe message to create the builder from.

FromComponents(IReadOnlyCollection<IMessageComponent>)​

Creates a new builder from the provided list of components.

View Source​
Declaration
public static ComponentBuilder FromComponents(IReadOnlyCollection<IMessageComponent> components)
Returns​

Discord.ComponentBuilder: The newly created builder.

Parameters​
TypeNameDescription
System.Collections.Generic.IReadOnlyCollection<Discord.IMessageComponent>componentsThe components to create the builder from.

WithSelectMenu(String, List<SelectMenuOptionBuilder>, String, Int32, Int32, Boolean, Int32)​

Adds a Discord.SelectMenuBuilder to the Discord.ComponentBuilder at the specific row. If the row cannot accept the component then it will add it to a row that can.

View Source​
Declaration
public ComponentBuilder WithSelectMenu(string customId, List<SelectMenuOptionBuilder> options, string placeholder = null, int minValues = 1, int maxValues = 1, bool disabled = false, int row = 0)
Returns​

Discord.ComponentBuilder

Parameters​
TypeNameDescription
System.StringcustomIdThe custom id of the menu.
System.Collections.Generic.List<Discord.SelectMenuOptionBuilder>optionsThe options of the menu.
System.StringplaceholderThe placeholder of the menu.
System.Int32minValuesThe min values of the placeholder.
System.Int32maxValuesThe max values of the placeholder.
System.BooleandisabledWhether or not the menu is disabled.
System.Int32rowThe row to add the menu to.

WithSelectMenu(SelectMenuBuilder, Int32)​

Adds a Discord.SelectMenuBuilder to the Discord.ComponentBuilder at the specific row. If the row cannot accept the component then it will add it to a row that can.

View Source​
Declaration
public ComponentBuilder WithSelectMenu(SelectMenuBuilder menu, int row = 0)
Returns​

Discord.ComponentBuilder: The current builder.

Parameters​
TypeNameDescription
Discord.SelectMenuBuildermenuThe menu to add.
System.Int32rowThe row to attempt to add this component on.

WithButton(String, String, ButtonStyle, IEmote, String, Boolean, Int32)​

Adds a Discord.ButtonBuilder with specified parameters to the Discord.ComponentBuilder at the specific row. If the row cannot accept the component then it will add it to a row that can.

View Source​
Declaration
public ComponentBuilder WithButton(string label = null, string customId = null, ButtonStyle style = ButtonStyle.Primary, IEmote emote = null, string url = null, bool disabled = false, int row = 0)
Returns​

Discord.ComponentBuilder: The current builder.

Parameters​
TypeNameDescription
System.StringlabelThe label text for the newly added button.
System.StringcustomIdThe custom id of the newly added button.
Discord.ButtonStylestyleThe style of this newly added button.
Discord.IEmoteemoteA Discord.IEmote to be used with this button.
System.StringurlA URL to be used only if the Discord.ButtonStyle is a Link.
System.BooleandisabledWhether or not the newly created button is disabled.
System.Int32rowThe row the button should be placed on.

WithButton(ButtonBuilder, Int32)​

Adds a Discord.ButtonBuilder to the Discord.ComponentBuilder at the specific row. If the row cannot accept the component then it will add it to a row that can.

View Source​
Declaration
public ComponentBuilder WithButton(ButtonBuilder button, int row = 0)
Returns​

Discord.ComponentBuilder: The current builder.

Parameters​
TypeNameDescription
Discord.ButtonBuilderbuttonThe button to add.
System.Int32rowThe row to add the button.

Build()​

Builds this builder into a Discord.MessageComponent used to send your components.

View Source​
Declaration
public MessageComponent Build()
Returns​

Discord.MessageComponent: A Discord.MessageComponent that can be sent with Discord.IMessageChannel.SendMessageAsync(System.String%2cSystem.Boolean%2cDiscord.Embed%2cDiscord.RequestOptions%2cDiscord.AllowedMentions%2cDiscord.MessageReference%2cDiscord.MessageComponent%2cDiscord.ISticker%5b%5d%2cDiscord.Embed%5b%5d).