war-pigeon 0.1.0

An ergonomic Rust client for War Pigeon, the runtime message delivery system.
Documentation
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
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
use crate::messages::discord::{DiscordChannelType, DiscordPartialEmoji, DiscordSnowflake};
use serde::{Deserialize, Serialize};

use super::meta::DiscordMentions;

/// An Action Row is a top-level layout component.
///
/// Action Rows can contain one of the following:
/// - Up to 5 contextually grouped buttons.
/// - A single select component (string select, user select, role select, mentionable select, or channel select).
///
/// NOTE: Label is recommended for use over an Action Row in modals. Action Row with Text Inputs in modals are now deprecated.
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
pub struct DiscordActionRowComponent {
    #[serde(skip_serializing_if = "Option::is_none")]
    pub id: Option<u32>,
    pub components: Vec<DiscordActionRowChild>,
}

#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
#[serde(untagged)]
pub enum DiscordActionRowChild {
    Button(DiscordButtonComponent),
    StringSelect(DiscordStringSelectComponent),
    UserSelect(DiscordSelectComponent),
    RoleSelect(DiscordSelectComponent),
    MentionableSelect(DiscordSelectComponent),
    ChannelSelect(DiscordChannelSelectComponent),
}

/// A Button is an interactive component that can only be used in messages.
///
/// It creates clickable elements that users can interact with,
/// sending an interaction to your app when clicked.
///
/// NOTE: Buttons must be placed inside an Action Row or a Section’s accessory field.
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
pub struct DiscordButtonComponent {
    #[serde(skip_serializing_if = "Option::is_none")]
    pub id: Option<u32>,

    #[serde(flatten)]
    pub kind: DiscordButtonKind,

    #[serde(skip_serializing_if = "Option::is_none")]
    pub disabled: Option<bool>,
}

#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
#[serde(tag = "style")]
pub enum DiscordButtonKind {
    #[serde(rename = "1")]
    Primary {
        label: Option<String>,
        emoji: Option<DiscordPartialEmoji>,
        custom_id: String,
    },

    #[serde(rename = "2")]
    Secondary {
        label: Option<String>,
        emoji: Option<DiscordPartialEmoji>,
        custom_id: String,
    },

    #[serde(rename = "3")]
    Success {
        label: Option<String>,
        emoji: Option<DiscordPartialEmoji>,
        custom_id: String,
    },

    #[serde(rename = "4")]
    Danger {
        label: Option<String>,
        emoji: Option<DiscordPartialEmoji>,
        custom_id: String,
    },

    #[serde(rename = "5")]
    Link {
        label: Option<String>,
        emoji: Option<DiscordPartialEmoji>,
        url: String,
    },

    #[serde(rename = "6")]
    Premium { sku_id: DiscordSnowflake },
}

/// A String Select is an interactive component that allows users to select one or more provided options.
///
/// String Selects can be configured for both single-select and multi-select behavior.
/// When a user finishes making their choice(s) your app receives an interaction.
///
/// NOTE: String Selects are available in messages and modals.
/// They must be placed inside an Action Row in messages and a Label in modals.
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
pub struct DiscordStringSelectComponent {
    /// Optional identifier for component.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub id: Option<u32>,

    /// ID for the select menu.
    ///
    /// NOTE: 1-100 characters.
    pub custom_id: String,

    /// Specified choices in a select menu.
    ///
    /// NOTE: max limit of 25.
    pub options: Vec<DiscordSelectOption>,

    /// Placeholder text if nothing is selected or default.
    ///
    /// NOTE: max limit of 150 characters.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub placeholder: Option<String>,

    /// Minimum number of items that must be chosen.
    ///
    /// NOTE: defaults to 1.
    ///
    /// NOTE: max limit of 25.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub min_values: Option<u8>,

    /// Maximum number of items that can be chosen.
    ///
    /// NOTE: defaults to 1.
    ///
    /// NOTE: max limit of 25.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub max_values: Option<u8>,

