twilight_model/channel/message/
mod.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
//! Textual user communication method.
#![warn(missing_docs)]

pub mod component;
pub mod embed;
pub mod sticker;

mod activity;
mod allowed_mentions;
mod application;
mod call;
mod flags;
mod interaction;
mod kind;
mod mention;
mod reaction;
mod reaction_type;
mod reference;
mod reference_type;
mod role_subscription_data;
mod snapshot;

pub use self::{
    activity::{MessageActivity, MessageActivityType},
    allowed_mentions::{AllowedMentions, MentionType},
    application::MessageApplication,
    call::MessageCall,
    component::Component,
    embed::Embed,
    flags::MessageFlags,
    interaction::MessageInteraction,
    kind::MessageType,
    mention::Mention,
    reaction::{EmojiReactionType, Reaction, ReactionCountDetails},
    reaction_type::ReactionType,
    reference::MessageReference,
    reference_type::MessageReferenceType,
    role_subscription_data::RoleSubscriptionData,
    snapshot::MessageSnapshot,
    sticker::{MessageSticker, Sticker},
};

use crate::{
    application::interaction::InteractionMetadata,
    channel::{Attachment, Channel, ChannelMention},
    guild::PartialMember,
    id::{
        marker::{
            ApplicationMarker, ChannelMarker, GuildMarker, MessageMarker, RoleMarker, WebhookMarker,
        },
        Id,
    },
    poll::Poll,
    user::User,
    util::Timestamp,
};
use serde::{Deserialize, Serialize};

