@@ -16,7 +16,7 @@ public sealed class DiscordSectionComponent : DiscordComponent
16
16
/// <summary>
17
17
/// Constructs a new <see cref="DiscordSectionComponent" />.
18
18
/// </summary>
19
- internal DiscordSectionComponent ( )
19
+ public DiscordSectionComponent ( )
20
20
{
21
21
this . Type = ComponentType . Section ;
22
22
}
@@ -51,7 +51,7 @@ public DiscordSectionComponent(IEnumerable<DiscordTextDisplayComponent> componen
51
51
/// The components for the section.
52
52
/// </summary>
53
53
[ JsonProperty ( "components" , NullValueHandling = NullValueHandling . Ignore ) ]
54
- public IReadOnlyList < DiscordTextDisplayComponent > Components { get ; internal set ; } = [ ] ;
54
+ public List < DiscordTextDisplayComponent > Components { get ; internal set ; } = [ ] ;
55
55
56
56
/// <summary>
57
57
/// The accessory for the section.
@@ -93,4 +93,32 @@ public DiscordSectionComponent WithId(int id)
93
93
this . Id = id ;
94
94
return this ;
95
95
}
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
+ }
96
124
}
0 commit comments