    /// Whether the string select is required to answer in a modal.
    ///
    /// NOTE: defaults to false.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub required: Option<bool>,

    /// Whether select menu is disabled in a message.
    ///
    /// NOTE: defaults to false.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub disabled: Option<bool>,
}

#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
/// Text Input is an interactive component that allows users to enter free-form text responses in modals.
///
/// It supports both short, single-line inputs and longer, multi-line paragraph inputs. Text Inputs can
/// only be used within modals and must be placed inside a Label.
///
/// NOTE: We no longer recommend using Text Input within an [`ActionRow`] in modals. Going forward all
/// text inputs should be placed a Label component.
pub struct DiscordTextInputComponent {
    /// Optional identifier for component.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub id: Option<u32>,

    /// ID for the select menu.
    ///
    /// NOTE: 1-100 characters.
    pub custom_id: String,

    /// The style for the text input.
    pub style: DiscordTextInputStyle,

    /// Minimum number of items that must be chosen.
    ///
    /// NOTE: defaults to 0.
    ///
    /// NOTE: max limit of 4000.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub min_values: Option<u16>,

    /// Maximum number of items that can be chosen.
    ///
    /// NOTE: defaults to 1.
    ///
    /// NOTE: max limit of 4000.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub max_values: Option<u16>,

    /// Whether this component is required to be filled.
    ///
    /// NOTE: defaults to [`true`].
    #[serde(skip_serializing_if = "Option::is_none")]
    pub required: Option<bool>,

    /// Pre-filled value for this component.
    ///
    /// NOTE: max limit of 4000 characters.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub value: Option<String>,

    /// Custom placeholder text if the input is empty.
    ///
    /// NOTE: max limit of 100 characters.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub placeholder: Option<String>,
}

#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
pub enum DiscordTextInputStyle {
    /// Single-line text input.
    #[serde(rename = "1")]
    Short,

    /// Multi-line text input.
    #[serde(rename = "2")]
    Paragraph,
}

/// An interactive component which allows users to select one or more options.
///
/// This selector can be used for User, Role, and Mentions selectors.
///
/// Options are automatically populated based on server settings like roles,
/// users, and mentions.
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
pub struct DiscordSelectComponent {
    /// Optional identifier for the component.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub id: Option<u32>,

    /// Developer-defined identifier for the select menu.
    ///
    /// NOTE: must be 1-100 characters.
    pub custom_id: String,

    /// Placeholder text if nothing is selected.
    ///
    ///  NOTE: max limit of 150 characters.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub placeholder: Option<String>,

    /// Default selected values.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub default_values: Option<Vec<DiscordSelectDefaultValue>>,

    /// Minimum number of items that must be chosen.
    ///
    /// NOTE: defaults to 1.
    ///
    /// NOTE: minimum of 0, maximum of 25.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub min_values: Option<u8>,

    /// Maximum number of items that can be chosen.
    ///
    /// NOTE: defaults to 1.
    ///
    /// NOTE: minimum of 0, maximum of 25.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub max_values: Option<u8>,

    /// Whether the select is required in a modal.
    ///
    /// NOTE: defaults to true.
    ///
    /// NOTE: ignored in messages.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub required: Option<bool>,

    /// Whether the select menu is disabled in a message.
    ///
    /// Defaults to false. Invalid in modals.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub disabled: Option<bool>,
}

/// A Channel Select is an interactive component that allows users
/// to select one or more channels in a message or modal.
///
/// Options are automatically populated based on available channels
/// in the server and can be filtered by channel types.
///
/// Channel Selects can be configured for both single-select and
/// multi-select behavior. When a user finishes making their choice(s)
/// your app receives an interaction.
///
/// Channel Selects are available in messages and modals. They must be
/// placed inside an Action Row in messages and a Label in modals.
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
pub struct DiscordChannelSelectComponent {
    /// Optional identifier for the component.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub id: Option<u32>,

    /// Developer-defined identifier for the select menu.
    ///
    /// NOTE: must be 1-100 characters.
    pub custom_id: String,