/// Text message sent in a [`Channel`].
#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)]
pub struct Message {
    /// Present with Rich Presence-related chat embeds.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub activity: Option<MessageActivity>,
    /// Present with Rich Presence-related chat embeds.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub application: Option<MessageApplication>,
    /// Associated application's ID.
    ///
    /// Present if the message is a response to an [`Interaction`].
    ///
    /// [`Interaction`]: crate::application::interaction::Interaction
    #[serde(skip_serializing_if = "Option::is_none")]
    pub application_id: Option<Id<ApplicationMarker>>,
    /// List of attachments.
    ///
    /// Receiving the attachments of messages requires that the
    /// [Message Content Intent] be enabled for the application. In the case of
    /// receiving messages over the Gateway, the intent must also be enabled for
    /// the session.
    ///
    /// Message attachments will be empty unless the [Message Content Intent] is
    /// enabled, the message was sent by the current user, or the message is in
    /// a direct message channel.
    ///
    /// [Message Content Intent]: crate::gateway::Intents::MESSAGE_CONTENT
    pub attachments: Vec<Attachment>,
    /// Author of the message.
    pub author: User,
    /// The call associated with the message.
    pub call: Option<MessageCall>,
    /// ID of the [`Channel`] the message was sent in.
    pub channel_id: Id<ChannelMarker>,
    /// List of provided components, such as buttons.
    ///
    /// Receiving the components of messages requires that the
    /// [Message Content Intent] be enabled for the application. In the case of
    /// receiving messages over the Gateway, the intent must also be enabled for
    /// the session.
    ///
    /// Message components will be empty unless the [Message Content Intent] is
    /// enabled, the message was sent by the current user, or the message is in
    /// a direct message channel.
    ///
    /// [Message Content Intent]: crate::gateway::Intents::MESSAGE_CONTENT
    #[serde(default, skip_serializing_if = "Vec::is_empty")]
    pub components: Vec<Component>,
    /// Content of the message.
    ///
    /// Receiving the content of messages requires that the
    /// [Message Content Intent] be enabled for the application. In the case of
    /// receiving messages over the Gateway, the intent must also be enabled for
    /// the session.
    ///
    /// Message content will be empty unless the [Message Content Intent] is
    /// enabled, the message was sent by the current user, or the message is in
    /// a direct message channel.
    ///
    /// [Message Content Intent]: crate::gateway::Intents::MESSAGE_CONTENT
    pub content: String,
    /// When the message was last edited.
    pub edited_timestamp: Option<Timestamp>,
    /// List of embeds.
    ///
    /// Receiving the embeds of messages requires that the
    /// [Message Content Intent] be enabled for the application. In the case of
    /// receiving messages over the Gateway, the intent must also be enabled for
    /// the session.
    ///
    /// Message embeds will be empty unless the [Message Content Intent] is
    /// enabled, the message was sent by the current user, or the message is in
    /// a direct message channel.
    ///
    /// [Message Content Intent]: crate::gateway::Intents::MESSAGE_CONTENT
    pub embeds: Vec<Embed>,
    /// Flags of the message.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub flags: Option<MessageFlags>,
    /// ID of the [`Guild`] the message was sent in.
    ///
    /// [`Guild`]: crate::guild::Guild
    #[serde(skip_serializing_if = "Option::is_none")]
    pub guild_id: Option<Id<GuildMarker>>,
    /// Id of the message.
    pub id: Id<MessageMarker>,
    /// Interaction the message was sent as a response to.
    #[deprecated(note = "use interaction_metadata instead")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub interaction: Option<MessageInteraction>,
    /// Contains metadata related to the interacting if the message is
    /// sent as a result of an interaction.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub interaction_metadata: Option<Box<InteractionMetadata>>,
    /// Type of message.
    #[serde(rename = "type")]
    pub kind: MessageType,
    /// Member properties of the [`author`].
    ///
    /// [`author`]: Message::author
    #[serde(skip_serializing_if = "Option::is_none")]
    pub member: Option<PartialMember>,
    /// [`Channel`]s mentioned in the message.
    ///
    /// Note: only textual channels visible to everyone mentioned in crossposted
    /// messages (via channel following) will be included.
    #[serde(default, skip_serializing_if = "Vec::is_empty")]
    pub mention_channels: Vec<ChannelMention>,
    /// Whether the message mentions `@everyone`.
    pub mention_everyone: bool,
    /// [`Role`]s mentioned in the message.
    ///
    /// [`Role`]: crate::guild::Role
    pub mention_roles: Vec<Id<RoleMarker>>,
    /// Users mentioned in the message.
    pub mentions: Vec<Mention>,
    /// The message associated with the [`MessageReference`]. This is a minimal subset
    /// of fields in a message (e.g. author is excluded.).
    #[serde(default, skip_serializing_if = "Vec::is_empty")]
    pub message_snapshots: Vec<MessageSnapshot>,
    /// Whether the message is pinned.
    pub pinned: bool,
    /// The poll associated with the message.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub poll: Option<Poll>,
    /// List of reactions to the message.
    #[serde(default, skip_serializing_if = "Vec::is_empty")]
    pub reactions: Vec<Reaction>,
    /// Crosspost, channel follow add, pin and reply source message data.
    #[serde(rename = "message_reference", skip_serializing_if = "Option::is_none")]
    pub reference: Option<MessageReference>,
    /// The message associated with the [`reference`].
    ///
    /// [`reference`]: Self::reference
    #[serde(skip_serializing_if = "Option::is_none")]
    pub referenced_message: Option<Box<Message>>,
    /// Information about the role subscription purchase or renewal that
    /// prompted this message.
    ///
    /// Applies to [`RoleSubscriptionPurchase`] messages.
    ///
    /// [`RoleSubscriptionPurchase`]: MessageType::RoleSubscriptionPurchase
    #[serde(skip_serializing_if = "Option::is_none")]
    pub role_subscription_data: Option<RoleSubscriptionData>,
    /// Stickers within the message.
    #[serde(default)]
    pub sticker_items: Vec<MessageSticker>,
    /// Timestamp of when the message was created.
    pub timestamp: Timestamp,
    /// Thread started from this message, includes [`Channel::member`].
    #[serde(skip_serializing_if = "Option::is_none")]
    pub thread: Option<Channel>,
    /// Whether the message was a TTS message.
    pub tts: bool,
    /// ID of the webhook that generated the message.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub webhook_id: Option<Id<WebhookMarker>>,
}

