@@ -116,8 +116,15 @@ pub struct Section {
116116 /// Always [`ComponentType::Section`]
117117 #[ serde( rename = "type" ) ]
118118 pub kind : ComponentType ,
119- components : FixedArray < SectionComponent > ,
120- accessory : SectionAccessory ,
119+ /// The components inside of the section.
120+ ///
121+ /// As of 2025-02-28, this is limited to just [`ComponentType::TextDisplay`] with up to 3 max.
122+ pub components : FixedArray < Component > ,
123+ /// The accessory to the side of the section.
124+ ///
125+ /// As of 2025-02-28, this is limited to [`ComponentType::Button`] or
126+ /// [`ComponentType::Thumbnail`]
127+ pub accessory : Box < Component > ,
121128}
122129
123130/// A section component's thumbnail.
@@ -132,8 +139,11 @@ pub struct Thumbnail {
132139 /// Always [`ComponentType::Thumbnail`]
133140 #[ serde( rename = "type" ) ]
134141 pub kind : ComponentType ,
135- media : UnfurledMediaItem ,
142+ /// The internal media item this contains.
143+ pub media : UnfurledMediaItem ,
144+ /// The description of the thumbnail.
136145 description : Option < FixedString < u16 > > ,
146+ /// Whether or not this component is spoilered.
137147 spoiler : Option < bool > ,
138148}
139149
@@ -154,7 +164,8 @@ pub enum MediaItem {
154164#[ derive( Clone , Debug , Deserialize , Serialize ) ]
155165#[ non_exhaustive]
156166pub struct UnfurledMediaItem {
157- url : FixedString < u16 > ,
167+ /// The url of this item.
168+ pub url : FixedString < u16 > ,
158169}
159170
160171/// A resolved unfurled media item, with extra metadata added by Discord.
@@ -164,12 +175,18 @@ pub struct UnfurledMediaItem {
164175#[ derive( Clone , Debug , Deserialize , Serialize ) ]
165176#[ non_exhaustive]
166177pub struct ResolvedUnfurledMediaItem {
167- url : FixedString < u16 > ,
168- proxy_url : FixedString < u16 > ,
169- width : NonMaxU32 ,
170- height : NonMaxU32 ,
171- content_type : FixedString ,
172- loading_state : UnfurledMediaItemLoadingState ,
178+ /// The url of this item.
179+ pub url : FixedString < u16 > ,
180+ /// The proxied discord url.
181+ pub proxy_url : FixedString < u16 > ,
182+ /// The width of the media item.
183+ pub width : NonMaxU32 ,
184+ /// The height of the media item.
185+ pub height : NonMaxU32 ,
186+ /// The content type of the media item.
187+ pub content_type : FixedString ,
188+ /// The loading state of the item, declaring if it has fully loaded yet.
189+ pub loading_state : UnfurledMediaItemLoadingState ,
173190}
174191
175192enum_number ! {
@@ -186,51 +203,15 @@ enum_number! {
186203 }
187204}
188205
189- /// A list of valid components for an accessory of a section.
190- ///
191- /// See [`Section`] for how this works.
192- ///
193- /// [Incomplete Discord docs](https://github.com/Lulalaby/discord-api-docs/pull/30)
194- #[ cfg_attr( feature = "typesize" , derive( typesize:: derive:: TypeSize ) ) ]
195- #[ derive( Clone , Debug , Serialize ) ]
196- #[ non_exhaustive]
197- pub enum SectionAccessory {
198- Thumbnail ( Thumbnail ) ,
199- Button ( Button ) ,
200- Unknown ,
201- // always update the macro below.
202- }
203-
204- impl_deserialize_component ! ( SectionAccessory ,
205- ComponentType :: Button => SectionAccessory :: Button ,
206- ComponentType :: Thumbnail => SectionAccessory :: Thumbnail
207- ) ;
208-
209- /// The valid components a section can contain.
210- ///
211- /// See [`Section`] for other details.
212- ///
213- /// [Incomplete Discord docs](https://github.com/Lulalaby/discord-api-docs/pull/30)
214- #[ cfg_attr( feature = "typesize" , derive( typesize:: derive:: TypeSize ) ) ]
215- #[ derive( Clone , Debug , Serialize ) ]
216- #[ non_exhaustive]
217- pub enum SectionComponent {
218- TextDisplay ( TextDisplay ) ,
219- Unknown ,
220- }
221-
222- impl_deserialize_component ! ( SectionComponent ,
223- ComponentType :: TextDisplay => SectionComponent :: TextDisplay
224- ) ;
225-
226206/// A text display component.
227207///
228208/// [Incomplete Discord docs](https://github.com/Lulalaby/discord-api-docs/pull/30)
229209#[ cfg_attr( feature = "typesize" , derive( typesize:: derive:: TypeSize ) ) ]
230210#[ derive( Clone , Debug , Deserialize , Serialize ) ]
231211#[ non_exhaustive]
232212pub struct TextDisplay {
233- content : FixedString < u16 > ,
213+ /// The content of this text display component.
214+ pub content : FixedString < u16 > ,
234215}
235216
236217/// A media gallery component.
@@ -243,7 +224,8 @@ pub struct MediaGallery {
243224 /// Always [`ComponentType::MediaGallery`]
244225 #[ serde( rename = "type" ) ]
245226 pub kind : ComponentType ,
246- items : FixedArray < MediaGalleryItem > ,
227+ /// Array of images this media gallery can contain, max of 10.
228+ pub items : FixedArray < MediaGalleryItem > ,
247229}
248230
249231/// An individual media gallery item.
@@ -255,9 +237,12 @@ pub struct MediaGallery {
255237#[ derive( Clone , Debug , Deserialize , Serialize ) ]
256238#[ non_exhaustive]
257239pub struct MediaGalleryItem {
258- media : UnfurledMediaItem ,
259- description : Option < FixedString < u16 > > ,
260- spoiler : Option < bool > ,
240+ /// The internal media piece that this item contains.
241+ pub media : UnfurledMediaItem ,
242+ /// The description of the media item.
243+ pub description : Option < FixedString < u16 > > ,
244+ /// Whether or not this component is spoilered.
245+ pub spoiler : Option < bool > ,
261246}
262247
263248/// A separator component
@@ -270,8 +255,10 @@ pub struct Separator {
270255 /// Always [`ComponentType::Separator`]
271256 #[ serde( rename = "type" ) ]
272257 pub kind : ComponentType ,
273- divider : Option < bool > ,
274- spacing : Option < SeparatorSpacingSize > ,
258+ /// Whether or not this contains a separating divider.
259+ pub divider : Option < bool > ,
260+ /// The spacing of the separator.
261+ pub spacing : Option < SeparatorSpacingSize > ,
275262}
276263
277264enum_number ! {
@@ -296,8 +283,10 @@ pub struct FileComponent {
296283 /// Always [`ComponentType::File`]
297284 #[ serde( rename = "type" ) ]
298285 pub kind : ComponentType ,
299- file : UnfurledMediaItem ,
300- spoiler : Option < bool > ,
286+ /// The file this component internally contains.
287+ pub file : UnfurledMediaItem ,
288+ /// Whether or not this component is spoilered.
289+ pub spoiler : Option < bool > ,
301290}
302291
303292/// A container component, similar to an embed but without all the functionality.
@@ -310,9 +299,16 @@ pub struct Container {
310299 /// Always [`ComponentType::Container`]
311300 #[ serde( rename = "type" ) ]
312301 pub kind : ComponentType ,
313- accent_color : Option < Colour > ,
314- spoiler : Option < bool > ,
315- components : FixedArray < Component > ,
302+ /// The accent colour, similar to an embeds accent.
303+ pub accent_color : Option < Colour > ,
304+ /// Whether or not this component is spoilered.
305+ pub spoiler : Option < bool > ,
306+ /// The components within this container.
307+ ///
308+ /// As of 2025-02-28, this can be [`ComponentType::ActionRow`], [`ComponentType::Section`],
309+ /// [`ComponentType::TextDisplay`], [`ComponentType::MediaGallery`], [`ComponentType::File`] or
310+ /// [`ComponentType::Separator`]
311+ pub components : FixedArray < Component > ,
316312}
317313
318314/// An action row.
0 commit comments