    /// List of channel types to include in the channel select component.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub channel_types: Option<Vec<DiscordChannelType>>,

    /// Placeholder text if nothing is selected.
    ///
    ///  NOTE: max limit of 150 characters.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub placeholder: Option<String>,

    /// Default selected values.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub default_values: Option<Vec<DiscordSelectDefaultValue>>,

    /// Minimum number of items that must be chosen.
    ///
    /// NOTE: defaults to 1.
    ///
    /// NOTE: minimum of 0, maximum of 25.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub min_values: Option<u8>,

    /// Maximum number of items that can be chosen.
    ///
    /// NOTE: defaults to 1.
    ///
    /// NOTE: minimum of 0, maximum of 25.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub max_values: Option<u8>,

    /// Whether the select is required in a modal.
    ///
    /// NOTE: defaults to true.
    ///
    /// NOTE: ignored in messages.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub required: Option<bool>,

    /// Whether the select menu is disabled in a message.
    ///
    /// Defaults to false. Invalid in modals.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub disabled: Option<bool>,
}

#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
pub struct DiscordSelectDefaultValue {
    /// ID of a user, role, or channel.
    pub id: DiscordSnowflake,

    /// Type of value the ID represents.
    pub r#type: DiscordMentions,
}

#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
pub struct DiscordSelectOption {
    pub label: String,
    pub value: String,
    pub description: Option<String>,
    pub emoji: Option<DiscordPartialEmoji>,
    pub default: Option<bool>,
}

/// A Section is a top-level layout component that allows you to
/// contextually associate content with an accessory component.
///
/// The typical use-case is to contextually associate text content with an accessory.
///
/// NOTE: Sections are currently only available in messages.
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
pub struct DiscordSectionComponent {
    /// Optional identifier for the component.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub id: Option<u32>,

    /// One to three child components representing the
    /// content of the section that is contextually
    /// associated to the accessory.
    pub components: Vec<DiscordTextDisplayComponent>,

    /// A component that is contextually associated to the content of the section.
    pub accessory: Vec<DiscordSectionAccessory>,
}

/// A Text Display is a content component that allows you to add markdown
/// formatted text, including mentions (users, roles, etc) and emojis.
///
/// The behavior of this component is extremely similar to the content
/// field of a message, but allows you to add multiple text components,
/// controlling the layout of your message.
///
/// When sent in a message, pingable mentions (@user, @role, etc) present
/// in this component will ping and send notifications based on the value
/// of the allowed mention object set in message.allowed_mentions.
///
/// NOTE: To use this component in messages you must send the message flag
/// `1 << 15` (IS_COMPONENTS_V2) which can be activated on a per-message basis.
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
pub struct DiscordTextDisplayComponent {
    /// Optional identifier for the component.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub id: Option<u32>,

    /// Text that will be displayed similar to a message.
    pub content: String,
}

#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
pub enum DiscordSectionAccessory {
    Button(DiscordButtonComponent),
    Thumbnail(DiscordThumbnailComponent),
}

/// A Thumbnail is a content component that displays visual media in a small form-factor.
///
/// It is intended as an accessory for to other content, and is primarily usable with sections.
/// The media displayed is defined by the unfurled media item structure, which supports both
/// uploaded media and externally hosted media.
///
/// Thumbnails are currently only available in messages as an accessory in a section.
///
/// NOTE: Thumbnails currently only support images, including animated formats like GIF and WEBP.
/// NOTE: Videos are not supported at this time.
///
/// NOTE: To use this component, you need to send the message flag `1 << 15` (IS_COMPONENTS_V2),
/// which can be activated on a per-message basis.
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
pub struct DiscordThumbnailComponent {
    /// Optional identifier for the component.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub id: Option<u32>,

    /// A url or attachment provided as an unfurled media item.
    pub media: DiscordUnfurledMediaItem,

    /// Alt text for the media.
    ///
    /// NOTE: max limit of 1024 characters.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub description: Option<String>,

