@@ -62,7 +62,7 @@ pub enum Component {
6262 Separator ( Separator ) ,
6363 File ( FileComponent ) ,
6464 Container ( Container ) ,
65- Unknown ,
65+ Unknown ( u8 ) ,
6666 // always update the macro below.
6767}
6868
@@ -75,6 +75,8 @@ impl<'de> Deserialize<'de> for Component {
7575 where
7676 D : Deserializer < ' de > ,
7777 {
78+ use serde_json:: value:: RawValue ;
79+
7880 #[ derive( Deserialize ) ]
7981 struct ComponentRaw {
8082 #[ serde( rename = "type" ) ]
@@ -104,11 +106,8 @@ impl<'de> Deserialize<'de> for Component {
104106 ComponentType :: Separator => Deserialize :: deserialize ( value) . map ( Component :: Separator ) ,
105107 ComponentType :: File => Deserialize :: deserialize ( value) . map ( Component :: File ) ,
106108 ComponentType :: Container => Deserialize :: deserialize ( value) . map ( Component :: Container ) ,
107- // TODO: maybe just not include it so the deserialization doesn't explode.
108- // With all new component types right now, the ENTIRE message won't deserialize.
109- // I need to do other stuff in other places too so that its as resilent as possible, it
110- // should not die when discord adds new stuff.
111- _ => Err ( DeError :: custom ( "Unknown component type" ) ) ,
109+ ComponentType :: Thumbnail => Deserialize :: deserialize ( value) . map ( Component :: Thumbnail ) ,
110+ ComponentType ( i) => Ok ( Component :: Unknown ( i) ) ,
112111 }
113112 . map_err ( DeError :: custom)
114113 }
@@ -157,18 +156,7 @@ pub struct Thumbnail {
157156 pub spoiler : Option < bool > ,
158157}
159158
160- /// An abstraction over a resolved and unresolved unfurled media item.
161- #[ cfg_attr( feature = "typesize" , derive( typesize:: derive:: TypeSize ) ) ]
162- #[ derive( Clone , Debug , Deserialize , Serialize ) ]
163- #[ non_exhaustive]
164- #[ serde( untagged) ]
165- #[ cfg( feature = "unstable" ) ]
166- pub enum MediaItem {
167- Resolved ( ResolvedUnfurledMediaItem ) ,
168- Unresolved ( UnfurledMediaItem ) ,
169- }
170-
171- /// An unfurled media item, stores the url to the item.
159+ /// An unfurled media item.
172160///
173161/// [Incomplete Discord docs](https://github.com/Lulalaby/discord-api-docs/pull/30)
174162#[ cfg_attr( feature = "typesize" , derive( typesize:: derive:: TypeSize ) ) ]
@@ -178,18 +166,6 @@ pub enum MediaItem {
178166pub struct UnfurledMediaItem {
179167 /// The url of this item.
180168 pub url : FixedString < u16 > ,
181- }
182-
183- /// A resolved unfurled media item, with extra metadata added by Discord.
184- ///
185- /// [Incomplete Discord docs](https://github.com/Lulalaby/discord-api-docs/pull/30)
186- #[ cfg_attr( feature = "typesize" , derive( typesize:: derive:: TypeSize ) ) ]
187- #[ derive( Clone , Debug , Deserialize , Serialize ) ]
188- #[ non_exhaustive]
189- #[ cfg( feature = "unstable" ) ]
190- pub struct ResolvedUnfurledMediaItem {
191- /// The url of this item.
192- pub url : FixedString < u16 > ,
193169 /// The proxied discord url.
194170 pub proxy_url : Option < FixedString < u16 > > ,
195171 /// The width of the media item.
0 commit comments