#[cfg(test)]
mod tests {
    use super::{
        reaction::ReactionCountDetails,
        reference_type::MessageReferenceType,
        sticker::{MessageSticker, StickerFormatType},
        EmojiReactionType, Message, MessageActivity, MessageActivityType, MessageApplication,
        MessageCall, MessageFlags, MessageReference, MessageType, Reaction,
    };
    use crate::{
        channel::{ChannelMention, ChannelType},
        guild::{MemberFlags, PartialMember},
        id::Id,
        test::image_hash,
        user::User,
        util::{datetime::TimestampParseError, Timestamp},
    };
    use serde_test::Token;
    use std::str::FromStr;

    #[allow(clippy::too_many_lines, deprecated)]
    #[test]
    fn message_deserialization() {
        let joined_at = Some(Timestamp::from_str("2020-01-01T00:00:00.000000+00:00").unwrap());
        let timestamp = Timestamp::from_micros(1_580_608_922_020_000).expect("non zero");
        let flags = MemberFlags::BYPASSES_VERIFICATION | MemberFlags::DID_REJOIN;

        let value = Message {
            activity: None,
            application: None,
            application_id: None,
            attachments: Vec::new(),
            author: User {
                accent_color: None,
                avatar: Some(image_hash::AVATAR),
                avatar_decoration: None,
                avatar_decoration_data: None,
                banner: None,
                bot: false,
                discriminator: 1,
                email: None,
                flags: None,
                global_name: Some("test".to_owned()),
                id: Id::new(3),
                locale: None,
                mfa_enabled: None,
                name: "test".to_owned(),
                premium_type: None,
                public_flags: None,
                system: None,
                verified: None,
            },
            call: Some(MessageCall {
                ended_timestamp: None,
                participants: Vec::new(),
            }),
            channel_id: Id::new(2),
            components: Vec::new(),
            content: "ping".to_owned(),
            edited_timestamp: None,
            embeds: Vec::new(),
            flags: Some(MessageFlags::empty()),
            guild_id: Some(Id::new(1)),
            id: Id::new(4),
            interaction: None,
            kind: MessageType::Regular,
            member: Some(PartialMember {
                avatar: None,
                communication_disabled_until: None,
                deaf: false,
                flags,
                joined_at,
                mute: false,
                nick: Some("member nick".to_owned()),
                permissions: None,
                premium_since: None,
                roles: Vec::new(),
                user: None,
            }),
            mention_channels: Vec::new(),
            mention_everyone: false,
            mention_roles: Vec::new(),
            mentions: Vec::new(),
            message_snapshots: Vec::new(),
            pinned: false,
            poll: None,
            reactions: Vec::new(),
            reference: None,
            role_subscription_data: None,
            sticker_items: vec![MessageSticker {
                format_type: StickerFormatType::Png,
                id: Id::new(1),
                name: "sticker name".to_owned(),
            }],
            referenced_message: None,
            timestamp,
            thread: None,
            tts: false,
            webhook_id: None,
            interaction_metadata: None,
        };

        serde_test::assert_tokens(
            &value,
            &[
                Token::Struct {
                    name: "Message",
                    len: 19,
                },
                Token::Str("attachments"),
                Token::Seq { len: Some(0) },
                Token::SeqEnd,
                Token::Str("author"),
                Token::Struct {
                    name: "User",
                    len: 10,
                },
                Token::Str("accent_color"),
                Token::None,
                Token::Str("avatar"),
                Token::Some,
                Token::Str(image_hash::AVATAR_INPUT),
                Token::Str("avatar_decoration"),
                Token::None,
                Token::Str("avatar_decoration_data"),
                Token::None,
                Token::Str("banner"),
                Token::None,
                Token::Str("bot"),
                Token::Bool(false),
                Token::Str("discriminator"),
                Token::Str("0001"),
                Token::Str("global_name"),
                Token::Some,
                Token::Str("test"),
                Token::Str("id"),
                Token::NewtypeStruct { name: "Id" },
                Token::Str("3"),
                Token::Str("username"),
                Token::Str("test"),
                Token::StructEnd,
                Token::Str("call"),
                Token::Some,
                Token::Struct {
                    name: "MessageCall",
                    len: 2,
                },
                Token::Str("ended_timestamp"),
                Token::None,
                Token::Str("participants"),
                Token::Seq { len: Some(0) },
                Token::SeqEnd,
                Token::StructEnd,
                Token::Str("channel_id"),
                Token::NewtypeStruct { name: "Id" },
                Token::Str("2"),
                Token::Str("content"),
                Token::Str("ping"),
                Token::Str("edited_timestamp"),
                Token::None,
                Token::Str("embeds"),
                Token::Seq { len: Some(0) },
                Token::SeqEnd,
                Token::Str("flags"),
                Token::Some,
                Token::U64(0),
                Token::Str("guild_id"),
                Token::Some,
                Token::NewtypeStruct { name: "Id" },
                Token::Str("1"),
                Token::Str("id"),
                Token::NewtypeStruct { name: "Id" },
                Token::Str("4"),
                Token::Str("type"),
                Token::U8(0),
                Token::Str("member"),
                Token::Some,
                Token::Struct {
                    name: "PartialMember",
                    len: 8,
                },
                Token::Str("communication_disabled_until"),
                Token::None,
                Token::Str("deaf"),
                Token::Bool(false),
                Token::Str("flags"),
                Token::U64(flags.bits()),
                Token::Str("joined_at"),
                Token::Some,
                Token::Str("2020-01-01T00:00:00.000000+00:00"),
                Token::Str("mute"),
                Token::Bool(false),
                Token::Str("nick"),
                Token::Some,
                Token::Str("member nick"),
                Token::Str("roles"),
                Token::Seq { len: Some(0) },
                Token::SeqEnd,
                Token::Str("user"),
                Token::None,
                Token::StructEnd,
                Token::Str("mention_everyone"),
                Token::Bool(false),
                Token::Str("mention_roles"),
                Token::Seq { len: Some(0) },
                Token::SeqEnd,
                Token::Str("mentions"),
                Token::Seq { len: Some(0) },
                Token::SeqEnd,
                Token::Str("pinned"),
                Token::Bool(false),
                Token::Str("sticker_items"),
                Token::Seq { len: Some(1) },
                Token::Struct {
                    name: "MessageSticker",
                    len: 3,
                },
                Token::Str("format_type"),
                Token::U8(1),
                Token::Str("id"),
                Token::NewtypeStruct { name: "Id" },
                Token::Str("1"),
                Token::Str("name"),
                Token::Str("sticker name"),
                Token::StructEnd,
                Token::SeqEnd,
                Token::Str("timestamp"),
                Token::Str("2020-02-02T02:02:02.020000+00:00"),
                Token::Str("tts"),
                Token::Bool(false),
                Token::StructEnd,
            ],
        );
    }

