@@ -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 ( ) ,
@@ -503,7 +494,7 @@ impl<'a> CreateContainer<'a> {
503494#[ must_use]
504495pub struct CreateLabel < ' a > {
505496 #[ serde( rename = "type" ) ]
506- kind : StaticU8 < 18 > ,
497+ kind : ComponentType ,
507498 label : Cow < ' a , str > ,
508499 description : Option < Cow < ' a , str > > ,
509500 component : CreateLabelComponent < ' a > ,
@@ -516,7 +507,7 @@ impl<'a> CreateLabel<'a> {
516507 select_menu : impl Into < CreateSelectMenu < ' a > > ,
517508 ) -> Self {
518509 Self {
519- kind : StaticU8 :: < 18 > ,
510+ kind : ComponentType :: Label ,
520511 label : label. into ( ) ,
521512 description : None ,
522513 component : CreateLabelComponent :: SelectMenu ( select_menu. into ( ) ) ,
@@ -529,7 +520,7 @@ impl<'a> CreateLabel<'a> {
529520 input_text : impl Into < CreateInputText < ' a > > ,
530521 ) -> Self {
531522 Self {
532- kind : StaticU8 :: < 18 > ,
523+ kind : ComponentType :: Label ,
533524 label : label. into ( ) ,
534525 description : None ,
535526 component : CreateLabelComponent :: InputText ( input_text. into ( ) ) ,
@@ -722,7 +713,7 @@ impl Serialize for CreateSelectMenuDefault {
722713 }
723714}
724715
725- /// [Discord docs](https://discord.com/developers/docs/interactions/message- components#select-menu- object-select-menu-structure ).
716+ /// [Discord docs](https://discord.com/developers/docs/components/reference#component- object-component-types ).
726717#[ derive( Clone , Debug ) ]
727718pub enum CreateSelectMenuKind < ' a > {
728719 String {
@@ -810,7 +801,7 @@ impl Serialize for CreateSelectMenuKind<'_> {
810801
811802/// A builder for creating a select menu component in a message
812803///
813- /// [Discord docs](https://discord.com/developers/docs/interactions/message- components#select-menu- object-select-menu-structure ).
804+ /// [Discord docs](https://discord.com/developers/docs/components/reference#component- object-component-types ).
814805#[ derive( Clone , Debug , Serialize ) ]
815806#[ must_use]
816807pub struct CreateSelectMenu < ' a > {
@@ -876,7 +867,7 @@ impl<'a> CreateSelectMenu<'a> {
876867
877868/// A builder for creating an option of a select menu component in a message
878869///
879- /// [Discord docs](https://discord.com/developers/docs/interactions/message- components#select-menu-object -select-option-structure)
870+ /// [Discord docs](https://discord.com/developers/docs/components/reference#string-select -select-option-structure)
880871#[ derive( Clone , Debug , Serialize ) ]
881872#[ must_use]
882873pub struct CreateSelectMenuOption < ' a > {
@@ -936,7 +927,7 @@ impl<'a> CreateSelectMenuOption<'a> {
936927
937928/// A builder for creating an input text component in a modal
938929///
939- /// [Discord docs](https://discord.com/developers/docs/interactions/message- components#text-inputs-text- input-structure ).
930+ /// [Discord docs](https://discord.com/developers/docs/components/reference #text-input).
940931#[ derive( Clone , Debug , Serialize ) ]
941932#[ must_use]
942933pub struct CreateInputText < ' a > {
0 commit comments