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(ActionRowComponent)
Initializes a new ActionRowBuilder from existing component.
public ActionRowBuilder(ActionRowComponent actionRow)
Parameters
actionRow
ActionRowComponent
ActionRowBuilder(params IMessageComponentBuilder[])
Initializes a new ActionRowBuilder.
public ActionRowBuilder(params IMessageComponentBuilder[] components)
Parameters
components
IMessageComponentBuilder[]
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?
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
component
IMessageComponentBuilderThe 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
components
IMessageComponentBuilder[]
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
button
ButtonBuilderThe 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
label
stringThe label text for the newly added button.
customId
stringThe custom id of the newly added button.
style
ButtonStyleThe style of this newly added button.
emote
IEmoteA IEmote to be used with this button.
url
stringA URL to be used only if the ButtonStyle is a Link.
disabled
boolWhether 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
components
IEnumerable<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
components
List<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
menu
SelectMenuBuilderThe 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
customId
stringThe custom id of the menu.
options
List<SelectMenuOptionBuilder>The options of the menu.
placeholder
stringThe placeholder of the menu.
minValues
intThe min values of the placeholder.
maxValues
intThe max values of the placeholder.
disabled
boolWhether or not the menu is disabled.
type
ComponentTypeThe type of the select menu.
channelTypes
ChannelType[]Menus valid channel types (only for ChannelSelect)
Returns
- ActionRowBuilder
The current builder.