@@ -4,18 +4,9 @@ use serde::Serialize;
44
55use crate :: model:: prelude:: * ;
66
7- #[ derive( Clone , Debug ) ]
8- struct StaticU8 < const VAL : u8 > ;
9-
10- impl < const VAL : u8 > Serialize for StaticU8 < VAL > {
11- fn serialize < S : serde:: Serializer > ( & self , ser : S ) -> Result < S :: Ok , S :: Error > {
12- ser. serialize_u8 ( VAL )
13- }
14- }
15-
167/// A builder for creating a components action row in a message.
178///
18- /// [Discord docs](https://discord.com/developers/docs/interactions/message- components#component-object ).
9+ /// [Discord docs](https://discord.com/developers/docs/components/reference#action-row ).
1910#[ derive( Clone , Debug ) ]
2011#[ must_use]
2112pub enum CreateActionRow < ' a > {
@@ -110,7 +101,7 @@ pub enum CreateComponent<'a> {
110101#[ must_use]
111102pub struct CreateSection < ' a > {
112103 #[ serde( rename = "type" ) ]
113- kind : StaticU8 < 9 > ,
104+ kind : ComponentType ,
114105 #[ serde( skip_serializing_if = "<[_]>::is_empty" ) ]
115106 components : Cow < ' a , [ CreateSectionComponent < ' a > ] > ,
116107 accessory : CreateSectionAccessory < ' a > ,
@@ -125,7 +116,7 @@ impl<'a> CreateSection<'a> {
125116 accessory : CreateSectionAccessory < ' a > ,
126117 ) -> Self {
127118 CreateSection {
128- kind : StaticU8 :: < 9 > ,
119+ kind : ComponentType :: Section ,
129120 components : components. into ( ) ,
130121 accessory,
131122 }
@@ -170,7 +161,7 @@ pub enum CreateSectionComponent<'a> {
170161#[ derive( Clone , Debug , Serialize ) ]
171162pub struct CreateTextDisplay < ' a > {
172163 #[ serde( rename = "type" ) ]
173- kind : StaticU8 < 10 > ,
164+ kind : ComponentType ,
174165 content : Cow < ' a , str > ,
175166}
176167
@@ -180,7 +171,7 @@ impl<'a> CreateTextDisplay<'a> {
180171 /// Note: All components on a message shares the same **4000** character limit.
181172 pub fn new ( content : impl Into < Cow < ' a , str > > ) -> Self {
182173 CreateTextDisplay {
183- kind : StaticU8 :: < 10 > ,
174+ kind : ComponentType :: TextDisplay ,
184175 content : content. into ( ) ,
185176 }
186177 }
@@ -210,7 +201,7 @@ pub enum CreateSectionAccessory<'a> {
210201#[ must_use]
211202pub struct CreateThumbnail < ' a > {
212203 #[ serde( rename = "type" ) ]
213- kind : StaticU8 < 11 > ,
204+ kind : ComponentType ,
214205 media : CreateUnfurledMediaItem < ' a > ,
215206 #[ serde( skip_serializing_if = "Option::is_none" ) ]
216207 description : Option < Cow < ' a , str > > ,
@@ -222,7 +213,7 @@ impl<'a> CreateThumbnail<'a> {
222213 /// Creates a new thumbnail with a media item.
223214 pub fn new ( media : CreateUnfurledMediaItem < ' a > ) -> Self {
224215 CreateThumbnail {
225- kind : StaticU8 :: < 11 > ,
216+ kind : ComponentType :: Thumbnail ,
226217 media,
227218 description : None ,
228219 spoiler : None ,
@@ -277,15 +268,15 @@ impl<'a> CreateUnfurledMediaItem<'a> {
277268#[ must_use]
278269pub struct CreateMediaGallery < ' a > {
279270 #[ serde( rename = "type" ) ]
280- kind : StaticU8 < 12 > ,
271+ kind : ComponentType ,
281272 items : Cow < ' a , [ CreateMediaGalleryItem < ' a > ] > ,
282273}
283274
284275impl < ' a > CreateMediaGallery < ' a > {
285276 /// Creates a new media gallery with up to **10** items.
286277 pub fn new ( items : impl Into < Cow < ' a , [ CreateMediaGalleryItem < ' a > ] > > ) -> Self {
287278 CreateMediaGallery {
288- kind : StaticU8 :: < 12 > ,
279+ kind : ComponentType :: MediaGallery ,
289280 items : items. into ( ) ,
290281 }
291282 }
@@ -370,7 +361,7 @@ impl<'a> CreateMediaGalleryItem<'a> {
370361#[ must_use]
371362pub struct CreateFile < ' a > {
372363 #[ serde( rename = "type" ) ]
373- kind : StaticU8 < 13 > ,
364+ kind : ComponentType ,
374365 file : CreateUnfurledMediaItem < ' a > ,
375366 #[ serde( skip_serializing_if = "Option::is_none" ) ]
376367 spoiler : Option < bool > ,
@@ -381,7 +372,7 @@ impl<'a> CreateFile<'a> {
381372 /// limits.
382373 pub fn new ( file : impl Into < CreateUnfurledMediaItem < ' a > > ) -> Self {
383374 CreateFile {
384- kind : StaticU8 :: < 13 > ,
375+ kind : ComponentType :: File ,
385376 file : file. into ( ) ,
386377 spoiler : None ,
387378 }
@@ -406,7 +397,7 @@ impl<'a> CreateFile<'a> {
406397#[ must_use]
407398pub struct CreateSeparator {
408399 #[ serde( rename = "type" ) ]
409- kind : StaticU8 < 14 > ,
400+ kind : ComponentType ,
410401 divider : bool ,
411402 #[ serde( skip_serializing_if = "Option::is_none" ) ]
412403 spacing : Option < Spacing > ,
@@ -416,7 +407,7 @@ impl CreateSeparator {
416407 /// Creates a new separator, with or without a divider.
417408 pub fn new ( divider : bool ) -> Self {
418409 CreateSeparator {
419- kind : StaticU8 :: < 14 > ,
410+ kind : ComponentType :: Separator ,
420411 divider,
421412 spacing : None ,
422413 }
@@ -441,7 +432,7 @@ impl CreateSeparator {
441432#[ must_use]
442433pub struct CreateContainer < ' a > {
443434 #[ serde( rename = "type" ) ]
444- kind : StaticU8 < 17 > ,
435+ kind : ComponentType ,
445436 #[ serde( skip_serializing_if = "Option::is_none" ) ]
446437 accent_color : Option < Colour > ,
447438 #[ serde( skip_serializing_if = "Option::is_none" ) ]
@@ -454,7 +445,7 @@ impl<'a> CreateContainer<'a> {
454445 /// other component except another container!
455446 pub fn new ( components : impl Into < Cow < ' a , [ CreateComponent < ' a > ] > > ) -> Self {
456447 CreateContainer {
457- kind : StaticU8 :: < 17 > ,
448+ kind : ComponentType :: Container ,
458449 accent_color : None ,
459450 spoiler : None ,
460451 components : components. into ( ) ,
@@ -499,11 +490,13 @@ impl<'a> CreateContainer<'a> {
499490}
500491
501492/// A builder for creating a label that can hold an [`InputText`] or [`SelectMenu`].
493+ ///
494+ /// [Discord docs](https://discord.com/developers/docs/components/reference#label).
502495#[ derive( Clone , Debug , Serialize ) ]
503496#[ must_use]
504497pub struct CreateLabel < ' a > {
505498 #[ serde( rename = "type" ) ]
506- kind : StaticU8 < 18 > ,
499+ kind : ComponentType ,
507500 label : Cow < ' a , str > ,
508501 description : Option < Cow < ' a , str > > ,
509502 component : CreateLabelComponent < ' a > ,
@@ -513,7 +506,7 @@ impl<'a> CreateLabel<'a> {
513506 /// Create a select menu with a specific label.
514507 pub fn select_menu ( label : impl Into < Cow < ' a , str > > , select_menu : CreateSelectMenu < ' a > ) -> Self {
515508 Self {
516- kind : StaticU8 :: < 18 > ,
509+ kind : ComponentType :: Label ,
517510 label : label. into ( ) ,
518511 description : None ,
519512 component : CreateLabelComponent :: SelectMenu ( select_menu) ,
@@ -523,7 +516,7 @@ impl<'a> CreateLabel<'a> {
523516 /// Create a text input with a specific label.
524517 pub fn input_text ( label : impl Into < Cow < ' a , str > > , input_text : CreateInputText < ' a > ) -> Self {
525518 Self {
526- kind : StaticU8 :: < 18 > ,
519+ kind : ComponentType :: Label ,
527520 label : label. into ( ) ,
528521 description : None ,
529522 component : CreateLabelComponent :: InputText ( input_text) ,
@@ -716,7 +709,7 @@ impl Serialize for CreateSelectMenuDefault {
716709 }
717710}
718711
719- /// [Discord docs](https://discord.com/developers/docs/interactions/message- components#select-menu- object-select-menu-structure ).
712+ /// [Discord docs](https://discord.com/developers/docs/components/reference#component- object-component-types ).
720713#[ derive( Clone , Debug ) ]
721714pub enum CreateSelectMenuKind < ' a > {
722715 String {
@@ -804,7 +797,7 @@ impl Serialize for CreateSelectMenuKind<'_> {
804797
805798/// A builder for creating a select menu component in a message
806799///
807- /// [Discord docs](https://discord.com/developers/docs/interactions/message- components#select-menu- object-select-menu-structure ).
800+ /// [Discord docs](https://discord.com/developers/docs/components/reference#component- object-component-types ).
808801#[ derive( Clone , Debug , Serialize ) ]
809802#[ must_use]
810803pub struct CreateSelectMenu < ' a > {
@@ -870,7 +863,7 @@ impl<'a> CreateSelectMenu<'a> {
870863
871864/// A builder for creating an option of a select menu component in a message
872865///
873- /// [Discord docs](https://discord.com/developers/docs/interactions/message- components#select-menu-object -select-option-structure)
866+ /// [Discord docs](https://discord.com/developers/docs/components/reference#string-select -select-option-structure)
874867#[ derive( Clone , Debug , Serialize ) ]
875868#[ must_use]
876869pub struct CreateSelectMenuOption < ' a > {
@@ -930,7 +923,7 @@ impl<'a> CreateSelectMenuOption<'a> {
930923
931924/// A builder for creating an input text component in a modal
932925///
933- /// [Discord docs](https://discord.com/developers/docs/interactions/message- components#text-inputs-text- input-structure ).
926+ /// [Discord docs](https://discord.com/developers/docs/components/reference #text-input).
934927#[ derive( Clone , Debug , Serialize ) ]
935928#[ must_use]
936929pub struct CreateInputText < ' a > {
0 commit comments