    /// Whether the thumbnail should be a spoiler (or blurred out).
    ///
    /// NOTE: defaults to [`false`].
    pub spoiler: Option<bool>,
}

/// A piece of media used within a Discord component.
///
/// An unfurled media item can reference either:
/// - external media via a direct URL
/// - uploaded media via an `attachment://<filename>` reference
///
/// When sending requests to Discord, only [`Self::url`] is developer-settable.
/// All other fields are populated by Discord in responses.
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
pub struct DiscordUnfurledMediaItem {
    /// The media location.
    ///
    /// Supports arbitrary URLs and `attachment://<filename>` references.
    pub url: String,

    /// The proxied URL of the media item.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub proxy_url: Option<String>,

    /// The height of the media item, if it is an image or video.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub height: Option<i64>,

    /// The width of the media item, if it is an image or video.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub width: Option<i64>,

    /// A ThumbHash placeholder for the media item, if it is an image or video.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub placeholder: Option<String>,

    /// The version of the placeholder, if present.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub placeholder_version: Option<i64>,

    /// The media type of the content.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub content_type: Option<String>,

    /// Unfurled media item flags combined as a bitfield.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub flags: Option<i64>,

    /// The ID of the uploaded attachment backing this media item.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub attachment_id: Option<String>,
}

/// A media gallery component for Discord messages.
///
/// This component allows displaying between 1 and 10 media items in a gallery format,
/// where each item can optionally include a description and spoiler flag.
///
/// ## Notes
/// - `type` is always `12` for media gallery components.
/// - Requires message flag `1 << 15` (`IS_COMPONENTS_V2`) to be set.
/// - Each gallery must contain **1 to 10 items**.
/// - Each item references media via [`DiscordUnfurledMediaItem`].
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
pub struct DiscordMediaGalleryComponent {
    /// The component type.
    ///
    /// Always `12` for a media gallery component.
    #[serde(rename = "type")]
    pub kind: u8,

    /// Optional identifier for the component.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub id: Option<u32>,

    /// The media items displayed in the gallery.
    ///
    /// NOTE: Must contain between **1 and 10 items**.
    pub items: Vec<DiscordMediaGalleryItem>,
}

/// A single item within a media gallery.
///
/// Each item represents one media entry, optionally including
/// a description and spoiler flag.
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
pub struct DiscordMediaGalleryItem {
    /// The media content for this item.
    ///
    /// Can reference either:
    /// - an external URL
    /// - an uploaded attachment via `attachment://<filename>`
    pub media: DiscordUnfurledMediaItem,

    /// Optional alt text describing the media.
    ///
    /// Maximum length: 1024 characters.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub description: Option<String>,

    /// Whether the media should be marked as a spoiler (blurred).
    ///
    /// Defaults to `false` if not provided.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub spoiler: Option<bool>,
}

/// A Separator is a top-level layout component that adds vertical
/// padding and visual division between other components.
///
/// ## Notes
/// - Separators are currently only available in messages.
///
/// - To use this component in messages you must send the
///   message flag 1 << 15 (IS_COMPONENTS_V2) which can be
///   activated on a per-message basis.
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
pub struct DiscordSeparatorComponent {
    /// Optional identifier for the component.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub id: Option<u32>,

    /// Whether a visual divider should be displayed in the component.
    ///
    /// NOTE: defaults to `true`.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub divider: Option<bool>,

    /// Size of separator padding.
    ///
    /// NOTE: defaults to 1 ([`DiscordSeparatorPadding::Small`]).
    #[serde(skip_serializing_if = "Option::is_none")]
    pub spacing: Option<DiscordSeparatorPadding>,
}

#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
pub enum DiscordSeparatorPadding {
    #[serde(rename = "1")]
    Small,

    #[serde(rename = "2")]
    Large,
}

