diff --git a/src/Discord.Net.Core/Entities/Interactions/MessageComponents/ComponentBuilder.cs b/src/Discord.Net.Core/Entities/Interactions/MessageComponents/ComponentBuilder.cs index 4461a4205..b086535f7 100644 --- a/src/Discord.Net.Core/Entities/Interactions/MessageComponents/ComponentBuilder.cs +++ b/src/Discord.Net.Core/Entities/Interactions/MessageComponents/ComponentBuilder.cs @@ -238,6 +238,38 @@ namespace Discord return this; } + /// + /// Adds a row to this component builder. + /// + /// The row to add. + /// The component builder contains the max amount of rows defined as . + /// The current builder. + public ComponentBuilder AddRow(ActionRowBuilder row) + { + _actionRows ??= new(); + + if (_actionRows.Count >= MaxActionRowCount) + throw new IndexOutOfRangeException("The max amount of rows has been reached"); + + ActionRows.Add(row); + return this; + } + + /// + /// Sets the rows of this component builder to a specified collection. + /// + /// The rows to set. + /// The collection contains more rows then is allowed by discord. + /// The current builder. + public ComponentBuilder WithRows(IEnumerable rows) + { + if (rows.Count() > MaxActionRowCount) + throw new IndexOutOfRangeException($"Cannot have more than {MaxActionRowCount} rows"); + + _actionRows = new List(rows); + return this; + } + /// /// Builds this builder into a used to send your components. ///