Table of Contents

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

int

Properties

Components

Gets or sets the components inside this row.

public List<IMessageComponentBuilder> Components { get; set; }

Property Value

List<IMessageComponentBuilder>

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

ComponentType

Methods

AddComponent(IMessageComponentBuilder)

Adds a component at the end of the current row.

public ActionRowBuilder AddComponent(IMessageComponentBuilder component)

Parameters

component IMessageComponentBuilder

The 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)

public ActionRowBuilder WithButton(ButtonBuilder button)

Parameters

button ButtonBuilder

The 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 string

The label text for the newly added button.

customId string

The custom id of the newly added button.

style ButtonStyle

The style of this newly added button.

emote IEmote

A IEmote to be used with this button.

url string

A URL to be used only if the ButtonStyle is a Link.

disabled bool

Whether 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)

public ActionRowBuilder WithSelectMenu(SelectMenuBuilder menu)

Parameters

menu SelectMenuBuilder

The 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[])

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 string

The custom id of the menu.

options List<SelectMenuOptionBuilder>

The options of the menu.

placeholder string

The placeholder of the menu.

minValues int

The min values of the placeholder.

maxValues int

The max values of the placeholder.

disabled bool

Whether or not the menu is disabled.

type ComponentType

The type of the select menu.

channelTypes ChannelType[]

Menus valid channel types (only for ChannelSelect)

Returns

ActionRowBuilder

The current builder.