/// A file component for Discord messages.
///
/// This component allows displaying an uploaded file as an attachment and
/// referencing it via an unfurled media item.
///
/// ## Notes
/// - `type` is always `13` for file components.
/// - The [`Self::file`] field must use the `attachment://<filename>` syntax.
/// - To use this component, the message must include the flag:
///   `1 << 15` (`IS_COMPONENTS_V2`).
/// - Some fields are response-only and ignored when sending requests.
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
pub struct DiscordFileComponent {
    /// The component type.
    ///
    /// Always `13` for a file component.
    #[serde(rename = "type")]
    pub kind: u8,

    /// Optional identifier for the component.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub id: Option<u32>,

    /// The unfurled media item representing the file.
    ///
    /// This must use the `attachment://<filename>` format and cannot reference
    /// arbitrary external URLs.
    pub file: DiscordUnfurledMediaItem,

    /// Whether the file should be marked as a spoiler (blurred).
    ///
    /// Defaults to `false`.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub spoiler: Option<bool>,

    /// The name of the file.
    ///
    /// This field is ignored when sending requests and is populated by Discord
    /// in responses.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub name: Option<String>,

    /// The size of the file in bytes.
    ///
    /// This field is ignored when sending requests and is populated by Discord
    /// in responses.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub size: Option<u64>,
}

/// A Container is a top-level layout component.
///
/// Containers offer the ability to visually encapsulate a collection of
/// components and have an optional customizable accent color bar.
///
/// NOTE: Containers are currently only available in messages.
///
/// NOTE: To use this component in messages you must send the message flag
/// `1 << 15` (IS_COMPONENTS_V2) which can be activated on a per-message basis.
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
pub struct DiscordContainerComponent {
    /// Optional identifier for the component.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub id: Option<u32>,

    /// Child components that are encapsulated within the Container.
    pub components: Vec<DiscordContainerComponentChild>,

    /// Color for the accent on the container as RGB from 0x000000 to 0xFFFFFF.
    pub accent_color: Option<u64>,

    /// Whether the container should be a spoiler (or blurred out).
    ///
    /// NOTE: defaults to `false`.
    pub spoiler: Option<bool>,
}

#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
pub enum DiscordContainerComponentChild {
    ActionRow(DiscordActionRowComponent),
    TextDisplay(DiscordTextDisplayComponent),
    Section(DiscordSectionComponent),
    MediaGallery(DiscordMediaGalleryComponent),
    Separator(DiscordSeparatorComponent),
    File(DiscordFileComponent),
}

/// A label component for Discord modals.
///
/// Labels wrap another modal component with label text and an optional
/// description.
///
/// The description may render above or below the child component depending
/// on the platform.
///
/// NOTE: `type` is always `18` for a label component.
/// NOTE: `label` has a maximum length of 45 characters.
/// NOTE: `description` has a maximum length of 100 characters.
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
pub struct DiscordLabelComponent {
    /// Optional identifier for the component.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub id: Option<u32>,

    /// The label text displayed for the wrapped component.
    ///
    /// NOTE: max limit of 45 characters.
    pub label: String,

    /// Optional description text for the label.
    ///
    /// NOTE: max limit of 100 characters.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub description: Option<String>,

    /// The child component wrapped by this label.
    pub component: DiscordLabelChildComponent,
}

/// Components that may be wrapped by a [`DiscordLabelComponent`].
///
/// NOTE: These are modal-oriented child components supported by Discord labels.
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
#[serde(tag = "type")]
pub enum DiscordLabelChildComponent {
    /// A text input component.
    #[serde(rename = "4")]
    TextInput(DiscordTextInputComponent),

    /// A string select component.
    #[serde(rename = "3")]
    StringSelect(DiscordStringSelectComponent),

    /// A user select component.
    #[serde(rename = "5")]
    UserSelect(DiscordSelectComponent),

    /// A role select component.
    #[serde(rename = "6")]
    RoleSelect(DiscordSelectComponent),

    /// A mentionable select component.
    #[serde(rename = "7")]
    MentionableSelect(DiscordSelectComponent),

