discord-ferris 0.0.2

discord-ferris is a Discord API Rust library under development 🦀
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
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
use crate::models::payloads::application::APIApplication;
use crate::models::payloads::base::{
    APIInteractionDataResolved, APIMessageInteraction, APIMessageInteractionMetadata,
};
use crate::models::payloads::emoji::APIPartialEmoji;
use crate::models::payloads::guild::APIGuildMember;
use crate::models::payloads::permissions::APIRole;
use crate::models::payloads::poll::APIPoll;
use crate::models::payloads::sticker::{APISticker, APIStickerItem};
use crate::models::payloads::user::APIUser;
use crate::utils::serde::flags_numeric;
use bitflags::bitflags;
use serde::{Deserialize, Serialize};
use serde_repr::{Deserialize_repr, Serialize_repr};

/**
 * Types extracted from https://discord.com/developers/docs/resources/channel
 */

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct APIBasePartialChannel {
    /**
     * The id of the channel
     */
    pub id: String,
    /**
     * The type of the channel
     *
     * @see {@link https://discord.com/developers/docs/resources/channel#channel-object-channel-types}
     */
    #[serde(rename = "type")]
    pub r#type: ChannelType,
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct APINameableChannel {
    /**
     * The name of the channel (1-100 characters)
     */
    pub name: Option<String>,
}

/**
 * Not documented, but partial only includes id, name, and type
 */
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct APIPartialChannel {
    pub id: String,
    #[serde(rename = "type")]
    pub r#type: ChannelType,
    pub name: Option<String>,
}

/**
 * A channel obtained from fetching an invite.
 */
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct APIInviteChannel {
    /**
     * Icon hash.
     */
    pub icon: Option<String>,
    /**
     * The invite channel's recipients.
     *
     * @remarks Only includes usernames of users.
     */
    pub recipients: Option<Vec<APIInviteChannelRecipient>>,
    pub id: String,
    #[serde(rename = "type")]
    pub r#type: ChannelType,
    pub name: String,
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct APIInviteChannelRecipient {
    pub username: String,
}

/**
 * Source channel of channel follower webhooks.
 */
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct APIWebhookSourceChannel {
    pub id: String,
    pub name: String,
}

/**
 * This interface is used to allow easy extension for other channel types. While
 * also allowing `APIPartialChannel` to be used without breaking.
 */
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct APIChannelBase {
    pub id: String,
    #[serde(rename = "type")]
    pub r#type: ChannelType,
    #[serde(with = "flags_numeric")]
    pub flags: ChannelFlags,
}

pub type TextChannelType = ChannelType;

pub type GuildChannelType = ChannelType;

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct APISlowmodeChannel {
    /**
     * Amount of seconds a user has to wait before sending another message (0-21600);
     * bots, as well as users with the permission `MANAGE_MESSAGES` or `MANAGE_CHANNELS`, are unaffected
     *
     * `rate_limit_per_user` also applies to thread creation. Users can send one message and create one thread during each `rate_limit_per_user` interval.
     *
     * For thread channels, `rate_limit_per_user` is only returned if the field is set to a non-zero and non-null value.
     * The absence of this field in API calls and Gateway events should indicate that slowmode has been reset to the default value.
     */
    pub rate_limit_per_user: Option<i64>,
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct APISortableChannel {
    /**
     * Sorting position of the channel
     */
    pub position: i64,
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct APITextBasedChannel {
    /**
     * The id of the last message sent in this channel (may not point to an existing or valid message)
     */
    pub last_message_id: Option<String>,
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct APIPinChannel {
    /**
     * When the last pinned message was pinned.
     * This may be `null` in events such as `GUILD_CREATE` when a message is not pinned
     */
    pub last_pin_timestamp: Option<String>,
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct APIGuildChannel {
    /**
     * The name of the channel (1-100 characters)
     */
    pub name: String,
    /**
     * The id of the guild (may be missing for some channel objects received over gateway guild dispatches)
     */
    pub guild_id: Option<String>,
    /**
     * Explicit permission overwrites for members and roles
     *
     * @see {@link https://discord.com/developers/docs/resources/channel#overwrite-object}
     */
    pub permission_overwrites: Option<Vec<APIOverwrite>>,
    /**
     * ID of the parent category for a channel (each parent category can contain up to 50 channels)
     *
     * OR
     *
     * ID of the parent channel for a thread
     */
    pub parent_id: Option<String>,
    /**
     * Whether the channel is nsfw
     */
    pub nsfw: Option<bool>,
}

pub type GuildTextChannelType = ChannelType;

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct APIGuildTextChannel {
    /**
     * Default duration for newly created threads, in minutes, to automatically archive the thread after recent activity
     */
    pub default_auto_archive_duration: Option<ThreadAutoArchiveDuration>,
    /**
     * The initial `rate_limit_per_user` to set on newly created threads.
     * This field is copied to the thread at creation time and does not live update
     */
    pub default_thread_rate_limit_per_user: Option<i64>,
    /**
     * The channel topic (0-1024 characters)
     */
    pub topic: Option<String>,
}

pub type APITextChannel = APIGuildTextChannel;
pub type APINewsChannel = APIGuildTextChannel;
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct APIGuildCategoryChannel {}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct APIVoiceChannelBase {
    /**
     * The bitrate (in bits) of the voice or stage channel
     */
    pub bitrate: Option<i64>,
    /**
     * The user limit of the voice or stage channel
     */
    pub user_limit: Option<i64>,
    /**
     * Voice region id for the voice or stage channel, automatic when set to `null`
     *
     * @see {@link https://discord.com/developers/docs/resources/voice#voice-region-object}
     */
    pub rtc_region: Option<String>,
    /**
     * The camera video quality mode of the voice or stage channel, `1` when not present
     *
     * @see {@link https://discord.com/developers/docs/resources/channel#channel-object-video-quality-modes}
     */
    pub video_quality_mode: Option<VideoQualityMode>,
}

pub type APIGuildVoiceChannel = APIVoiceChannelBase;

pub type APIGuildStageVoiceChannel = APIVoiceChannelBase;

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct APIDMChannelBase {
    /**
     * The recipients of the DM
     *
     * @see {@link https://discord.com/developers/docs/resources/user#user-object}
     */
    pub recipients: Option<Vec<APIUser>>,
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct APIDMChannel {
    /**
     * The name of the channel (always null for DM channels)
     */
    pub name: Option<String>,
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct APIGroupDMChannel {
    /**
     * The name of the channel (1-100 characters)
     */
    pub name: Option<String>,
    /**
     * Application id of the group DM creator if it is bot-created
     */
    pub application_id: Option<String>,
    /**
     * Icon hash
     */
    pub icon: Option<String>,
    /**
     * ID of the DM creator
     */
    pub owner_id: Option<String>,
    /**
     * The id of the last message sent in this channel (may not point to an existing or valid message)
     */
    pub last_message_id: Option<String>,
    /**
     * Whether the channel is managed by an OAuth2 application
     */
    pub managed: Option<bool>,
}

pub type ThreadChannelType = ChannelType;

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct APIThreadChannel {
    /**
     * The client users member for the thread, only included in select endpoints
     */
    pub member: Option<APIThreadMember>,
    /**
     * The metadata for a thread channel not shared by other channels
     */
    pub thread_metadata: Option<APIThreadMetadata>,
    /**
     * Number of messages (not including the initial message or deleted messages) in a thread
     *
     * If the thread was created before July 1, 2022, it stops counting at 50 messages
     */
    pub message_count: Option<i64>,
    /**
     * The approximate member count of the thread, does not count above 50 even if there are more members
     */
    pub member_count: Option<i64>,
    /**
     * ID of the thread creator
     */
    pub owner_id: Option<String>,
    /**
     * Number of messages ever sent in a thread
     *
     * Similar to `message_count` on message creation, but won't decrement when a message is deleted
     */
    pub total_message_sent: Option<i64>,
    /**
     * The IDs of the set of tags that have been applied to a thread in a thread-only channel
     */
    pub applied_tags: Vec<String>,
}

pub type APIPublicThreadChannel = APIThreadChannel;
pub type APIPrivateThreadChannel = APIThreadChannel;
pub type APIAnnouncementThreadChannel = APIThreadChannel;

/**
 * @see {@link https://discord.com/developers/docs/resources/channel#forum-tag-object-forum-tag-structure}
 */
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct APIGuildForumTag {
    /**
     * The id of the tag
     */
    pub id: String,
    /**
     * The name of the tag (0-20 characters)
     */
    pub name: String,
    /**
     * Whether this tag can only be added to or removed from threads by a member with the `MANAGE_THREADS` permission
     */
    pub moderated: bool,
    /**
     * The id of a guild's custom emoji
     */
    pub emoji_id: Option<String>,
    /**
     * The unicode character of the emoji
     */
    pub emoji_name: Option<String>,
}

/**
 * @see {@link https://discord.com/developers/docs/resources/channel#default-reaction-object-default-reaction-structure}
 */
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct APIGuildForumDefaultReactionEmoji {
    /**
     * The id of a guild's custom emoji
     */
    pub emoji_id: Option<String>,
    /**
     * The unicode character of the emoji
     */
    pub emoji_name: Option<String>,
}

/**
 * @see {@link https://discord.com/developers/docs/resources/channel/#channel-object-sort-order-types}
 */
#[derive(Debug, Copy, Clone, Eq, PartialEq, Serialize_repr, Deserialize_repr)]
#[repr(u8)]
pub enum SortOrderType {
    /**
     * Sort forum posts by activity
     */
    LatestActivity = 0,
    /**
     * Sort forum posts by creation time (from most recent to oldest)
     */
    CreationDate = 1,
}

/**
 * @see {@link https://discord.com/developers/docs/resources/channel/#channel-object-forum-layout-types}
 */
#[derive(Debug, Copy, Clone, Eq, PartialEq, Serialize_repr, Deserialize_repr)]
#[repr(u8)]
pub enum ForumLayoutType {
    /**
     * No default has been set for forum channel
     */
    NotSet = 0,
    /**
     * Display posts as a list
     */
    ListView = 1,
    /**
     * Display posts as a collection of tiles
     */
    GalleryView = 2,
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct APIThreadOnlyChannel {
    /**
     * The channel topic (0-4096 characters)
     */
    pub topic: Option<String>,
    /**
     * The id of the last thread created in this channel (may not point to an existing or valid thread)
     */
    pub last_message_id: Option<String>,
    /**
     * Amount of seconds a user has to wait before creating another thread (0-21600);
     * bots, as well as users with the permission `MANAGE_MESSAGES` or `MANAGE_CHANNELS`, are unaffected
     *
     * The absence of this field in API calls and Gateway events should indicate that slowmode has been reset to the default value.
     */
    pub rate_limit_per_user: Option<i64>,
    /**
     * When the last pinned message was pinned.
     * This may be `null` in events such as `GUILD_CREATE` when a message is not pinned
     */
    pub last_pin_timestamp: Option<String>,
    /**
     * Default duration for newly created threads, in minutes, to automatically archive the thread after recent activity
     */
    pub default_auto_archive_duration: Option<ThreadAutoArchiveDuration>,
    /**
     * The set of tags that can be used in a thread-only channel
     */
    pub available_tags: Vec<APIGuildForumTag>,
    /**
     * The initial `rate_limit_per_user` to set on newly created threads.
     * This field is copied to the thread at creation time and does not live update
     */
    pub default_thread_rate_limit_per_user: Option<i64>,
    /**
     * The emoji to show in the add reaction button on a thread in a thread-only channel
     */
    pub default_reaction_emoji: Option<APIGuildForumDefaultReactionEmoji>,
    /**
     * The default sort order type used to order posts in a thread-only channel
     */
    pub default_sort_order: Option<SortOrderType>,
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct APIGuildForumChannel {
    /**
     * The default layout type used to display posts in a forum channel
     *
     * @defaultValue `ForumLayoutType.NotSet` which indicates a layout view has not been set by a channel admin
     */
    pub default_forum_layout: ForumLayoutType,
}

pub type APIGuildMediaChannel = APIThreadOnlyChannel;

/**
 * @see {@link https://discord.com/developers/docs/resources/channel#channel-object-channel-structure}
 */
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(untagged)]
pub enum APIChannel {
    APIAnnouncementThreadChannel(APIAnnouncementThreadChannel),
    APIDMChannel(APIDMChannel),
    APIGroupDMChannel(APIGroupDMChannel),
    APIGuildCategoryChannel(APIGuildCategoryChannel),
    APIGuildForumChannel(APIGuildForumChannel),
    APIGuildMediaChannel(APIGuildMediaChannel),
    APIGuildStageVoiceChannel(APIGuildStageVoiceChannel),
    APIGuildVoiceChannel(APIGuildVoiceChannel),
    APINewsChannel(APINewsChannel),
    APIPrivateThreadChannel(APIPrivateThreadChannel),
    APIPublicThreadChannel(APIPublicThreadChannel),
    APITextChannel(APITextChannel),
}

/**
 * @see {@link https://discord.com/developers/docs/resources/channel#channel-object-channel-types}
 */
#[derive(Debug, Copy, Clone, Eq, PartialEq, Serialize_repr, Deserialize_repr)]
#[repr(u8)]
pub enum ChannelType {
    /**
     * A text channel within a guild
     */
    GuildText = 0,
    /**
     * A direct message between users
     */
    DM = 1,
    /**
     * A voice channel within a guild
     */
    GuildVoice = 2,
    /**
     * A direct message between multiple users
     */
    GroupDM = 3,
    /**
     * An organizational category that contains up to 50 channels
     *
     * @see {@link https://support.discord.com/hc/articles/115001580171}
     */
    GuildCategory = 4,
    /**
     * A channel that users can follow and crosspost into their own guild
     *
     * @see {@link https://support.discord.com/hc/articles/360032008192}
     */
    GuildAnnouncement = 5,
    /**
     * A temporary sub-channel within a Guild Announcement channel
     */
    AnnouncementThread = 10,
    /**
     * A temporary sub-channel within a Guild Text or Guild Forum channel
     */
    PublicThread = 11,
    /**
     * A temporary sub-channel within a Guild Text channel that is only viewable by those invited and those with the Manage Threads permission
     */
    PrivateThread = 12,
    /**
     * A voice channel for hosting events with an audience
     *
     * @see {@link https://support.discord.com/hc/articles/1500005513722}
     */
    GuildStageVoice = 13,
    /**
     * The channel in a Student Hub containing the listed servers
     *
     * @see {@link https://support.discord.com/hc/articles/4406046651927}
     */
    GuildDirectory = 14,
    /**
     * A channel that can only contain threads
     */
    GuildForum = 15,
    /**
     * A channel like forum channels but contains media for server subscriptions
     *
     * @see {@link https://creator-support.discord.com/hc/articles/14346342766743}
     */
    GuildMedia = 16,
}

#[derive(Debug, Copy, Clone, Eq, PartialEq, Serialize_repr, Deserialize_repr)]
#[repr(u8)]
pub enum VideoQualityMode {
    /**
     * Discord chooses the quality for optimal performance
     */
    Auto = 1,
    /**
     * 720p
     */
    Full = 2,
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct APIMessageMentions {
    /**
     * Users specifically mentioned in the message
     *
     * The `member` field is only present in `MESSAGE_CREATE` and `MESSAGE_UPDATE` events
     * from text-based guild channels
     *
     * @see {@link https://discord.com/developers/docs/resources/user#user-object}
     * @see {@link https://discord.com/developers/docs/resources/guild#guild-member-object}
     */
    pub mentions: Vec<APIUser>,
}

/**
 * @see {@link https://discord.com/developers/docs/resources/channel#message-object-message-structure}
 */
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct APIBaseMessageNoChannel {
    /**
     * ID of the message
     */
    pub id: String,
    /**
     * The author of this message (only a valid user in the case where the message is generated by a user or bot user)
     *
     * If the message is generated by a webhook, the author object corresponds to the webhook's id,
     * username, and avatar. You can tell if a message is generated by a webhook by checking for the `webhook_id` property
     *
     * @see {@link https://discord.com/developers/docs/resources/user#user-object}
     */
    pub author: APIUser,
    /**
     * Contents of the message
     *
     * The `MESSAGE_CONTENT` privileged gateway intent is required for verified applications to receive a non-empty value from this field
     *
     * In the Discord Developers Portal, you need to enable the toggle of this intent of your application in **Bot \> Privileged Gateway Intents**.
     * You also need to specify the intent bit value (`1 << 15`) if you are connecting to the gateway
     *
     * @see {@link https://support-dev.discord.com/hc/articles/6207308062871}
     */
    pub content: String,
    /**
     * When this message was sent
     */
    pub timestamp: String,
    /**
     * When this message was edited (or null if never)
     */
    pub edited_timestamp: Option<String>,
    /**
     * Whether this was a TTS message
     */
    pub tts: bool,
    /**
     * Whether this message mentions everyone
     */
    pub mention_everyone: bool,
    /**
     * Roles specifically mentioned in this message
     *
     * @see {@link https://discord.com/developers/docs/topics/permissions#role-object}
     */
    pub mention_roles: Vec<APIRole>,
    /**
     * Channels specifically mentioned in this message
     *
     * Not all channel mentions in a message will appear in `mention_channels`.
     * - Only textual channels that are visible to everyone in a lurkable guild will ever be included
     * - Only crossposted messages (via Channel Following) currently include `mention_channels` at all
     *
     * If no mentions in the message meet these requirements, this field will not be sent
     *
     * @see {@link https://discord.com/developers/docs/resources/channel#channel-mention-object}
     */
    pub mention_channels: Option<Vec<APIChannelMention>>,
    /**
     * Any attached files
     *
     * @see {@link https://discord.com/developers/docs/resources/message#attachment-object-attachment-structure}
     *
     * The `MESSAGE_CONTENT` privileged gateway intent is required for verified applications to receive a non-empty value from this field
     *
     * In the Discord Developers Portal, you need to enable the toggle of this intent of your application in **Bot \> Privileged Gateway Intents**.
     * You also need to specify the intent bit value (`1 << 15`) if you are connecting to the gateway
     * @see {@link https://support-dev.discord.com/hc/articles/6207308062871}
     */
    pub attachments: Vec<APIAttachment>,
    /**
     * Any embedded content
     *
     * @see {@link https://discord.com/developers/docs/resources/channel#embed-object}
     *
     * The `MESSAGE_CONTENT` privileged gateway intent is required for verified applications to receive a non-empty value from this field
     *
     * In the Discord Developers Portal, you need to enable the toggle of this intent of your application in **Bot \> Privileged Gateway Intents**.
     * You also need to specify the intent bit value (`1 << 15`) if you are connecting to the gateway
     * @see {@link https://support-dev.discord.com/hc/articles/6207308062871}
     */
    pub embeds: Vec<APIEmbed>,
    /**
     * Reactions to the message
     *
     * @see {@link https://discord.com/developers/docs/resources/channel#reaction-object}
     */
    pub reactions: Option<Vec<APIReaction>>,
    /**
     * A nonce that can be used for optimistic message sending (up to 25 characters)
     *
     * **You will not receive this from further fetches. This is received only once from a `MESSAGE_CREATE`
     * event to ensure it got sent**
     */
    pub nonce: Option<serde_json::Value>,
    /**
     * Whether this message is pinned
     */
    pub pinned: bool,
    /**
     * If the message is generated by a webhook, this is the webhook's id
     */
    pub webhook_id: Option<String>,
    /**
     * Type of message
     *
     * @see {@link https://discord.com/developers/docs/resources/channel#message-object-message-types}
     */
    pub r#type: MessageType,
    /**
     * Sent with Rich Presence-related chat embeds
     *
     * @see {@link https://discord.com/developers/docs/resources/channel#message-object-message-activity-structure}
     */
    pub activity: Option<APIMessageActivity>,
    /**
     * Sent with Rich Presence-related chat embeds
     *
     * @see {@link https://discord.com/developers/docs/resources/application#application-object}
     */
    pub application: Option<APIApplication>,
    /**
     * If the message is a response to an Interaction, this is the id of the interaction's application
     */
    pub application_id: Option<String>,
    /**
     * Reference data sent with crossposted messages, replies, pins, and thread starter messages
     *
     * @see {@link https://discord.com/developers/docs/resources/channel#message-reference-object-message-reference-structure}
     */
    pub message_reference: Option<APIMessageReference>,
    /**
     * Message flags combined as a bitfield
     *
     * @see {@link https://discord.com/developers/docs/resources/channel#message-object-message-flags}
     * @see {@link https://en.wikipedia.org/wiki/Bit_field}
     */
    #[serde(default, with = "crate::utils::serde::flags_numeric_opt")]
    pub flags: Option<MessageFlags>,
    /**
     * The message associated with the `message_reference`
     *
     * This field is only returned for messages with a `type` of `19` (REPLY).
     *
     * If the message is a reply but the `referenced_message` field is not present,
     * the backend did not attempt to fetch the message that was being replied to,
     * so its state is unknown.
     *
     * If the field exists but is `null`, the referenced message was deleted
     *
     * @see {@link https://discord.com/developers/docs/resources/channel#message-object}
     */
    pub referenced_message: Option<Box<APIMessage>>,
    /**
     * Sent if the message is sent as a result of an interaction
     */
    pub interaction_metadata: Option<APIMessageInteractionMetadata>,
    /**
     * Sent if the message is a response to an Interaction
     *
     * @deprecated In favor of `interaction_metadata`
     */
    pub interaction: Option<APIMessageInteraction>,
    /**
     * Sent if a thread was started from this message
     */
    pub thread: Option<APIChannel>,
    /**
     * Sent if the message contains components like buttons, action rows, or other interactive components
     *
     * The `MESSAGE_CONTENT` privileged gateway intent is required for verified applications to receive a non-empty value from this field
     *
     * In the Discord Developers Portal, you need to enable the toggle of this intent of your application in **Bot \> Privileged Gateway Intents**.
     * You also need to specify the intent bit value (`1 << 15`) if you are connecting to the gateway
     *
     * @see {@link https://support-dev.discord.com/hc/articles/6207308062871}
     */
    pub components: Option<Vec<APIMessageTopLevelComponent>>,
    /**
     * Sent if the message contains stickers
     *
     * @see {@link https://discord.com/developers/docs/resources/sticker#sticker-item-object}
     */
    pub sticker_items: Option<Vec<APIStickerItem>>,
    /**
     * The stickers sent with the message
     *
     * @see {@link https://discord.com/developers/docs/resources/sticker#sticker-object}
     * @deprecated Use {@link APIBaseMessageNoChannel.sticker_items} instead
     */
    pub stickers: Option<Vec<APISticker>>,
    /**
     * A generally increasing integer (there may be gaps or duplicates) that represents the approximate position of the message in a thread
     *
     * It can be used to estimate the relative position of the message in a thread in company with `total_message_sent` on parent thread
     */
    pub position: Option<i64>,
    /**
     * Data of the role subscription purchase or renewal that prompted this `ROLE_SUBSCRIPTION_PURCHASE` message
     */
    pub role_subscription_data: Option<APIMessageRoleSubscriptionData>,
    /**
     * Data for users, members, channels, and roles in the message's auto-populated select menus
     *
     * @see {@link https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object-resolved-data-structure}
     */
    pub resolved: Option<APIInteractionDataResolved>,
    /**
     * A poll!
     *
     * The `MESSAGE_CONTENT` privileged gateway intent is required for verified applications to receive a non-empty value from this field
     *
     * In the Discord Developers Portal, you need to enable the toggle of this intent of your application in **Bot \> Privileged Gateway Intents**.
     * You also need to specify the intent bit value (`1 << 15`) if you are connecting to the gateway
     *
     * @see {@link https://support-dev.discord.com/hc/articles/6207308062871}
     */
    pub poll: Option<APIPoll>,
    /**
     * The message associated with the message_reference. This is a minimal subset of fields in a message (e.g. author is excluded.)
     */
    pub message_snapshots: Option<Vec<APIMessageSnapshot>>,
    /**
     * The call associated with the message
     */
    pub call: Option<APIMessageCall>,
}

/**
 * @see {@link https://discord.com/developers/docs/resources/channel#message-object-message-structure}
 */
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct APIBaseMessage {
    /**
     * ID of the channel the message was sent in
     */
    pub channel_id: String,

    /**
     * ID of the message
     */
    pub id: String,
    /**
     * The author of this message (only a valid user in the case where the message is generated by a user or bot user)
     *
     * If the message is generated by a webhook, the author object corresponds to the webhook's id,
     * username, and avatar. You can tell if a message is generated by a webhook by checking for the `webhook_id` property
     *
     * @see {@link https://discord.com/developers/docs/resources/user#user-object}
     */
    pub author: APIUser,
    /**
     * Contents of the message
     *
     * The `MESSAGE_CONTENT` privileged gateway intent is required for verified applications to receive a non-empty value from this field
     *
     * In the Discord Developers Portal, you need to enable the toggle of this intent of your application in **Bot \> Privileged Gateway Intents**.
     * You also need to specify the intent bit value (`1 << 15`) if you are connecting to the gateway
     *
     * @see {@link https://support-dev.discord.com/hc/articles/6207308062871}
     */
    pub content: String,
    /**
     * When this message was sent
     */
    pub timestamp: String,
    /**
     * When this message was edited (or null if never)
     */
    pub edited_timestamp: Option<String>,
    /**
     * Whether this was a TTS message
     */
    pub tts: bool,
    /**
     * Whether this message mentions everyone
     */
    pub mention_everyone: bool,
    /**
     * Roles specifically mentioned in this message
     *
     * @see {@link https://discord.com/developers/docs/topics/permissions#role-object}
     */
    pub mention_roles: Vec<APIRole>,
    /**
     * Channels specifically mentioned in this message
     *
     * Not all channel mentions in a message will appear in `mention_channels`.
     * - Only textual channels that are visible to everyone in a lurkable guild will ever be included
     * - Only crossposted messages (via Channel Following) currently include `mention_channels` at all
     *
     * If no mentions in the message meet these requirements, this field will not be sent
     *
     * @see {@link https://discord.com/developers/docs/resources/channel#channel-mention-object}
     */
    pub mention_channels: Option<Vec<APIChannelMention>>,
    /**
     * Any attached files
     *
     * @see {@link https://discord.com/developers/docs/resources/message#attachment-object-attachment-structure}
     *
     * The `MESSAGE_CONTENT` privileged gateway intent is required for verified applications to receive a non-empty value from this field
     *
     * In the Discord Developers Portal, you need to enable the toggle of this intent of your application in **Bot \> Privileged Gateway Intents**.
     * You also need to specify the intent bit value (`1 << 15`) if you are connecting to the gateway
     * @see {@link https://support-dev.discord.com/hc/articles/6207308062871}
     */
    pub attachments: Vec<APIAttachment>,
    /**
     * Any embedded content
     *
     * @see {@link https://discord.com/developers/docs/resources/channel#embed-object}
     *
     * The `MESSAGE_CONTENT` privileged gateway intent is required for verified applications to receive a non-empty value from this field
     *
     * In the Discord Developers Portal, you need to enable the toggle of this intent of your application in **Bot \> Privileged Gateway Intents**.
     * You also need to specify the intent bit value (`1 << 15`) if you are connecting to the gateway
     * @see {@link https://support-dev.discord.com/hc/articles/6207308062871}
     */
    pub embeds: Vec<APIEmbed>,
    /**
     * Reactions to the message
     *
     * @see {@link https://discord.com/developers/docs/resources/channel#reaction-object}
     */
    pub reactions: Option<Vec<APIReaction>>,
    /**
     * A nonce that can be used for optimistic message sending (up to 25 characters)
     *
     * **You will not receive this from further fetches. This is received only once from a `MESSAGE_CREATE`
     * event to ensure it got sent**
     */
    pub nonce: Option<serde_json::Value>,
    /**
     * Whether this message is pinned
     */
    pub pinned: bool,
    /**
     * If the message is generated by a webhook, this is the webhook's id
     */
    pub webhook_id: Option<String>,
    /**
     * Type of message
     *
     * @see {@link https://discord.com/developers/docs/resources/channel#message-object-message-types}
     */
    pub r#type: MessageType,
    /**
     * Sent with Rich Presence-related chat embeds
     *
     * @see {@link https://discord.com/developers/docs/resources/channel#message-object-message-activity-structure}
     */
    pub activity: Option<APIMessageActivity>,
    /**
     * Sent with Rich Presence-related chat embeds
     *
     * @see {@link https://discord.com/developers/docs/resources/application#application-object}
     */
    pub application: Option<APIApplication>,
    /**
     * If the message is a response to an Interaction, this is the id of the interaction's application
     */
    pub application_id: Option<String>,
    /**
     * Reference data sent with crossposted messages, replies, pins, and thread starter messages
     *
     * @see {@link https://discord.com/developers/docs/resources/channel#message-reference-object-message-reference-structure}
     */
    pub message_reference: Option<APIMessageReference>,
    /**
     * Message flags combined as a bitfield
     *
     * @see {@link https://discord.com/developers/docs/resources/channel#message-object-message-flags}
     * @see {@link https://en.wikipedia.org/wiki/Bit_field}
     */
    #[serde(default, with = "crate::utils::serde::flags_numeric_opt")]
    pub flags: Option<MessageFlags>,
    /**
     * The message associated with the `message_reference`
     *
     * This field is only returned for messages with a `type` of `19` (REPLY).
     *
     * If the message is a reply but the `referenced_message` field is not present,
     * the backend did not attempt to fetch the message that was being replied to,
     * so its state is unknown.
     *
     * If the field exists but is `null`, the referenced message was deleted
     *
     * @see {@link https://discord.com/developers/docs/resources/channel#message-object}
     */
    pub referenced_message: Option<Box<APIMessage>>,
    /**
     * Sent if the message is sent as a result of an interaction
     */
    pub interaction_metadata: Option<APIMessageInteractionMetadata>,
    /**
     * Sent if the message is a response to an Interaction
     *
     * @deprecated In favor of `interaction_metadata`
     */
    pub interaction: Option<APIMessageInteraction>,
    /**
     * Sent if a thread was started from this message
     */
    pub thread: Option<APIChannel>,
    /**
     * Sent if the message contains components like buttons, action rows, or other interactive components
     *
     * The `MESSAGE_CONTENT` privileged gateway intent is required for verified applications to receive a non-empty value from this field
     *
     * In the Discord Developers Portal, you need to enable the toggle of this intent of your application in **Bot \> Privileged Gateway Intents**.
     * You also need to specify the intent bit value (`1 << 15`) if you are connecting to the gateway
     *
     * @see {@link https://support-dev.discord.com/hc/articles/6207308062871}
     */
    pub components: Option<Vec<APIMessageTopLevelComponent>>,
    /**
     * Sent if the message contains stickers
     *
     * @see {@link https://discord.com/developers/docs/resources/sticker#sticker-item-object}
     */
    pub sticker_items: Option<Vec<APIStickerItem>>,
    /**
     * The stickers sent with the message
     *
     * @see {@link https://discord.com/developers/docs/resources/sticker#sticker-object}
     * @deprecated Use {@link APIBaseMessageNoChannel.sticker_items} instead
     */
    pub stickers: Option<Vec<APISticker>>,
    /**
     * A generally increasing integer (there may be gaps or duplicates) that represents the approximate position of the message in a thread
     *
     * It can be used to estimate the relative position of the message in a thread in company with `total_message_sent` on parent thread
     */
    pub position: Option<i64>,
    /**
     * Data of the role subscription purchase or renewal that prompted this `ROLE_SUBSCRIPTION_PURCHASE` message
     */
    pub role_subscription_data: Option<APIMessageRoleSubscriptionData>,
    /**
     * Data for users, members, channels, and roles in the message's auto-populated select menus
     *
     * @see {@link https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object-resolved-data-structure}
     */
    pub resolved: Option<APIInteractionDataResolved>,
    /**
     * A poll!
     *
     * The `MESSAGE_CONTENT` privileged gateway intent is required for verified applications to receive a non-empty value from this field
     *
     * In the Discord Developers Portal, you need to enable the toggle of this intent of your application in **Bot \> Privileged Gateway Intents**.
     * You also need to specify the intent bit value (`1 << 15`) if you are connecting to the gateway
     *
     * @see {@link https://support-dev.discord.com/hc/articles/6207308062871}
     */
    pub poll: Option<APIPoll>,
    /**
     * The message associated with the message_reference. This is a minimal subset of fields in a message (e.g. author is excluded.)
     */
    pub message_snapshots: Option<Vec<APIMessageSnapshot>>,
    /**
     * The call associated with the message
     */
    pub call: Option<APIMessageCall>,
}

/**
 * @see {@link https://discord.com/developers/docs/resources/channel#message-object-message-structure}
 */
pub type APIMessage = APIBaseMessage;

/**
 * @see {@link https://discord.com/developers/docs/resources/channel#message-object-message-types}
 */
#[derive(Debug, Copy, Clone, Eq, PartialEq, Serialize_repr, Deserialize_repr)]
#[repr(u8)]
pub enum MessageType {
    Default = 0,
    RecipientAdd = 1,
    RecipientRemove = 2,
    Call = 3,
    ChannelNameChange = 4,
    ChannelIconChange = 5,
    ChannelPinnedMessage = 6,
    UserJoin = 7,
    GuildBoost = 8,
    GuildBoostTier1 = 9,
    GuildBoostTier2 = 10,
    GuildBoostTier3 = 11,
    ChannelFollowAdd = 12,

    GuildDiscoveryDisqualified = 14,
    GuildDiscoveryRequalified = 15,
    GuildDiscoveryGracePeriodInitialWarning = 16,
    GuildDiscoveryGracePeriodFinalWarning = 17,
    ThreadCreated = 18,
    Reply = 19,
    ChatInputCommand = 20,
    ThreadStarterMessage = 21,
    GuildInviteReminder = 22,
    ContextMenuCommand = 23,
    AutoModerationAction = 24,
    RoleSubscriptionPurchase = 25,
    InteractionPremiumUpsell = 26,
    StageStart = 27,
    StageEnd = 28,
    StageSpeaker = 29,
    /**
     * @unstable https://github.com/discord/discord-api-docs/pull/5927#discussion_r1107678548
     */
    StageRaiseHand = 30,
    StageTopic = 31,
    GuildApplicationPremiumSubscription = 32,

    GuildIncidentAlertModeEnabled = 36,
    GuildIncidentAlertModeDisabled = 37,
    GuildIncidentReportRaid = 38,
    GuildIncidentReportFalseAlarm = 39,

    PurchaseNotification = 44,

    PollResult = 46,
}

/**
 * @see {@link https://discord.com/developers/docs/resources/channel#message-object-message-activity-structure}
 */
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct APIMessageActivity {
    /**
     * Type of message activity
     *
     * @see {@link https://discord.com/developers/docs/resources/channel#message-object-message-activity-types}
     */
    pub r#type: MessageActivityType,
    /**
     * `party_id` from a Rich Presence event
     *
     * @see {@link https://discord.com/developers/docs/rich-presence/how-to#updating-presence-update-presence-payload-fields}
     */
    pub party_id: Option<String>,
}

/**
 * @see {@link https://discord.com/developers/docs/resources/channel#message-reference-object-message-reference-structure}
 */
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct APIMessageReference {
    /**
     * Type of reference
     */
    pub r#type: Option<MessageReferenceType>,
    /**
     * ID of the originating message
     */
    pub message_id: Option<String>,
    /**
     * ID of the originating message's channel
     */
    pub channel_id: String,
    /**
     * ID of the originating message's guild
     */
    pub guild_id: Option<String>,
}

/**
 * @see {@link https://discord.com/developers/docs/resources/channel#message-object-message-activity-types}
 */
#[derive(Debug, Copy, Clone, Eq, PartialEq, Serialize_repr, Deserialize_repr)]
#[repr(u8)]
pub enum MessageActivityType {
    Join = 1,
    Spectate = 2,
    Listen = 3,
    JoinRequest = 5,
}

/**
 * @see {@link https://discord.com/developers/docs/resources/channel#message-reference-types}
 */
#[derive(Debug, Copy, Clone, Eq, PartialEq, Serialize_repr, Deserialize_repr)]
#[repr(u8)]
pub enum MessageReferenceType {
    /**
     * A standard reference used by replies
     */
    Default = 0,
    /**
     * Reference used to point to a message at a point in time
     */
    Forward = 1,
}

bitflags! {
    /// Numeric bitflags as per Discord "message.flags".
    #[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize, Default)]
    #[serde(transparent)]
    pub struct MessageFlags: u64 {
        const CROSSPOSTED                         = 1 << 0;
        const IS_CROSSPOST                        = 1 << 1;
        const SUPPRESS_EMBEDS                     = 1 << 2;
        const SOURCE_MESSAGE_DELETED              = 1 << 3;
        const URGENT                              = 1 << 4;
        const HAS_THREAD                          = 1 << 5;
        const EPHEMERAL                           = 1 << 6;
        const LOADING                             = 1 << 7;
        const FAILED_TO_MENTION_SOME_ROLES        = 1 << 8;
        const SHOULD_SHOW_LINK_NOT_DISCORD_WARN   = 1 << 10;
        const SUPPRESS_NOTIFICATIONS              = 1 << 12;
        const IS_VOICE_MESSAGE                    = 1 << 13;
        const HAS_SNAPSHOT                        = 1 << 14;
        const IS_COMPONENTS_V2                    = 1 << 15;
    }
}

/**
 * @see {@link https://discord.com/developers/docs/resources/channel#message-call-object-message-call-object-structure}
 */
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct APIMessageCall {
    /**
     * Array of user ids that participated in the call
     */
    pub participants: Vec<String>,
    /**
     * ISO8601 timestamp when the call ended
     */
    pub ended_timestamp: Option<String>,
}

/**
 * @see {@link https://discord.com/developers/docs/resources/channel#role-subscription-data-object-role-subscription-data-object-structure}
 */
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct APIMessageRoleSubscriptionData {
    /**
     * The id of the SKU and listing the user is subscribed to
     */
    pub role_subscription_listing_id: String,
    /**
     * The name of the tier the user is subscribed to
     */
    pub tier_name: String,
    /**
     * The number of months the user has been subscribed for
     */
    pub total_months_subscribed: i64,
    /**
     * Whether this notification is for a renewal
     */
    pub is_renewal: bool,
}

/**
 * @see {@link https://discord.com/developers/docs/resources/channel#followed-channel-object}
 */
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct APIFollowedChannel {
    /**
     * Source channel id
     */
    pub channel_id: String,
    /**
     * Created target webhook id
     */
    pub webhook_id: String,
}

/**
 * @see {@link https://discord.com/developers/docs/resources/channel#reaction-object-reaction-structure}
 */
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct APIReaction {
    /**
     * Total number of times this emoji has been used to react (including super reacts)
     */
    pub count: i64,
    /**
     * An object detailing the individual reaction counts for different types of reactions
     */
    pub count_details: APIReactionCountDetails,
    /**
     * Whether the current user reacted using this emoji
     */
    pub me: bool,
    /**
     * Whether the current user super-reacted using this emoji
     */
    pub me_burst: bool,
    /**
     * Emoji information
     *
     * @see {@link https://discord.com/developers/docs/resources/emoji#emoji-object}
     */
    pub emoji: APIPartialEmoji,
    /**
     * Hexadecimal colors used for this super reaction
     */
    pub burst_colors: Vec<String>,
}

/**
 * @see {@link https://discord.com/developers/docs/resources/channel#reaction-count-details-object-reaction-count-details-structure}
 */
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct APIReactionCountDetails {
    /**
     * Count of super reactions
     */
    pub burst: i64,
    /**
     * Count of normal reactions
     */
    pub normal: i64,
}

/**
 * @see {@link https://discord.com/developers/docs/resources/channel#overwrite-object-overwrite-structure}
 */
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct APIOverwrite {
    /**
     * Role or user id
     */
    pub id: String,
    /**
     * Either 0 (role) or 1 (member)
     */
    pub r#type: OverwriteType,
    /**
     * Permission bit set
     *
     * @see {@link https://discord.com/developers/docs/topics/permissions#permissions-bitwise-permission-flags}
     * @see {@link https://en.wikipedia.org/wiki/Bit_field}
     */
    pub allow: String,
    /**
     * Permission bit set
     *
     * @see {@link https://discord.com/developers/docs/topics/permissions#permissions-bitwise-permission-flags}
     * @see {@link https://en.wikipedia.org/wiki/Bit_field}
     */
    pub deny: String,
}

#[derive(Debug, Copy, Clone, Eq, PartialEq, Serialize_repr, Deserialize_repr)]
#[repr(u8)]
pub enum OverwriteType {
    Role = 0,
    Member = 1,
}

/**
 * @see {@link https://discord.com/developers/docs/resources/channel#thread-metadata-object-thread-metadata-structure}
 */
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct APIThreadMetadata {
    /**
     * Whether the thread is archived
     */
    pub archived: bool,
    /**
     * Duration in minutes to automatically archive the thread after recent activity, can be set to: 60, 1440, 4320, 10080
     */
    pub auto_archive_duration: ThreadAutoArchiveDuration,
    /**
     * An ISO8601 timestamp when the thread's archive status was last changed, used for calculating recent activity
     */
    pub archive_timestamp: String,
    /**
     * Whether the thread is locked; when a thread is locked, only users with `MANAGE_THREADS` can unarchive it
     */
    pub locked: bool,
    /**
     * Whether non-moderators can add other non-moderators to the thread; only available on private threads
     */
    pub invitable: Option<bool>,
    /**
     * Timestamp when the thread was created; only populated for threads created after 2022-01-09
     */
    pub create_timestamp: Option<String>,
}

#[derive(Debug, Copy, Clone, Eq, PartialEq, Serialize_repr, Deserialize_repr)]
#[repr(u32)]
pub enum ThreadAutoArchiveDuration {
    OneHour = 60,
    OneDay = 1_440,
    ThreeDays = 4_320,
    OneWeek = 10_080,
}

/**
 * @see {@link https://discord.com/developers/docs/resources/channel#thread-member-object-thread-member-structure}
 */
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct APIThreadMember {
    /**
     * The id of the thread
     *
     * **This field is omitted on the member sent within each thread in the `GUILD_CREATE` event**
     */
    pub id: Option<String>,
    /**
     * The id of the member
     *
     * **This field is omitted on the member sent within each thread in the `GUILD_CREATE` event**
     */
    pub user_id: Option<String>,
    /**
     * An ISO8601 timestamp for when the member last joined
     */
    pub join_timestamp: String,
    /**
     * Member flags combined as a bitfield
     *
     * @see {@link https://en.wikipedia.org/wiki/Bit_field}
     */
    pub flags: ThreadMemberFlags,
    /**
     * Additional information about the user
     *
     * **This field is omitted on the member sent within each thread in the `GUILD_CREATE` event**
     *
     * **This field is only present when `with_member` is set to true when calling `List Thread Members` or `Get Thread Member`**
     */
    pub member: Option<APIGuildMember>,
}

bitflags! {
    #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
    pub struct ThreadMemberFlags: u32 {
        /**
         * @unstable This thread member flag is currently not documented by Discord but has a known value which we will try to keep up to date.
         */
        const HasInteracted = 1 << 0;
        /**
         * @unstable This thread member flag is currently not documented by Discord but has a known value which we will try to keep up to date.
         */
        const AllMessages = 1 << 1;
        /**
         * @unstable This thread member flag is currently not documented by Discord but has a known value which we will try to keep up to date.
         */
        const OnlyMentions = 1 << 2;
        /**
         * @unstable This thread member flag is currently not documented by Discord but has a known value which we will try to keep up to date.
         */
        const NoMessages = 1 << 3;
    }
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct APIThreadList {
    /**
     * The threads that were fetched
     */
    pub threads: Vec<APIChannel>,
    /**
     * The members for the client user in each of the fetched threads
     */
    pub members: Vec<APIThreadMember>,
}

/**
 * @see {@link https://discord.com/developers/docs/resources/channel#embed-object-embed-structure}
 *
 * Length limit: 6000 characters
 */
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct APIEmbed {
    /**
     * Title of embed
     *
     * Length limit: 256 characters
     */
    pub title: Option<String>,
    /**
     * Type of embed (always "rich" for webhook embeds)
     */
    pub r#type: Option<EmbedType>,
    /**
     * Description of embed
     *
     * Length limit: 4096 characters
     */
    pub description: Option<String>,
    /**
     * URL of embed
     */
    pub url: Option<String>,
    /**
     * Timestamp of embed content
     */
    pub timestamp: Option<String>,
    /**
     * Color code of the embed
     */
    pub color: Option<i64>,
    /**
     * Footer information
     *
     * @see {@link https://discord.com/developers/docs/resources/channel#embed-object-embed-footer-structure}
     */
    pub footer: Option<APIEmbedFooter>,
    /**
     * Image information
     *
     * @see {@link https://discord.com/developers/docs/resources/channel#embed-object-embed-image-structure}
     */
    pub image: Option<APIEmbedImage>,
    /**
     * Thumbnail information
     *
     * @see {@link https://discord.com/developers/docs/resources/channel#embed-object-embed-thumbnail-structure}
     */
    pub thumbnail: Option<APIEmbedThumbnail>,
    /**
     * Video information
     *
     * @see {@link https://discord.com/developers/docs/resources/channel#embed-object-embed-video-structure}
     */
    pub video: Option<APIEmbedVideo>,
    /**
     * Provider information
     *
     * @see {@link https://discord.com/developers/docs/resources/channel#embed-object-embed-provider-structure}
     */
    pub provider: Option<APIEmbedProvider>,
    /**
     * Author information
     *
     * @see {@link https://discord.com/developers/docs/resources/channel#embed-object-embed-author-structure}
     */
    pub author: Option<APIEmbedAuthor>,
    /**
     * Fields information
     *
     * Length limit: 25 field objects
     *
     * @see {@link https://discord.com/developers/docs/resources/channel#embed-object-embed-field-structure}
     */
    pub fields: Option<Vec<APIEmbedField>>,
}

/**
 * @see {@link https://discord.com/developers/docs/resources/channel#embed-object-embed-types}
 */
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "snake_case")]
pub enum EmbedType {
    /**
     * Generic embed rendered from embed attributes
     */
    #[serde(rename = "rich")]
    Rich,
    /**
     * Image embed
     */
    #[serde(rename = "image")]
    Image,
    /**
     * Video embed
     */
    #[serde(rename = "video")]
    Video,
    /**
     * Animated gif image embed rendered as a video embed
     */
    #[serde(rename = "gifv")]
    GIFV,
    /**
     * Article embed
     */
    #[serde(rename = "article")]
    Article,
    /**
     * Link embed
     */
    #[serde(rename = "link")]
    Link,
    /**
     * Auto moderation alert embed
     *
     * @unstable This embed type is currently not documented by Discord, but it is returned in the auto moderation system messages.
     */
    #[serde(rename = "auto_moderation_message")]
    AutoModerationMessage,
    /**
     * Poll result embed
     */
    #[serde(rename = "poll_result")]
    PollResult,
}

/**
 * @see {@link https://discord.com/developers/docs/resources/channel#embed-object-embed-thumbnail-structure}
 */
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct APIEmbedThumbnail {
    /**
     * Source url of thumbnail (only supports http(s) and attachments)
     */
    pub url: String,
    /**
     * A proxied url of the thumbnail
     */
    pub proxy_url: Option<String>,
    /**
     * Height of thumbnail
     */
    pub height: Option<i64>,
    /**
     * Width of thumbnail
     */
    pub width: Option<i64>,
}

/**
 * @see {@link https://discord.com/developers/docs/resources/channel#embed-object-embed-video-structure}
 */
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct APIEmbedVideo {
    /**
     * Source url of video
     */
    pub url: Option<String>,
    /**
     * A proxied url of the video
     */
    pub proxy_url: Option<String>,
    /**
     * Height of video
     */
    pub height: Option<i64>,
    /**
     * Width of video
     */
    pub width: Option<i64>,
}

/**
 * @see {@link https://discord.com/developers/docs/resources/channel#embed-object-embed-image-structure}
 */
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct APIEmbedImage {
    /**
     * Source url of image (only supports http(s) and attachments)
     */
    pub url: String,
    /**
     * A proxied url of the image
     */
    pub proxy_url: Option<String>,
    /**
     * Height of image
     */
    pub height: Option<i64>,
    /**
     * Width of image
     */
    pub width: Option<i64>,
}

/**
 * @see {@link https://discord.com/developers/docs/resources/channel#embed-object-embed-provider-structure}
 */
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct APIEmbedProvider {
    /**
     * Name of provider
     */
    pub name: Option<String>,
    /**
     * URL of provider
     */
    pub url: Option<String>,
}

/**
 * @see {@link https://discord.com/developers/docs/resources/channel#embed-object-embed-author-structure}
 */
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct APIEmbedAuthor {
    /**
     * Name of author
     *
     * Length limit: 256 characters
     */
    pub name: String,
    /**
     * URL of author
     */
    pub url: Option<String>,
    /**
     * URL of author icon (only supports http(s) and attachments)
     */
    pub icon_url: Option<String>,
    /**
     * A proxied url of author icon
     */
    pub proxy_icon_url: Option<String>,
}

/**
 * @see {@link https://discord.com/developers/docs/resources/channel#embed-object-embed-footer-structure}
 */
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct APIEmbedFooter {
    /**
     * Footer text
     *
     * Length limit: 2048 characters
     */
    pub text: String,
    /**
     * URL of footer icon (only supports http(s) and attachments)
     */
    pub icon_url: Option<String>,
    /**
     * A proxied url of footer icon
     */
    pub proxy_icon_url: Option<String>,
}

/**
 * @see {@link https://discord.com/developers/docs/resources/channel#embed-object-embed-field-structure}
 */
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct APIEmbedField {
    /**
     * Name of the field
     *
     * Length limit: 256 characters
     */
    pub name: String,
    /**
     * Value of the field
     *
     * Length limit: 1024 characters
     */
    pub value: String,
    /**
     * Whether or not this field should display inline
     */
    pub inline: Option<bool>,
}

/**
 * @see {@link https://discord.com/developers/docs/resources/message#attachment-object-attachment-structure}
 */
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct APIAttachment {
    /**
     * Attachment id
     */
    pub id: String,
    /**
     * Name of file attached
     */
    pub filename: String,
    /**
     * The title of the file
     */
    pub title: Option<String>,
    /**
     * Description for the file
     */
    pub description: Option<String>,
    /**
     * The attachment's media type
     *
     * @see {@link https://en.wikipedia.org/wiki/Media_type}
     */
    pub content_type: Option<String>,
    /**
     * Size of file in bytes
     */
    pub size: i64,
    /**
     * Source url of file
     */
    pub url: String,
    /**
     * A proxied url of file
     */
    pub proxy_url: String,
    /**
     * Height of file (if image)
     */
    pub height: Option<i64>,
    /**
     * Width of file (if image)
     */
    pub width: Option<i64>,
    /**
     * Whether this attachment is ephemeral
     */
    pub ephemeral: Option<bool>,
    /**
     * The duration of the audio file (currently for voice messages)
     */
    pub duration_secs: Option<f64>,
    /**
     * Base64 encoded bytearray representing a sampled waveform (currently for voice messages)
     */
    pub waveform: Option<String>,
    /**
     * Attachment flags combined as a bitfield
     */
    pub flags: Option<AttachmentFlags>,
}

bitflags! {
    /**
    * @see {@link https://discord.com/developers/docs/resources/channel#attachment-object-attachment-structure-attachment-flags}
    */
    #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
    pub struct AttachmentFlags: u32 {
        /**
         * This attachment has been edited using the remix feature on mobile
         */
        const IsRemix = 1 << 2;
    }
}

/**
 * @see {@link https://discord.com/developers/docs/resources/channel#channel-mention-object-channel-mention-structure}
 */
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct APIChannelMention {
    /**
     * ID of the channel
     */
    pub id: String,
    /**
     * ID of the guild containing the channel
     */
    pub guild_id: String,
    /**
     * The type of channel
     *
     * @see {@link https://discord.com/developers/docs/resources/channel#channel-object-channel-types}
     */
    pub r#type: ChannelType,
    /**
     * The name of the channel
     */
    pub name: String,
}

/**
 * @see {@link https://discord.com/developers/docs/resources/channel#allowed-mentions-object-allowed-mention-types}
 */
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "lowercase")]
pub enum AllowedMentionsTypes {
    /**
     * Controls `@everyone` and `@here` mentions
     */
    Everyone,
    /**
     * Controls role mentions
     */
    Role,
    /**
     * Controls user mentions
     */
    User,
}

/**
 * @see {@link https://discord.com/developers/docs/resources/channel#allowed-mentions-object-allowed-mentions-structure}
 */
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct APIAllowedMentions {
    /**
     * An array of allowed mention types to parse from the content
     *
     * @see {@link https://discord.com/developers/docs/resources/channel#allowed-mentions-object-allowed-mention-types}
     */
    pub parse: Option<Vec<AllowedMentionsTypes>>,
    /**
     * Array of role_ids to mention (Max size of 100)
     */
    pub roles: Option<Vec<String>>,
    /**
     * Array of user_ids to mention (Max size of 100)
     */
    pub users: Option<Vec<String>>,
    /**
     * For replies, whether to mention the author of the message being replied to
     *
     * @defaultValue `false`
     */
    pub replied_user: Option<bool>,
}

/**
 * @see {@link https://discord.com/developers/docs/components/reference#anatomy-of-a-component}
 */
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct APIBaseComponent<T> {
    /**
     * The type of the component
     */
    pub r#type: T,
    /**
     * 32 bit integer used as an optional identifier for component
     *
     * The id field is optional and is used to identify components in the response from an interaction that aren't interactive components. The id must be unique within the message and is generated sequentially if left empty. Generation of ids won't use another id that exists in the message if you have one defined for another component.
     */
    pub id: Option<i32>,
}

/**
 * @see {@link https://discord.com/developers/docs/components/reference#component-object-component-types}
 */
#[derive(Debug, Copy, Clone, Eq, PartialEq, Serialize_repr, Deserialize_repr)]
#[repr(u8)]
pub enum ComponentType {
    /**
     * Container to display a row of interactive components
     */
    ActionRow = 1,
    /**
     * Button component
     */
    Button = 2,
    /**
     * Select menu for picking from defined text options
     */
    StringSelect = 3,
    /**
     * Text Input component
     */
    TextInput = 4,
    /**
     * Select menu for users
     */
    UserSelect = 5,
    /**
     * Select menu for roles
     */
    RoleSelect = 6,
    /**
     * Select menu for users and roles
     */
    MentionableSelect = 7,
    /**
     * Select menu for channels
     */
    ChannelSelect = 8,
    /**
     * Container to display text alongside an accessory component
     */
    Section = 9,
    /**
     * Markdown text
     */
    TextDisplay = 10,
    /**
     * Small image that can be used as an accessory
     */
    Thumbnail = 11,
    /**
     * Display images and other media
     */
    MediaGallery = 12,
    /**
     * Displays an attached file
     */
    File = 13,
    /**
     * Component to add vertical padding between other components
     */
    Separator = 14,
    /**
     * @unstable This component type is currently not documented by Discord but has a known value which we will try to keep up to date.
     */
    ContentInventoryEntry = 16,
    /**
     * Container that visually groups a set of components
     */
    Container = 17,
}

/**
 * An Action Row is a top-level layout component used in messages and modals.
 *
 * @see {@link https://discord.com/developers/docs/components/reference#action-row}
 */
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct APIActionRowComponent<T> {
    /**
     * The type of the component
     */
    pub r#type: ComponentType,
    /**
     * 32 bit integer used as an optional identifier for component
     *
     * The id field is optional and is used to identify components in the response from an interaction that aren't interactive components. The id must be unique within the message and is generated sequentially if left empty. Generation of ids won't use another id that exists in the message if you have one defined for another component.
     */
    pub id: Option<i32>,
    /**
     * The components in the ActionRow
     */
    pub components: Vec<T>,
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct APIButtonBase<Style> {
    /**
     * The type of the component
     */
    pub r#type: ComponentType,
    /**
     * 32 bit integer used as an optional identifier for component
     *
     * The id field is optional and is used to identify components in the response from an interaction that aren't interactive components. The id must be unique within the message and is generated sequentially if left empty. Generation of ids won't use another id that exists in the message if you have one defined for another component.
     */
    pub id: Option<i32>,
    /**
     * The style of the button
     */
    pub style: Style,
    /**
     * The status of the button
     */
    pub disabled: Option<bool>,
}

/**
 * @see {@link https://discord.com/developers/docs/components/reference#button}
 */
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct APIButtonComponentBase<Style> {
    /**
     * The type of the component
     */
    pub r#type: ComponentType,
    /**
     * 32 bit integer used as an optional identifier for component
     *
     * The id field is optional and is used to identify components in the response from an interaction that aren't interactive components. The id must be unique within the message and is generated sequentially if left empty. Generation of ids won't use another id that exists in the message if you have one defined for another component.
     */
    pub id: Option<i32>,
    /**
     * The style of the button
     */
    pub style: Style,
    /**
     * The status of the button
     */
    pub disabled: Option<bool>,
    /**
     * The label to be displayed on the button
     */
    pub label: Option<String>,
    /**
     * The emoji to display to the left of the text
     */
    pub emoji: Option<APIMessageComponentEmoji>,
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct APIMessageComponentEmoji {
    /**
     * Emoji id
     */
    pub id: Option<String>,
    /**
     * Emoji name
     */
    pub name: Option<String>,
    /**
     * Whether this emoji is animated
     */
    pub animated: Option<bool>,
}

/**
 * @see {@link https://discord.com/developers/docs/components/reference#button}
 */
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct APIButtonComponentWithCustomId {
    /**
     * The type of the component
     */
    pub r#type: ComponentType,
    /**
     * 32 bit integer used as an optional identifier for component
     *
     * The id field is optional and is used to identify components in the response from an interaction that aren't interactive components. The id must be unique within the message and is generated sequentially if left empty. Generation of ids won't use another id that exists in the message if you have one defined for another component.
     */
    pub id: Option<i32>,
    /**
     * The style of the button
     */
    pub style: ButtonStyle,
    /**
     * The status of the button
     */
    pub disabled: Option<bool>,
    /**
     * The label to be displayed on the button
     */
    pub label: Option<String>,
    /**
     * The emoji to display to the left of the text
     */
    pub emoji: Option<APIMessageComponentEmoji>,
    /**
     * The custom_id to be sent in the interaction when clicked
     */
    pub custom_id: String,
}

/**
 * @see {@link https://discord.com/developers/docs/components/reference#button}
 */
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct APIButtonComponentWithURL {
    /**
     * The type of the component
     */
    pub r#type: ComponentType,
    /**
     * 32 bit integer used as an optional identifier for component
     *
     * The id field is optional and is used to identify components in the response from an interaction that aren't interactive components. The id must be unique within the message and is generated sequentially if left empty. Generation of ids won't use another id that exists in the message if you have one defined for another component.
     */
    pub id: Option<i32>,
    /**
     * The style of the button
     */
    pub style: ButtonStyle,
    /**
     * The status of the button
     */
    pub disabled: Option<bool>,
    /**
     * The label to be displayed on the button
     */
    pub label: Option<String>,
    /**
     * The emoji to display to the left of the text
     */
    pub emoji: Option<APIMessageComponentEmoji>,
    /**
     * The URL to direct users to when clicked for Link buttons
     */
    pub url: String,
}

/**
 * @see {@link https://discord.com/developers/docs/components/reference#button}
 */
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct APIButtonComponentWithSKUId {
    /**
     * The type of the component
     */
    pub r#type: ComponentType,
    /**
     * 32 bit integer used as an optional identifier for component
     *
     * The id field is optional and is used to identify components in the response from an interaction that aren't interactive components. The id must be unique within the message and is generated sequentially if left empty. Generation of ids won't use another id that exists in the message if you have one defined for another component.
     */
    pub id: Option<i32>,
    /**
     * The style of the button
     */
    pub style: ButtonStyle,
    /**
     * The status of the button
     */
    pub disabled: Option<bool>,
    /**
     * The id for a purchasable SKU
     */
    pub sku_id: String,
}

/**
 * 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.
 *
 * Buttons must be placed inside an Action Row or a Section's accessory field.
 *
 * @see {@link https://discord.com/developers/docs/components/reference#button}
 */
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(untagged)]
pub enum APIButtonComponent {
    APIButtonComponentWithCustomId(APIButtonComponentWithCustomId),
    APIButtonComponentWithSKUId(APIButtonComponentWithSKUId),
    APIButtonComponentWithURL(APIButtonComponentWithURL),
}

/**
 * @see {@link https://discord.com/developers/docs/components/reference#button-button-styles}
 */
#[derive(Debug, Copy, Clone, Eq, PartialEq, Serialize_repr, Deserialize_repr)]
#[repr(u8)]
pub enum ButtonStyle {
    /**
     * The most important or recommended action in a group of options
     */
    Primary = 1,
    /**
     * Alternative or supporting actions
     */
    Secondary = 2,
    /**
     * Positive confirmation or completion actions
     */
    Success = 3,
    /**
     * An action with irreversible consequences
     */
    Danger = 4,
    /**
     * Navigates to a URL
     */
    Link = 5,
    /**
     * Purchase
     */
    Premium = 6,
}

/**
 * @see {@link https://discord.com/developers/docs/components/reference#text-input-text-input-styles}
 */
#[derive(Debug, Copy, Clone, Eq, PartialEq, Serialize_repr, Deserialize_repr)]
#[repr(u8)]
pub enum TextInputStyle {
    /**
     * Single-line input
     */
    Short = 1,
    /**
     * Multi-line input
     */
    Paragraph = 2,
}

/**
 * @see {@link https://discord.com/developers/docs/components/reference}
 */
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct APIBaseSelectMenuComponent<T> {
    /**
     * A developer-defined identifier for the select menu, max 100 characters
     */
    pub custom_id: String,
    /**
     * Custom placeholder text if nothing is selected, max 150 characters
     */
    pub placeholder: Option<String>,
    /**
     * The minimum number of items that must be chosen; min 0, max 25
     *
     * @defaultValue `1`
     */
    pub min_values: Option<i64>,
    /**
     * The maximum number of items that can be chosen; max 25
     *
     * @defaultValue `1`
     */
    pub max_values: Option<i64>,
    /**
     * Disable the select
     *
     * @defaultValue `false`
     */
    pub disabled: Option<bool>,
    /**
     * The type of the component
     */
    pub r#type: T,
    /**
     * 32 bit integer used as an optional identifier for component
     *
     * The id field is optional and is used to identify components in the response from an interaction that aren't interactive components. The id must be unique within the message and is generated sequentially if left empty. Generation of ids won't use another id that exists in the message if you have one defined for another component.
     */
    pub id: Option<i32>,
}

/**
 * @see {@link https://discord.com/developers/docs/components/reference}
 */
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct APIBaseAutoPopulatedSelectMenuComponent<T, D> {
    /**
     * List of default values for auto-populated select menu components
     */
    pub default_values: Option<Vec<APISelectMenuDefaultValue<D>>>,
    /**
     * A developer-defined identifier for the select menu, max 100 characters
     */
    pub custom_id: String,
    /**
     * Custom placeholder text if nothing is selected, max 150 characters
     */
    pub placeholder: Option<String>,
    /**
     * The minimum number of items that must be chosen; min 0, max 25
     *
     * @defaultValue `1`
     */
    pub min_values: Option<i64>,
    /**
     * The maximum number of items that can be chosen; max 25
     *
     * @defaultValue `1`
     */
    pub max_values: Option<i64>,
    /**
     * Disable the select
     *
     * @defaultValue `false`
     */
    pub disabled: Option<bool>,
    /**
     * The type of the component
     */
    pub r#type: T,
    /**
     * 32 bit integer used as an optional identifier for component
     *
     * The id field is optional and is used to identify components in the response from an interaction that aren't interactive components. The id must be unique within the message and is generated sequentially if left empty. Generation of ids won't use another id that exists in the message if you have one defined for another component.
     */
    pub id: Option<i32>,
}

/**
 * A String Select is an interactive component that allows users to select one or more provided options in a message.
 *
 * 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.
 *
 * String Selects must be placed inside an Action Row and are only available in messages. An Action Row can contain only one select menu and cannot contain buttons if it has a select menu.
 *
 * @see {@link https://discord.com/developers/docs/components/reference#string-select}
 */
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct APIStringSelectComponent {
    /**
     * Specified choices in a select menu; max 25
     */
    pub options: Vec<APISelectMenuOption>,
    /**
     * A developer-defined identifier for the select menu, max 100 characters
     */
    pub custom_id: String,
    /**
     * Custom placeholder text if nothing is selected, max 150 characters
     */
    pub placeholder: Option<String>,
    /**
     * The minimum number of items that must be chosen; min 0, max 25
     *
     * @defaultValue `1`
     */
    pub min_values: Option<i64>,
    /**
     * The maximum number of items that can be chosen; max 25
     *
     * @defaultValue `1`
     */
    pub max_values: Option<i64>,
    /**
     * Disable the select
     *
     * @defaultValue `false`
     */
    pub disabled: Option<bool>,
    /**
     * The type of the component
     */
    pub r#type: ComponentType,
    /**
     * 32 bit integer used as an optional identifier for component
     *
     * The id field is optional and is used to identify components in the response from an interaction that aren't interactive components. The id must be unique within the message and is generated sequentially if left empty. Generation of ids won't use another id that exists in the message if you have one defined for another component.
     */
    pub id: Option<i32>,
}

/**
 * A User Select is an interactive component that allows users to select one or more users in a message. Options are automatically populated based on the server's available users.
 *
 * User 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.
 *
 * User Selects must be placed inside an Action Row and are only available in messages. An Action Row can contain only one select menu and cannot contain buttons if it has a select menu.
 *
 * @see {@link https://discord.com/developers/docs/components/reference#user-select}
 */
pub type APIUserSelectComponent =
    APIBaseAutoPopulatedSelectMenuComponent<ComponentType, SelectMenuDefaultValueType>;

/**
 * A Role Select is an interactive component that allows users to select one or more roles in a message. Options are automatically populated based on the server's available roles.
 *
 * Role 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.
 *
 * Role Selects must be placed inside an Action Row and are only available in messages. An Action Row can contain only one select menu and cannot contain buttons if it has a select menu.
 *
 * @see {@link https://discord.com/developers/docs/components/reference#role-select}
 */
pub type APIRoleSelectComponent =
    APIBaseAutoPopulatedSelectMenuComponent<ComponentType, SelectMenuDefaultValueType>;

/**
 * A Mentionable Select is an interactive component that allows users to select one or more mentionables in a message. Options are automatically populated based on available mentionables in the server.
 *
 * Mentionable 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.
 *
 * Mentionable Selects must be placed inside an Action Row and are only available in messages. An Action Row can contain only one select menu and cannot contain buttons if it has a select menu.
 *
 * @see {@link https://discord.com/developers/docs/components/reference#mentionable-select}
 */
pub type APIMentionableSelectComponent =
    APIBaseAutoPopulatedSelectMenuComponent<ComponentType, SelectMenuDefaultValueType>;

/**
 * A Channel Select is an interactive component that allows users to select one or more channels in a message. 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 must be placed inside an Action Row and are only available in messages. An Action Row can contain only one select menu and cannot contain buttons if it has a select menu.
 *
 * @see {@link https://discord.com/developers/docs/components/reference#channel-select}
 */
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct APIChannelSelectComponent {
    /**
     * List of channel types to include in the ChannelSelect component
     */
    pub channel_types: Option<Vec<ChannelType>>,
    /**
     * List of default values for auto-populated select menu components
     */
    pub default_values: Option<Vec<APISelectMenuDefaultValue<SelectMenuDefaultValueType>>>,
    /**
     * A developer-defined identifier for the select menu, max 100 characters
     */
    pub custom_id: String,
    /**
     * Custom placeholder text if nothing is selected, max 150 characters
     */
    pub placeholder: Option<String>,
    /**
     * The minimum number of items that must be chosen; min 0, max 25
     *
     * @defaultValue `1`
     */
    pub min_values: Option<i64>,
    /**
     * The maximum number of items that can be chosen; max 25
     *
     * @defaultValue `1`
     */
    pub max_values: Option<i64>,
    /**
     * Disable the select
     *
     * @defaultValue `false`
     */
    pub disabled: Option<bool>,
    /**
     * The type of the component
     */
    pub r#type: ComponentType,
    /**
     * 32 bit integer used as an optional identifier for component
     *
     * The id field is optional and is used to identify components in the response from an interaction that aren't interactive components. The id must be unique within the message and is generated sequentially if left empty. Generation of ids won't use another id that exists in the message if you have one defined for another component.
     */
    pub id: Option<i32>,
}

/**
 * @see {@link https://discord.com/developers/docs/components/reference#user-select-select-default-value-structure}
 */
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "lowercase")]
pub enum SelectMenuDefaultValueType {
    Channel,
    Role,
    User,
}

/**
 * @see {@link https://discord.com/developers/docs/components/reference#user-select-select-default-value-structure}
 */
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct APISelectMenuDefaultValue<T> {
    pub r#type: T,
    pub id: String,
}

/**
 * @see {@link https://discord.com/developers/docs/components/reference}
 */
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(untagged)]
pub enum APIAutoPopulatedSelectMenuComponent {
    APIChannelSelectComponent(APIChannelSelectComponent),
    APIMentionableSelectComponent(APIMentionableSelectComponent),
    APIRoleSelectComponent(APIRoleSelectComponent),
    APIUserSelectComponent(APIUserSelectComponent),
}

/**
 * @see {@link https://discord.com/developers/docs/components/reference}
 */
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(untagged)]
pub enum APISelectMenuComponent {
    APIChannelSelectComponent(APIChannelSelectComponent),
    APIMentionableSelectComponent(APIMentionableSelectComponent),
    APIRoleSelectComponent(APIRoleSelectComponent),
    APIStringSelectComponent(APIStringSelectComponent),
    APIUserSelectComponent(APIUserSelectComponent),
}

/**
 * @see {@link https://discord.com/developers/docs/components/reference#string-select-select-option-structure}
 */
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct APISelectMenuOption {
    /**
     * The user-facing name of the option (max 100 chars)
     */
    pub label: String,
    /**
     * The dev-defined value of the option (max 100 chars)
     */
    pub value: String,
    /**
     * An additional description of the option (max 100 chars)
     */
    pub description: Option<String>,
    /**
     * The emoji to display to the left of the option
     */
    pub emoji: Option<APIMessageComponentEmoji>,
    /**
     * Whether this option should be already-selected by default
     */
    pub default: Option<bool>,
}

/**
 * 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 an Action Row.
 *
 * When defining a text input component, you can set attributes to customize the behavior and appearance of it. However, not all attributes will be returned in the text input interaction payload.
 *
 * @see {@link https://discord.com/developers/docs/components/reference#text-input}
 */
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct APITextInputComponent {
    /**
     * One of text input styles
     */
    pub style: TextInputStyle,
    /**
     * The custom id for the text input
     */
    pub custom_id: String,
    /**
     * Text that appears on top of the text input field, max 45 characters
     */
    pub label: String,
    /**
     * Placeholder for the text input
     */
    pub placeholder: Option<String>,
    /**
     * The pre-filled text in the text input
     */
    pub value: Option<String>,
    /**
     * Minimal length of text input
     */
    pub min_length: Option<i64>,
    /**
     * Maximal length of text input
     */
    pub max_length: Option<i64>,
    /**
     * Whether or not this text input is required or not
     */
    pub required: Option<bool>,
    /**
     * The type of the component
     */
    pub r#type: ComponentType,
    /**
     * 32 bit integer used as an optional identifier for component
     *
     * The id field is optional and is used to identify components in the response from an interaction that aren't interactive components. The id must be unique within the message and is generated sequentially if left empty. Generation of ids won't use another id that exists in the message if you have one defined for another component.
     */
    pub id: Option<i32>,
}

#[derive(Debug, Copy, Clone, Eq, PartialEq, Serialize_repr, Deserialize_repr)]
#[repr(u8)]
pub enum UnfurledMediaItemLoadingState {
    Unknown = 0,
    Loading = 1,
    LoadedSuccess = 2,
    LoadedNotFound = 3,
}

/**
 * @see {@link https://discord.com/developers/docs/components/reference#unfurled-media-item-structure}
 */
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct APIUnfurledMediaItem {
    /**
     * Supports arbitrary urls and attachment://<filename> references
     */
    pub url: String,
    /**
     * The proxied url of the media item. This field is ignored and provided by the API as part of the response
     */
    pub proxy_url: Option<String>,
    /**
     * The width of the media item. This field is ignored and provided by the API as part of the response
     */
    pub width: Option<i64>,
    /**
     * The height of the media item. This field is ignored and provided by the API as part of the response
     */
    pub height: Option<i64>,
    pub placeholder: Option<String>,
    pub placeholder_version: Option<i64>,
    /**
     * The media type of the content. This field is ignored and provided by the API as part of the response
     *
     * @see {@link https://en.wikipedia.org/wiki/Media_type}
     */
    pub content_type: Option<String>,
    pub loading_state: Option<UnfurledMediaItemLoadingState>,
    pub flags: Option<i64>,
    /**
     * The id of the uploaded attachment. This field is ignored and provided by the API as part of the response
     */
    pub attachment_id: Option<String>,
}

/**
 * A Section is a top-level layout component that allows you to join text contextually with an accessory.
 *
 * Sections are only available in messages.
 *
 * @see {@link https://discord.com/developers/docs/components/reference#section}
 */
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct APISectionComponent {
    /**
     * One to three text components
     */
    pub components: Vec<APITextDisplayComponent>,
    /**
     * A thumbnail or a button component, with a future possibility of adding more compatible components
     */
    pub accessory: APISectionAccessoryComponent,
    /**
     * The type of the component
     */
    pub r#type: ComponentType,
    /**
     * 32 bit integer used as an optional identifier for component
     *
     * The id field is optional and is used to identify components in the response from an interaction that aren't interactive components. The id must be unique within the message and is generated sequentially if left empty. Generation of ids won't use another id that exists in the message if you have one defined for another component.
     */
    pub id: Option<i32>,
}

/**
 * A Text Display is a top-level content component that allows you to add text to your message formatted with markdown and mention users and roles. This is similar to the content field of a message, but allows you to add multiple text components, controlling the layout of your message.
 *
 * Text Displays are only available in messages.
 *
 * @see {@link https://discord.com/developers/docs/components/reference#text-display}
 */
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct APITextDisplayComponent {
    /**
     * Text that will be displayed similar to a message
     */
    pub content: String,
    /**
     * The type of the component
     */
    pub r#type: ComponentType,
    /**
     * 32 bit integer used as an optional identifier for component
     *
     * The id field is optional and is used to identify components in the response from an interaction that aren't interactive components. The id must be unique within the message and is generated sequentially if left empty. Generation of ids won't use another id that exists in the message if you have one defined for another component.
     */
    pub id: Option<i32>,
}

/**
 * A Thumbnail is a content component that is a small image only usable as an accessory in a section. The preview comes from an url or attachment through the unfurled media item structure.
 *
 * Thumbnails are only available in messages as an accessory in a section.
 *
 * @see {@link https://discord.com/developers/docs/components/reference#thumbnail}
 */
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct APIThumbnailComponent {
    /**
     * A url or attachment
     */
    pub media: APIUnfurledMediaItem,
    /**
     * Alt text for the media
     */
    pub description: Option<String>,
    /**
     * Whether the thumbnail should be a spoiler (or blurred out)
     *
     * @defaultValue `false`
     */
    pub spoiler: Option<bool>,
    /**
     * The type of the component
     */
    pub r#type: ComponentType,
    /**
     * 32 bit integer used as an optional identifier for component
     *
     * The id field is optional and is used to identify components in the response from an interaction that aren't interactive components. The id must be unique within the message and is generated sequentially if left empty. Generation of ids won't use another id that exists in the message if you have one defined for another component.
     */
    pub id: Option<i32>,
}

/**
 * @see {@link https://discord.com/developers/docs/components/reference#media-gallery-media-gallery-item-structure}
 */
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct APIMediaGalleryItem {
    /**
     * A url or attachment
     */
    pub media: APIUnfurledMediaItem,
    /**
     * Alt text for the media
     */
    pub description: Option<String>,
    /**
     * Whether the media should be a spoiler (or blurred out)
     *
     * @defaultValue `false`
     */
    pub spoiler: Option<bool>,
}

/**
 * A Media Gallery is a top-level content component that allows you to display 1-10 media attachments in an organized gallery format. Each item can have optional descriptions and can be marked as spoilers.
 *
 * Media Galleries are only available in messages.
 *
 * @see {@link https://discord.com/developers/docs/components/reference#media-gallery}
 */
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct APIMediaGalleryComponent {
    /**
     * 1 to 10 media gallery items
     */
    pub items: Vec<APIMediaGalleryItem>,
    /**
     * The type of the component
     */
    pub r#type: ComponentType,
    /**
     * 32 bit integer used as an optional identifier for component
     *
     * The id field is optional and is used to identify components in the response from an interaction that aren't interactive components. The id must be unique within the message and is generated sequentially if left empty. Generation of ids won't use another id that exists in the message if you have one defined for another component.
     */
    pub id: Option<i32>,
}

/**
 * A File is a top-level component that allows you to display an uploaded file as an attachment to the message and reference it in the component.
 *
 * Each file component can only display 1 attached file, but you can upload multiple files and add them to different file components within your payload.
 *
 * Files are only available in messages.
 *
 * @see {@link https://discord.com/developers/docs/components/reference#file}
 */
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct APIFileComponent {
    /**
     * This unfurled media item is unique in that it **only** support attachment references using the `attachment://<filename>` syntax
     */
    pub file: APIUnfurledMediaItem,

    /**
     * Whether the media should be a spoiler (or blurred out)
     *
     * @defaultValue `false`
     */
    pub spoiler: Option<bool>,
    /**
     * The type of the component
     */
    pub r#type: ComponentType,
    /**
     * 32 bit integer used as an optional identifier for component
     *
     * The id field is optional and is used to identify components in the response from an interaction that aren't interactive components. The id must be unique within the message and is generated sequentially if left empty. Generation of ids won't use another id that exists in the message if you have one defined for another component.
     */
    pub id: Option<i32>,
}

/**
 * @see {@link https://discord.com/developers/docs/components/reference#separator}
 */
#[derive(Debug, Copy, Clone, Eq, PartialEq, Serialize_repr, Deserialize_repr)]
#[repr(u8)]
pub enum SeparatorSpacingSize {
    Small = 1,
    Large = 2,
}

/**
 * A Separator is a top-level layout component that adds vertical padding and visual division between other components.
 *
 * Separators are only available in messages.
 *
 * @see {@link https://discord.com/developers/docs/components/reference#separator}
 */
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct APISeparatorComponent {
    /**
     * Whether a visual divider should be displayed in the component
     *
     * @defaultValue `true`
     */
    pub divider: Option<bool>,
    /**
     * Size of separator padding
     *
     * @defaultValue `SeparatorSpacingSize.Small`
     */
    pub spacing: Option<SeparatorSpacingSize>,
    /**
     * The type of the component
     */
    pub r#type: ComponentType,
    /**
     * 32 bit integer used as an optional identifier for component
     *
     * The id field is optional and is used to identify components in the response from an interaction that aren't interactive components. The id must be unique within the message and is generated sequentially if left empty. Generation of ids won't use another id that exists in the message if you have one defined for another component.
     */
    pub id: Option<i32>,
}

/**
 * A Container is a top-level layout component that holds up to 10 components. Containers are visually distinct from surrounding components and has an optional customizable color bar.
 *
 * Containers are only available in messages.
 *
 * @see {@link https://discord.com/developers/docs/components/reference#container}
 */
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct APIContainerComponent {
    /**
     * Color for the accent on the container as RGB from `0x000000` to `0xFFFFFF`
     */
    pub accent_color: Option<i64>,
    /**
     * Whether the container should be a spoiler (or blurred out)
     *
     * @defaultValue `false`
     */
    pub spoiler: Option<bool>,
    /**
     * Up to 10 components of the type action row, text display, section, media gallery, separator, or file
     */
    pub components: Vec<APIComponentInContainer>,
    /**
     * The type of the component
     */
    pub r#type: ComponentType,
    /**
     * 32 bit integer used as an optional identifier for component
     *
     * The id field is optional and is used to identify components in the response from an interaction that aren't interactive components. The id must be unique within the message and is generated sequentially if left empty. Generation of ids won't use another id that exists in the message if you have one defined for another component.
     */
    pub id: Option<i32>,
}

/**
 * @see {@link https://discord.com/developers/docs/resources/channel#message-snapshot-object}
 */
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct APIMessageSnapshot {
    /**
     * Subset of the message object fields
     */
    pub message: APIMessageSnapshotFields,
    /**
     * Id of the origin message's guild
     *
     * @deprecated This field doesn't accurately reflect the Discord API as it doesn't exist nor is documented and will
     * be removed in the next major version.
     *
     * It was added in {@link https://github.com/discord/discord-api-docs/pull/6833/commits/d18f72d06d62e6b1d51ca2c1ef308ddc29ff3348 | d18f72d}
     * but was later removed before the PR ({@link https://github.com/discord/discord-api-docs/pull/6833 | discord-api-docs#6833}) was merged.
     * @see {@link https://github.com/discordjs/discord-api-types/pull/1084 | discord-api-types#1084} for more information.
     */
    pub guild_id: Option<String>,
}

bitflags! {
    /**
    * @see {@link https://discord.com/developers/docs/resources/channel#channel-object-channel-flags}
    */
    #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
    pub struct ChannelFlags: u32 {
        /**
         * @unstable This channel flag is currently not documented by Discord but has a known value which we will try to keep up to date.
         */
        const GuildFeedRemoved = 1 << 0;
        /**
         * This thread is pinned to the top of its parent forum channel
         */
        const Pinned = 1 << 1;
        /**
         * @unstable This channel flag is currently not documented by Discord but has a known value which we will try to keep up to date.
         */
        const ActiveChannelsRemoved = 1 << 2;
        /**
         * Whether a tag is required to be specified when creating a thread in a forum channel.
         * Tags are specified in the `applied_tags` field
        */
        const RequireTag = 1 << 4;
        /**
         * @unstable This channel flag is currently not documented by Discord but has a known value which we will try to keep up to date.
         */
        const IsSpam = 1 << 5;
        /**
         * @unstable This channel flag is currently not documented by Discord but has a known value which we will try to keep up to date.
         */
        const IsGuildResourceChannel = 1 << 7;
        /**
         * @unstable This channel flag is currently not documented by Discord but has a known value which we will try to keep up to date.
         */
        const ClydeAI = 1 << 8;
        /**
         * @unstable This channel flag is currently not documented by Discord but has a known value which we will try to keep up to date.
         */
        const IsScheduledForDeletion = 1 << 9;
        /**
         * Whether media download options are hidden.
         */
        const HideMediaDownloadOptions = 1 << 15;
    }
}

/**
 * All components that can appear in messages.
 *
 * For more specific sets, see {@link APIMessageTopLevelComponent}, {@link APIComponentInMessageActionRow}, {@link APIComponentInContainer}, and {@link APISectionAccessoryComponent}
 *
 * @see {@link https://discord.com/developers/docs/components/reference}
 */
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(untagged)]
pub enum APIMessageComponent {
    APIActionRowComponent(APIActionRowComponent<APIComponentInMessageActionRow>),
    APIButtonComponent(APIButtonComponent),
    APIContainerComponent(APIContainerComponent),
    APIFileComponent(APIFileComponent),
    APIMediaGalleryComponent(APIMediaGalleryComponent),
    APISectionComponent(APISectionComponent),
    APISelectMenuComponent(APISelectMenuComponent),
    APISeparatorComponent(APISeparatorComponent),
    APITextDisplayComponent(APITextDisplayComponent),
    APIThumbnailComponent(APIThumbnailComponent),
}

/**
 * @see {@link https://discord.com/developers/docs/components/reference}
 */
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(untagged)]
pub enum APIMessageTopLevelComponent {
    APIActionRowComponent(APIActionRowComponent<APIComponentInMessageActionRow>),
    APIContainerComponent(APIContainerComponent),
    APIFileComponent(APIFileComponent),
    APIMediaGalleryComponent(APIMediaGalleryComponent),
    APISectionComponent(APISectionComponent),
    APISeparatorComponent(APISeparatorComponent),
    APITextDisplayComponent(APITextDisplayComponent),
}

/**
 * @see {@link https://discord.com/developers/docs/components/reference}
 */
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(untagged)]
pub enum APIModalComponent {
    APIActionRowComponent(APIActionRowComponent<APIComponentInModalActionRow>),
    APIComponentInModalActionRow(APIComponentInModalActionRow),
}

/**
 * @see {@link https://discord.com/developers/docs/components/reference#action-row}
 */
pub type APIComponentInActionRow = APIComponentInMessageActionRow;

/**
 * @see {@link https://discord.com/developers/docs/components/reference#action-row}
 */
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(untagged)]
pub enum APIComponentInMessageActionRow {
    APIButtonComponent(APIButtonComponent),
    APISelectMenuComponent(APISelectMenuComponent),
}

