Class ActionRowBuilder
- Namespace
- Discord
- Assembly
- Discord.Net.Core.dll
Represents a class used to build Action rows.
public class ActionRowBuilder
- Inheritance
-
ActionRowBuilder
- Inherited Members
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<IMessageComponent> Components { get; set; }
Property Value
Exceptions
- ArgumentNullException
Components cannot be null.
- ArgumentException
Components count exceeds MaxChildCount.
Methods
AddComponent(IMessageComponent)
Adds a component at the end of the current row.
public ActionRowBuilder AddComponent(IMessageComponent component)
Parameters
component
IMessageComponentThe component to add.
Returns
- ActionRowBuilder
The current builder.
Exceptions
- InvalidOperationException
Components count reached MaxChildCount
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(List<IMessageComponent>)
Adds a list of components to the current row.
public ActionRowBuilder WithComponents(List<IMessageComponent> components)
Parameters
components
List<IMessageComponent>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.