    #[allow(clippy::too_many_lines, deprecated)]
    #[test]
    fn message_deserialization_complete() -> Result<(), TimestampParseError> {
        let edited_timestamp = Timestamp::from_str("2021-08-10T12:41:51.602000+00:00")?;
        let joined_at = Some(Timestamp::from_str("2020-01-01T00:00:00.000000+00:00")?);
        let timestamp = Timestamp::from_micros(1_580_608_922_020_000).expect("non zero");
        let flags = MemberFlags::BYPASSES_VERIFICATION | MemberFlags::DID_REJOIN;

        let value = Message {
            activity: Some(MessageActivity {
                kind: MessageActivityType::Join,
                party_id: None,
            }),
            application: Some(MessageApplication {
                cover_image: Some(image_hash::COVER),
                description: "a description".to_owned(),
                icon: Some(image_hash::ICON),
                id: Id::new(1),
                name: "application".to_owned(),
            }),
            application_id: Some(Id::new(1)),
            attachments: Vec::new(),
            author: User {
                accent_color: None,
                avatar: Some(image_hash::AVATAR),
                avatar_decoration: None,
                avatar_decoration_data: None,
                banner: None,
                bot: false,
                discriminator: 1,
                email: None,
                flags: None,
                global_name: Some("test".to_owned()),
                id: Id::new(3),
                locale: None,
                mfa_enabled: None,
                name: "test".to_owned(),
                premium_type: None,
                public_flags: None,
                system: None,
                verified: None,
            },
            call: None,
            channel_id: Id::new(2),
            components: Vec::new(),
            content: "ping".to_owned(),
            edited_timestamp: Some(edited_timestamp),
            embeds: Vec::new(),
            flags: Some(MessageFlags::empty()),
            guild_id: Some(Id::new(1)),
            id: Id::new(4),
            interaction: None,
            kind: MessageType::Regular,
            member: Some(PartialMember {
                avatar: None,
                communication_disabled_until: None,
                deaf: false,
                flags,
                joined_at,
                mute: false,
                nick: Some("member nick".to_owned()),
                permissions: None,
                premium_since: None,
                roles: Vec::new(),
                user: None,
            }),
            mention_channels: vec![ChannelMention {
                guild_id: Id::new(1),
                id: Id::new(2),
                kind: ChannelType::GuildText,
                name: "channel".to_owned(),
            }],
            mention_everyone: false,
            mention_roles: Vec::new(),
            mentions: Vec::new(),
            message_snapshots: Vec::new(),
            pinned: false,
            poll: None,
            reactions: vec![Reaction {
                burst_colors: Vec::new(),
                count: 7,
                count_details: ReactionCountDetails {
                    burst: 0,
                    normal: 7,
                },
                emoji: EmojiReactionType::Unicode {
                    name: "a".to_owned(),
                },
                me: true,
                me_burst: false,
            }],
            reference: Some(MessageReference {
                channel_id: Some(Id::new(1)),
                guild_id: None,
                kind: MessageReferenceType::Default,
                message_id: None,
                fail_if_not_exists: None,
            }),
            role_subscription_data: None,
            sticker_items: vec![MessageSticker {
                format_type: StickerFormatType::Png,
                id: Id::new(1),
                name: "sticker name".to_owned(),
            }],
            referenced_message: None,
            timestamp,
            thread: None,
            tts: false,
            webhook_id: Some(Id::new(1)),
            interaction_metadata: None,
        };

        serde_test::assert_tokens(
            &value,
            &[
                Token::Struct {
                    name: "Message",
                    len: 26,
                },
                Token::Str("activity"),
                Token::Some,
                Token::Struct {
                    name: "MessageActivity",
                    len: 1,
                },
                Token::Str("type"),
                Token::U8(1),
                Token::StructEnd,
                Token::Str("application"),
                Token::Some,
                Token::Struct {
                    name: "MessageApplication",
                    len: 5,
                },
                Token::Str("cover_image"),
                Token::Some,
                Token::Str(image_hash::COVER_INPUT),
                Token::Str("description"),
                Token::Str("a description"),
                Token::Str("icon"),
                Token::Some,
                Token::Str(image_hash::ICON_INPUT),
                Token::Str("id"),
                Token::NewtypeStruct { name: "Id" },
                Token::Str("1"),
                Token::Str("name"),
                Token::Str("application"),
                Token::StructEnd,
                Token::Str("application_id"),
                Token::Some,
                Token::NewtypeStruct { name: "Id" },
                Token::Str("1"),
                Token::Str("attachments"),
                Token::Seq { len: Some(0) },
                Token::SeqEnd,
                Token::Str("author"),
                Token::Struct {
                    name: "User",
                    len: 10,
                },
                Token::Str("accent_color"),
                Token::None,
                Token::Str("avatar"),
                Token::Some,
                Token::Str(image_hash::AVATAR_INPUT),
                Token::Str("avatar_decoration"),
                Token::None,
                Token::Str("avatar_decoration_data"),
                Token::None,
                Token::Str("banner"),
                Token::None,
                Token::Str("bot"),
                Token::Bool(false),
                Token::Str("discriminator"),
                Token::Str("0001"),
                Token::Str("global_name"),
                Token::Some,
                Token::Str("test"),
                Token::Str("id"),
                Token::NewtypeStruct { name: "Id" },
                Token::Str("3"),
                Token::Str("username"),
                Token::Str("test"),
                Token::StructEnd,
                Token::Str("call"),
                Token::None,
                Token::Str("channel_id"),
                Token::NewtypeStruct { name: "Id" },
                Token::Str("2"),
                Token::Str("content"),
                Token::Str("ping"),
                Token::Str("edited_timestamp"),
                Token::Some,
                Token::Str("2021-08-10T12:41:51.602000+00:00"),
                Token::Str("embeds"),
                Token::Seq { len: Some(0) },
                Token::SeqEnd,
                Token::Str("flags"),
                Token::Some,
                Token::U64(0),
                Token::Str("guild_id"),
                Token::Some,
                Token::NewtypeStruct { name: "Id" },
                Token::Str("1"),
                Token::Str("id"),
                Token::NewtypeStruct { name: "Id" },
                Token::Str("4"),
                Token::Str("type"),
                Token::U8(0),
                Token::Str("member"),
                Token::Some,
                Token::Struct {
                    name: "PartialMember",
                    len: 8,
                },
                Token::Str("communication_disabled_until"),
                Token::None,
                Token::Str("deaf"),
                Token::Bool(false),
                Token::Str("flags"),
                Token::U64(flags.bits()),
                Token::Str("joined_at"),
                Token::Some,
                Token::Str("2020-01-01T00:00:00.000000+00:00"),
                Token::Str("mute"),
                Token::Bool(false),
                Token::Str("nick"),
                Token::Some,
                Token::Str("member nick"),
                Token::Str("roles"),
                Token::Seq { len: Some(0) },
                Token::SeqEnd,
                Token::Str("user"),
                Token::None,
                Token::StructEnd,
                Token::Str("mention_channels"),
                Token::Seq { len: Some(1) },
                Token::Struct {
                    name: "ChannelMention",
                    len: 4,
                },
                Token::Str("guild_id"),
                Token::NewtypeStruct { name: "Id" },
                Token::Str("1"),
                Token::Str("id"),
                Token::NewtypeStruct { name: "Id" },
                Token::Str("2"),
                Token::Str("type"),
                Token::U8(0),
                Token::Str("name"),
                Token::Str("channel"),
                Token::StructEnd,
                Token::SeqEnd,
                Token::Str("mention_everyone"),
                Token::Bool(false),
                Token::Str("mention_roles"),
                Token::Seq { len: Some(0) },
                Token::SeqEnd,
                Token::Str("mentions"),
                Token::Seq { len: Some(0) },
                Token::SeqEnd,
                Token::Str("pinned"),
                Token::Bool(false),
                Token::Str("reactions"),
                Token::Seq { len: Some(1) },
                Token::Struct {
                    name: "Reaction",
                    len: 6,
                },
                Token::Str("burst_colors"),
                Token::Seq { len: Some(0) },
                Token::SeqEnd,
                Token::Str("count"),
                Token::U64(7),
                Token::Str("count_details"),
                Token::Struct {
                    name: "ReactionCountDetails",
                    len: 2,
                },
                Token::Str("burst"),
                Token::U64(0),
                Token::Str("normal"),
                Token::U64(7),
                Token::StructEnd,
                Token::Str("emoji"),
                Token::Struct {
                    name: "EmojiReactionType",
                    len: 1,
                },
                Token::Str("name"),
                Token::Str("a"),
                Token::StructEnd,
                Token::Str("me"),
                Token::Bool(true),
                Token::Str("me_burst"),
                Token::Bool(false),
                Token::StructEnd,
                Token::SeqEnd,
                Token::Str("message_reference"),
                Token::Some,
                Token::Struct {
                    name: "MessageReference",
                    len: 2,
                },
                Token::Str("channel_id"),
                Token::Some,
                Token::NewtypeStruct { name: "Id" },
                Token::Str("1"),
                Token::Str("type"),
                Token::U8(0),
                Token::StructEnd,
                Token::Str("sticker_items"),
                Token::Seq { len: Some(1) },
                Token::Struct {
                    name: "MessageSticker",
                    len: 3,
                },
                Token::Str("format_type"),
                Token::U8(1),
                Token::Str("id"),
                Token::NewtypeStruct { name: "Id" },
                Token::Str("1"),
                Token::Str("name"),
                Token::Str("sticker name"),
                Token::StructEnd,
                Token::SeqEnd,
                Token::Str("timestamp"),
                Token::Str("2020-02-02T02:02:02.020000+00:00"),
                Token::Str("tts"),
                Token::Bool(false),
                Token::Str("webhook_id"),
                Token::Some,
                Token::NewtypeStruct { name: "Id" },
                Token::Str("1"),
                Token::StructEnd,
            ],
        );

        Ok(())
    }
}