/**
 * @see {@link https://discord.com/developers/docs/components/reference#action-row}
 */
pub type APIComponentInModalActionRow = APITextInputComponent;

/**
 * @see {@link https://discord.com/developers/docs/components/reference#section}
 */
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(untagged)]
pub enum APISectionAccessoryComponent {
    APIButtonComponent(APIButtonComponent),
    APIThumbnailComponent(APIThumbnailComponent),
}

/**
 * @see {@link https://discord.com/developers/docs/components/reference#container}
 */
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(untagged)]
pub enum APIComponentInContainer {
    APIActionRowComponent(APIActionRowComponent<APIComponentInMessageActionRow>),
    APIFileComponent(APIFileComponent),
    APIMediaGalleryComponent(APIMediaGalleryComponent),
    APISectionComponent(APISectionComponent),
    APISeparatorComponent(APISeparatorComponent),
    APITextDisplayComponent(APITextDisplayComponent),
}

/**
 * https://discord.com/developers/docs/resources/message#message-snapshot-object
 */
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct APIMessageSnapshotFields {
    pub attachments: Vec<APIAttachment>,
    pub components: Option<Vec<APIMessageTopLevelComponent>>,
    pub content: String,
    pub edited_timestamp: Option<String>,
    pub embeds: Vec<APIEmbed>,
    pub flags: MessageFlags,
    pub mention_roles: Vec<APIRole>,
    pub mentions: Vec<APIUser>,
    pub sticker_items: Option<Vec<APIStickerItem>>,
    pub stickers: Option<Vec<APISticker>>,
    pub timestamp: String,
    pub r#type: MessageType,
}

/**
 * @see {@link https://discord.com/developers/docs/resources/message#message-pin-object}
 */
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct APIMessagePin {
    /**
     * The time the message was pinned
     */
    pub pinned_at: String,
    /**
     * The pinned message
     */
    pub message: APIMessage,
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct APIRoleId {
    pub id: String,
}