    /// A channel select component.
    #[serde(rename = "8")]
    ChannelSelect(DiscordChannelSelectComponent),

    /// A file upload component.
    #[serde(rename = "19")]
    FileUpload(DiscordFileUploadComponent),

    /// A radio group component.
    #[serde(rename = "21")]
    RadioGroup(DiscordRadioGroupComponent),

    /// A checkbox group component.
    #[serde(rename = "22")]
    CheckboxGroup(DiscordCheckboxGroupComponent),

    /// A checkbox component.
    #[serde(rename = "23")]
    Checkbox(DiscordCheckboxComponent),
}

/// A radio group component for Discord modals.
///
/// This component allows users to select **exactly one** option from a list.
///
/// ## Notes
/// - `type` is always `21` for radio group components.
/// - Must be placed inside a [`DiscordLabelComponent`].
/// - Must contain between **2 and 10 options**.
/// - `custom_id` must be between 1 and 100 characters.
/// - `required` defaults to `true`.
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
pub struct DiscordRadioGroupComponent {
    /// Optional identifier for the component.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub id: Option<u32>,

    /// Developer-defined identifier for the radio group.
    ///
    /// NOTE: Must be between 1 and 100 characters.
    pub custom_id: String,

    /// The selectable options in the radio group.
    ///
    /// NOTE: Must contain between **2 and 10 options**.
    pub options: Vec<DiscordRadioGroupOption>,

    /// Whether a selection is required before submitting the modal.
    ///
    /// NOTE: Defaults to `true`.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub required: Option<bool>,
}

/// A single selectable option within a [`DiscordRadioGroup`].
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
pub struct DiscordRadioGroupOption {
    /// Developer-defined value for this option.
    ///
    /// NOTE: Maximum length of 100 characters.
    pub value: String,

    /// User-facing label for this option.
    ///
    /// NOTE: Maximum length of 100 characters.
    pub label: String,

    /// Optional description for this option.
    ///
    /// NOTE: Maximum length of 100 characters.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub description: Option<String>,

    /// Whether this option should be selected by default.
    ///
    /// NOTE: Defaults to `false`.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub default: Option<bool>,
}

/// A file upload component for Discord modals.
///
/// This component allows users to upload files as part of a modal submission.
///
/// ## Notes
/// - `type` is always `19` for file upload components.
/// - Must be placed inside a [`DiscordLabelComponent`].
/// - Users can upload between **0 and 10 files**.
/// - The maximum file size is determined by the channel's upload limits.
/// - `custom_id` must be between 1 and 100 characters.
/// - `min_values` defaults to `1` (can be set to `0`).
/// - `max_values` defaults to `1`.
/// - `required` defaults to `true`.
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
pub struct DiscordFileUploadComponent {
    /// Optional identifier for the component.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub id: Option<u32>,

    /// Developer-defined identifier for the file upload component.
    ///
    /// NOTE: Must be between 1 and 100 characters.
    pub custom_id: String,

    /// Minimum number of files that must be uploaded.
    ///
    /// NOTE: Defaults to `1`.
    ///
    /// NOTE: Minimum allowed value is `0`, maximum is `10`.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub min_values: Option<u8>,

    /// Maximum number of files that can be uploaded.
    ///
    /// NOTE: Defaults to `1`.
    ///
    /// NOTE: Maximum allowed value is `10`.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub max_values: Option<u8>,

    /// Whether this component is required to be filled before submitting the modal.
    ///
    /// NOTE: Defaults to `true`.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub required: Option<bool>,
}

/// A checkbox group component for Discord modals.
///
/// This component allows users to select **one or more options** via checkboxes.
///
/// ## Notes
/// - `type` is always `22` for checkbox group components.
/// - Must be placed inside a [`DiscordLabelComponent`].
/// - Must contain between **1 and 10 options**.
/// - `custom_id` must be between 1 and 100 characters.
/// - `min_values` defaults to `1`.
/// - `max_values` defaults to the number of options.
/// - `required` defaults to `true`.
///
/// ## Constraints
/// - `min_values` must be:
///   - omitted, or
///   - at least `1` if `required` is `true` or omitted.
/// - `min_values` range: `0..=10`
/// - `max_values` range: `1..=10`
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
pub struct DiscordCheckboxGroupComponent {
    /// Optional identifier for the component.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub id: Option<u32>,

