Skip to content

Commit c536d19

Browse files
committed
Update DiscordSectionComponent.cs
1 parent 004d75b commit c536d19

File tree

1 file changed

+30
-2
lines changed

1 file changed

+30
-2
lines changed

DisCatSharp/Entities/Interaction/Components/V2Components/DiscordSectionComponent.cs

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public sealed class DiscordSectionComponent : DiscordComponent
1616
/// <summary>
1717
/// Constructs a new <see cref="DiscordSectionComponent" />.
1818
/// </summary>
19-
internal DiscordSectionComponent()
19+
public DiscordSectionComponent()
2020
{
2121
this.Type = ComponentType.Section;
2222
}
@@ -51,7 +51,7 @@ public DiscordSectionComponent(IEnumerable<DiscordTextDisplayComponent> componen
5151
/// The components for the section.
5252
/// </summary>
5353
[JsonProperty("components", NullValueHandling = NullValueHandling.Ignore)]
54-
public IReadOnlyList<DiscordTextDisplayComponent> Components { get; internal set; } = [];
54+
public List<DiscordTextDisplayComponent> Components { get; internal set; } = [];
5555

5656
/// <summary>
5757
/// The accessory for the section.
@@ -93,4 +93,32 @@ public DiscordSectionComponent WithId(int id)
9393
this.Id = id;
9494
return this;
9595
}
96+
97+
/// <summary>
98+
/// Adds a text display components to the section.
99+
/// </summary>
100+
/// <param name="component">The component to add.</param>
101+
/// <exception cref="ArgumentException">Thrown if the number of components exceeds 3.</exception>
102+
public DiscordSectionComponent AddTextDisplayComponent(DiscordTextDisplayComponent component)
103+
{
104+
if (this.Components.Count >= 3)
105+
throw new ArgumentException("You can only have up to 3 components in a section.");
106+
107+
this.Components.Add(component);
108+
return this;
109+
}
110+
111+
/// <summary>
112+
/// Adds multiple text display components to the section.
113+
/// </summary>
114+
/// <param name="components">The components to add.</param>
115+
/// <exception cref="ArgumentException">Thrown if the number of components exceeds 3.</exception>
116+
public DiscordSectionComponent AddTextDisplayComponents(IEnumerable<DiscordTextDisplayComponent> components)
117+
{
118+
if (this.Components.Count >= 3)
119+
throw new ArgumentException("You can only have up to 3 components in a section.");
120+
121+
this.Components.AddRange(components);
122+
return this;
123+
}
96124
}

0 commit comments

Comments
 (0)