Class ActionRowBuilder
- Namespace
- Discord
- Assembly
- Discord.Net.Core.dll
Represents a class used to build Action rows.
public class ActionRowBuilder : IMessageComponentBuilder, IInteractableComponentContainer, IComponentContainer
- Inheritance
-
ActionRowBuilder
- Implements
- Inherited Members
- Extension Methods
Constructors
ActionRowBuilder()
Initializes a new ActionRowBuilder.
public ActionRowBuilder()
ActionRowBuilder(ActionRowComponent)
Initializes a new ActionRowBuilder from existing component.
public ActionRowBuilder(ActionRowComponent actionRow)
Parameters
actionRowActionRowComponent
ActionRowBuilder(params IMessageComponentBuilder[])
Initializes a new ActionRowBuilder.
public ActionRowBuilder(params IMessageComponentBuilder[] components)
Parameters
componentsIMessageComponentBuilder[]
Fields
MaxChildCount
The max amount of child components this row can hold.
public const int MaxChildCount = 5
Field Value
Properties
Components
Gets or sets the components inside this row.
public List<IMessageComponentBuilder> Components { get; set; }
Property Value
Exceptions
- ArgumentNullException
Components cannot be null.
- ArgumentException
Components count exceeds MaxChildCount.
Id
Gets or sets the id for the component. An autoincremented id will be assigned if not set.
public int? Id { get; set; }
Property Value
- int?
SupportedComponentTypes
Gets the types of child components supported by this container.
public ImmutableArray<ComponentType> SupportedComponentTypes { get; }
Property Value
Type
Gets the type of the component.
public ComponentType Type { get; }
Property Value
Methods
AddComponent(IMessageComponentBuilder)
Adds a component at the end of the current row.
public ActionRowBuilder AddComponent(IMessageComponentBuilder component)
Parameters
componentIMessageComponentBuilderThe component to add.
Returns
- ActionRowBuilder
The current builder.
Exceptions
- InvalidOperationException
Components count reached MaxChildCount
AddComponents(params IMessageComponentBuilder[])
Adds components to the container.
public ActionRowBuilder AddComponents(params IMessageComponentBuilder[] components)
Parameters
componentsIMessageComponentBuilder[]
Returns
- ActionRowBuilder
The current container.
Build()
Builds the current builder to a ActionRowComponent that can be used within a ComponentBuilder
public ActionRowComponent Build()
Returns
- ActionRowComponent
A ActionRowComponent that can be used within a ComponentBuilder
WithButton(ButtonBuilder)
Adds a ButtonBuilder to the ActionRowBuilder.
public ActionRowBuilder WithButton(ButtonBuilder button)
Parameters
buttonButtonBuilderThe button to add.
Returns
- ActionRowBuilder
The current builder.
Exceptions
- InvalidOperationException
Components count reached MaxChildCount.
- InvalidOperationException
A button cannot be added to a row with a SelectMenu.
WithButton(string, string, ButtonStyle, IEmote, string, bool)
Adds a ButtonBuilder with specified parameters to the ActionRowBuilder.
public ActionRowBuilder WithButton(string label = null, string customId = null, ButtonStyle style = ButtonStyle.Primary, IEmote emote = null, string url = null, bool disabled = false)
Parameters
labelstringThe label text for the newly added button.
customIdstringThe custom id of the newly added button.
styleButtonStyleThe style of this newly added button.
emoteIEmoteA IEmote to be used with this button.
urlstringA URL to be used only if the ButtonStyle is a Link.
disabledboolWhether or not the newly created button is disabled.
Returns
- ActionRowBuilder
The current builder.
WithComponents(IEnumerable<IMessageComponentBuilder>)
Sets the components in the container.
public ActionRowBuilder WithComponents(IEnumerable<IMessageComponentBuilder> components)
Parameters
componentsIEnumerable<IMessageComponentBuilder>
Returns
- ActionRowBuilder
The current container.
WithComponents(List<IMessageComponentBuilder>)
Adds a list of components to the current row.
public ActionRowBuilder WithComponents(List<IMessageComponentBuilder> components)
Parameters
componentsList<IMessageComponentBuilder>The list of components to add.
Returns
- ActionRowBuilder
The current builder.
Exceptions
- ArgumentNullException
Components cannot be null.
- ArgumentException
Components count exceeds MaxChildCount.
WithSelectMenu(SelectMenuBuilder)
Adds a SelectMenuBuilder to the ActionRowBuilder.
public ActionRowBuilder WithSelectMenu(SelectMenuBuilder menu)
Parameters
menuSelectMenuBuilderThe menu to add.
Returns
- ActionRowBuilder
The current builder.
Exceptions
- InvalidOperationException
A Select Menu cannot exist in a pre-occupied ActionRow.
WithSelectMenu(string, List<SelectMenuOptionBuilder>, string, int, int, bool, ComponentType, ChannelType[])
Adds a SelectMenuBuilder to the ActionRowBuilder.
public ActionRowBuilder WithSelectMenu(string customId, List<SelectMenuOptionBuilder> options = null, string placeholder = null, int minValues = 1, int maxValues = 1, bool disabled = false, ComponentType type = ComponentType.SelectMenu, ChannelType[] channelTypes = null)
Parameters
customIdstringThe custom id of the menu.
optionsList<SelectMenuOptionBuilder>The options of the menu.
placeholderstringThe placeholder of the menu.
minValuesintThe min values of the placeholder.
maxValuesintThe max values of the placeholder.
disabledboolWhether or not the menu is disabled.
typeComponentTypeThe type of the select menu.
channelTypesChannelType[]Menus valid channel types (only for ChannelSelect)
Returns
- ActionRowBuilder
The current builder.