    /// Developer-defined identifier for the checkbox group.
    ///
    /// NOTE: Must be between 1 and 100 characters.
    pub custom_id: String,

    /// The selectable options in the checkbox group.
    ///
    /// NOTE: Must contain between **1 and 10 options**.
    pub options: Vec<DiscordCheckboxGroupOption>,

    /// Minimum number of options that must be selected.
    ///
    /// NOTE: Defaults to `1`.
    ///
    /// NOTE: Minimum allowed value is `0`, maximum is `10`.
    ///
    /// NOTE: Must be `>= 1` if `required` is `true` or not provided.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub min_values: Option<u8>,

    /// Maximum number of options that can be selected.
    ///
    /// NOTE: Defaults to the number of options.
    ///
    /// NOTE: Minimum allowed value is `1`, maximum is `10`.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub max_values: Option<u8>,

    /// Whether selecting at least one option is required.
    ///
    /// NOTE: Defaults to `true`.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub required: Option<bool>,
}

/// A single selectable option within a [`DiscordCheckboxGroup`].
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
pub struct DiscordCheckboxGroupOption {
    /// Developer-defined value for this option.
    ///
    /// NOTE: Maximum length of 100 characters.
    pub value: String,

    /// User-facing label for this option.
    ///
    /// NOTE: Maximum length of 100 characters.
    pub label: String,

    /// Optional description for this option.
    ///
    /// NOTE: Maximum length of 100 characters.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub description: Option<String>,

    /// Whether this option should be selected by default.
    ///
    /// NOTE: Defaults to `false`.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub default: Option<bool>,
}

/// A checkbox component for Discord modals.
///
/// This component represents a single **boolean-style input** (yes/no).
///
/// ## Notes
/// - `type` is always `23` for checkbox components.
/// - Must be placed inside a [`DiscordLabelComponent`].
/// - `custom_id` must be between 1 and 100 characters.
/// - Cannot be marked as required directly.
///
/// ## Tip
/// If you need a required checkbox, use a [`DiscordCheckboxGroup`]
/// with a single option and `required = true`.
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
pub struct DiscordCheckboxComponent {
    /// Optional identifier for the component.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub id: Option<u32>,

    /// Developer-defined identifier for the checkbox.
    ///
    /// NOTE: Must be between 1 and 100 characters.
    pub custom_id: String,

    /// Whether the checkbox is selected by default.
    ///
    /// NOTE: Defaults to `false`.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub default: Option<bool>,
}

/// The different types of discord message components.
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(tag = "type")]
pub enum DiscordComponent {
    /// An Action Row is a top-level layout component.
    ///
    /// Action Rows can contain one of the following:
    /// - Up to 5 contextually grouped buttons.
    /// - A single select component (string select, user select, role select, mentionable select, or channel select).
    #[serde(rename = "1")]
    ActionRow(DiscordActionRowComponent),

    /// A Button is an interactive component that can only be used in messages.
    ///
    /// It creates clickable elements that users can interact with,
    /// sending an interaction to your app when clicked.
    #[serde(rename = "2")]
    Button(DiscordButtonComponent),

    /// A String Select is an interactive component that allows users to select one or more provided options.
    ///
    /// String Selects can be configured for both single-select and multi-select behavior.
    /// When a user finishes making their choice(s) your app receives an interaction.
    #[serde(rename = "3")]
    StringSelect(DiscordStringSelectComponent),

    /// Text Input is an interactive component that allows users to enter free-form text responses in modals.
    ///
    /// It supports both short, single-line inputs and longer, multi-line paragraph inputs. Text Inputs can
    /// only be used within modals and must be placed inside a Label.
    #[serde(rename = "4")]
    TextInput(DiscordTextInputComponent),

    /// A User Select is an interactive component that allows users to select
    /// one or more users in a message or modal.
    ///
    /// Options are automatically populated based on the server’s available users.
    #[serde(rename = "5")]
    UserSelect(DiscordSelectComponent),

    /// A Role Select is an interactive component that allows users to select
    /// one or more roles in a message or modal.
    ///
    /// Options are automatically populated based on the server’s available roles.
    #[serde(rename = "6")]
    RoleSelect(DiscordSelectComponent),

    /// A Mentionable Select is an interactive component that allows users to select
    /// one or more mentionables in a message or modal.
    ///
    /// Options are automatically populated based on available mentionables in the server.
    #[serde(rename = "7")]
    MentionableSelect(DiscordSelectComponent),

    /// A Channel Select is an interactive component that allows users
    /// to select one or more channels in a message or modal.
    ///
    /// Options are automatically populated based on available channels
    /// in the server and can be filtered by channel types.
    #[serde(rename = "8")]
    ChannelSelect(DiscordChannelSelectComponent),

    /// A Section is a top-level layout component that allows you to
    /// contextually associate content with an accessory component.
    ///
    /// The typical use-case is to contextually associate text content with an accessory.
    #[serde(rename = "9")]
    Section(DiscordSectionComponent),

    /// A Text Display is a content component that allows you to add markdown
    /// formatted text, including mentions (users, roles, etc) and emojis.
    ///
    /// The behavior of this component is extremely similar to the content
    /// field of a message, but allows you to add multiple text components,
    /// controlling the layout of your message.
    #[serde(rename = "10")]
    TextDisplay(DiscordTextDisplayComponent),

    /// A Thumbnail is a content component that displays visual media in a small form-factor.
    ///
    /// It is intended as an accessory for to other content, and is primarily usable with sections.
    /// The media displayed is defined by the unfurled media item structure, which supports both
    /// uploaded media and externally hosted media.
    #[serde(rename = "11")]
    Thumbnail(DiscordThumbnailComponent),

    /// A media gallery component for Discord messages.
    ///
    /// This component allows displaying between 1 and 10 media items in a gallery format,
    /// where each item can optionally include a description and spoiler flag.
    #[serde(rename = "12")]
    MediaGallery(DiscordMediaGalleryComponent),

    /// A file component for Discord messages.
    ///
    /// This component allows displaying an uploaded file as an attachment and
    /// referencing it via an unfurled media item.
    #[serde(rename = "13")]
    File(DiscordFileComponent),

    /// A Separator is a top-level layout component that adds vertical
    /// padding and visual division between other components.
    #[serde(rename = "14")]
    Separator(DiscordSeparatorComponent),

    /// A Container is a top-level layout component.
    ///
    /// Containers offer the ability to visually encapsulate a collection of
    /// components and have an optional customizable accent color bar.
    #[serde(rename = "17")]
    Container(DiscordContainerComponent),

    /// A label component for Discord modals.
    ///
    /// Labels wrap another modal component with label text and an optional
    /// description.
    #[serde(rename = "18")]
    Label(DiscordLabelComponent),

    /// A file upload component for Discord modals.
    ///
    /// This component allows users to upload files as part of a modal submission.
    #[serde(rename = "19")]
    FileUpload(DiscordFileUploadComponent),

    /// A radio group component for Discord modals.
    ///
    /// This component allows users to select **exactly one** option from a list.
    #[serde(rename = "21")]
    RadioGroup(DiscordRadioGroupComponent),

    /// A checkbox group component for Discord modals.
    ///
    /// This component allows users to select **one or more options** via checkboxes.
    #[serde(rename = "22")]
    CheckboxGroup(DiscordCheckboxGroupComponent),

    /// A checkbox component for Discord modals.
    ///
    /// This component represents a single **boolean-style input** (yes/no).
    #[serde(rename = "23")]
    Checkbox(DiscordCheckboxComponent),
}