1use percent_encoding::{NON_ALPHANUMERIC, utf8_percent_encode};
2
3use crate::{
4 query_formatter::{QueryCsvArray, QueryStringFormatter},
5 request::{Method, channel::reaction::RequestReactionType},
6};
7use std::fmt::{Display, Formatter, Result as FmtResult};
8use twilight_model::{
9 http::message_search::{
10 AuthorType, SearchEmbedType, SearchFilter, SearchHasType, SearchSortMode, SearchSortOrder,
11 },
12 id::{
13 Id,
14 marker::{ChannelMarker, MessageMarker, RoleMarker, SkuMarker, UserMarker},
15 },
16};
17
18#[derive(Clone, Debug, Eq, Hash, PartialEq)]
19#[non_exhaustive]
20pub enum Route<'a> {
21 AddApplicationEmoji {
23 application_id: u64,
25 },
26 AddGuildMember {
28 guild_id: u64,
29 user_id: u64,
30 },
31 AddMemberRole {
33 guild_id: u64,
35 role_id: u64,
37 user_id: u64,
39 },
40 AddThreadMember {
42 channel_id: u64,
44 user_id: u64,
46 },
47 BulkGuildBan {
49 guild_id: u64,
50 },
51 ConsumeEntitlement {
54 application_id: u64,
56 entitlement_id: u64,
58 },
59 CreateAutoModerationRule {
61 guild_id: u64,
63 },
64 CreateBan {
66 guild_id: u64,
68 user_id: u64,
70 },
71 CreateChannel {
73 guild_id: u64,
75 },
76 CreateEmoji {
78 guild_id: u64,
80 },
81 CreateForumThread {
83 channel_id: u64,
85 },
86 CreateGlobalCommand {
88 application_id: u64,
90 },
91 CreateGuild,
93 CreateGuildCommand {
95 application_id: u64,
97 guild_id: u64,
99 },
100 CreateGuildFromTemplate {
102 template_code: &'a str,
104 },
105 CreateGuildIntegration {
107 guild_id: u64,
109 },
110 CreateGuildPrune {
112 compute_prune_count: Option<bool>,
114 days: Option<u16>,
117 guild_id: u64,
119 include_roles: &'a [Id<RoleMarker>],
124 },
125 CreateGuildScheduledEvent {
127 guild_id: u64,
129 },
130 CreateGuildSticker {
132 guild_id: u64,
134 },
135 CreateInvite {
137 channel_id: u64,
139 },
140 CreateMessage {
142 channel_id: u64,
144 },
145 CreatePrivateChannel,
147 CreateReaction {
149 channel_id: u64,
151 emoji: &'a RequestReactionType<'a>,
153 message_id: u64,
155 },
156 CreateRole {
158 guild_id: u64,
160 },
161 CreateStageInstance,
163 CreateTemplate {
165 guild_id: u64,
167 },
168 CreateTestEntitlement {
169 application_id: u64,
171 },
172 CreateThread {
174 channel_id: u64,
176 },
177 CreateThreadFromMessage {
179 channel_id: u64,
181 message_id: u64,
183 },
184 CreateTypingTrigger {
186 channel_id: u64,
188 },
189 CreateWebhook {
191 channel_id: u64,
193 },
194 CrosspostMessage {
196 channel_id: u64,
198 message_id: u64,
200 },
201 DeleteApplicationEmoji {
203 application_id: u64,
205 emoji_id: u64,
207 },
208 DeleteAutoModerationRule {
210 guild_id: u64,
212 auto_moderation_rule_id: u64,
214 },
215 DeleteBan {
217 guild_id: u64,
219 user_id: u64,
221 },
222 DeleteChannel {
224 channel_id: u64,
226 },
227 DeleteEmoji {
229 emoji_id: u64,
231 guild_id: u64,
233 },
234 DeleteGlobalCommand {
236 application_id: u64,
238 command_id: u64,
240 },
241 DeleteGuild {
243 guild_id: u64,
245 },
246 DeleteGuildCommand {
248 application_id: u64,
250 command_id: u64,
252 guild_id: u64,
254 },
255 DeleteGuildIntegration {
257 guild_id: u64,
259 integration_id: u64,
261 },
262 DeleteGuildScheduledEvent {
264 guild_id: u64,
266 scheduled_event_id: u64,
268 },
269 DeleteGuildSticker {
271 guild_id: u64,
273 sticker_id: u64,
275 },
276 DeleteInteractionOriginal {
278 application_id: u64,
280 interaction_token: &'a str,
282 },
283 DeleteInvite {
285 code: &'a str,
287 },
288 DeleteMessage {
290 channel_id: u64,
292 message_id: u64,
294 },
295 DeleteMessageReactions {
297 channel_id: u64,
299 message_id: u64,
301 },
302 DeleteMessageSpecificReaction {
305 channel_id: u64,
307 emoji: &'a RequestReactionType<'a>,
309 message_id: u64,
311 },
312 DeleteMessages {
314 channel_id: u64,
316 },
317 DeletePermissionOverwrite {
320 channel_id: u64,
322 target_id: u64,
324 },
325 DeleteReaction {
327 channel_id: u64,
329 emoji: &'a RequestReactionType<'a>,
331 message_id: u64,
333 user_id: u64,
335 },
336 DeleteReactionCurrentUser {
338 channel_id: u64,
340 emoji: &'a RequestReactionType<'a>,
342 message_id: u64,
344 },
345 DeleteRole {
347 guild_id: u64,
349 role_id: u64,
351 },
352 DeleteStageInstance {
354 channel_id: u64,
356 },
357 DeleteTemplate {
359 guild_id: u64,
361 template_code: &'a str,
363 },
364 DeleteWebhook {
366 token: Option<&'a str>,
368 webhook_id: u64,
370 },
371 DeleteWebhookMessage {
373 message_id: u64,
374 thread_id: Option<u64>,
376 token: &'a str,
377 webhook_id: u64,
378 },
379 DeleteTestEntitlement {
381 application_id: u64,
383 entitlement_id: u64,
385 },
386 UpdateApplicationEmoji {
388 application_id: u64,
390 emoji_id: u64,
392 },
393 EndPoll {
395 channel_id: u64,
396 message_id: u64,
397 },
398 ExecuteWebhook {
400 thread_id: Option<u64>,
402 token: &'a str,
404 wait: Option<bool>,
406 with_components: Option<bool>,
408 webhook_id: u64,
410 },
411 FollowNewsChannel {
413 channel_id: u64,
415 },
416 GetActiveThreads {
418 guild_id: u64,
420 },
421 GetApplicationEmojis {
422 application_id: u64,
424 },
425 GetAnswerVoters {
427 after: Option<u64>,
429 answer_id: u8,
431 channel_id: u64,
433 limit: Option<u8>,
435 message_id: u64,
437 },
438 GetAuditLogs {
440 action_type: Option<u64>,
442 after: Option<u64>,
444 before: Option<u64>,
446 guild_id: u64,
448 limit: Option<u16>,
450 user_id: Option<u64>,
452 },
453 GetAutoModerationRule {
455 guild_id: u64,
457 auto_moderation_rule_id: u64,
459 },
460 GetBan {
462 guild_id: u64,
464 user_id: u64,
466 },
467 GetBans {
469 guild_id: u64,
471 },
472 GetBansWithParameters {
474 after: Option<u64>,
476 before: Option<u64>,
478 limit: Option<u16>,
480 guild_id: u64,
482 },
483 GetChannel {
485 channel_id: u64,
487 },
488 GetChannelInvites {
490 channel_id: u64,
492 },
493 GetChannelMemberPermissions {
495 channel_id: u64,
497 implicit: Option<bool>,
499 user_id: u64,
501 },
502 GetChannelRolePermissions {
504 channel_id: u64,
506 implicit: Option<bool>,
508 role_id: u64,
510 },
511 GetChannelWebhooks {
513 channel_id: u64,
515 },
516 GetChannels {
518 guild_id: u64,
520 },
521 GetCommandPermissions {
523 application_id: u64,
525 command_id: u64,
527 guild_id: u64,
529 },
530 GetCurrentAuthorizationInformation,
532 GetCurrentUser,
534 GetCurrentUserApplicationInfo,
536 GetCurrentUserGuildMember {
538 guild_id: u64,
540 },
541 GetCurrentUserVoiceState {
543 guild_id: u64,
545 },
546 GetEmoji {
548 emoji_id: u64,
550 guild_id: u64,
552 },
553 GetEmojis {
555 guild_id: u64,
557 },
558 GetEntitlements {
559 after: Option<u64>,
561 application_id: u64,
563 before: Option<u64>,
565 exclude_deleted: Option<bool>,
567 exclude_ended: Option<bool>,
569 guild_id: Option<u64>,
571 limit: Option<u8>,
573 sku_ids: &'a [Id<SkuMarker>],
575 user_id: Option<u64>,
577 },
578 GetEntitlement {
579 application_id: u64,
581 entitlement_id: u64,
583 },
584 GetFollowupMessage {
586 application_id: u64,
588 interaction_token: &'a str,
590 thread_id: Option<u64>,
592 message_id: u64,
594 },
595 GetGateway,
597 GetGatewayBot,
600 GetGlobalCommand {
602 application_id: u64,
604 command_id: u64,
606 },
607 GetGlobalCommands {
608 application_id: u64,
610 with_localizations: Option<bool>,
612 },
613 GetGuild {
615 guild_id: u64,
617 with_counts: bool,
620 },
621 GetGuildAutoModerationRules {
623 guild_id: u64,
625 },
626 GetGuildCommand {
628 application_id: u64,
630 command_id: u64,
632 guild_id: u64,
634 },
635 GetGuildCommandPermissions {
637 application_id: u64,
639 guild_id: u64,
641 },
642 GetGuildCommands {
644 application_id: u64,
646 guild_id: u64,
648 with_localizations: Option<bool>,
650 },
651 GetGuildIntegrations {
653 guild_id: u64,
655 },
656 GetGuildInvites {
658 guild_id: u64,
660 },
661 GetGuildMemberPermissions {
663 guild_id: u64,
665 user_id: u64,
667 },
668 GetGuildMembers {
670 after: Option<u64>,
672 guild_id: u64,
674 limit: Option<u16>,
676 },
677 GetGuildOnboarding {
679 guild_id: u64,
681 },
682 GetGuildPreview {
684 guild_id: u64,
686 },
687 GetGuildPruneCount {
690 days: Option<u16>,
693 guild_id: u64,
695 include_roles: &'a [Id<RoleMarker>],
700 },
701 GetGuildRoleMemberCounts {
703 guild_id: u64,
704 },
705 GetGuildRolePermissions {
707 guild_id: u64,
709 role_id: u64,
711 },
712 GetGuildRoles {
714 guild_id: u64,
716 },
717 GetGuildScheduledEvent {
719 guild_id: u64,
721 scheduled_event_id: u64,
723 with_user_count: bool,
725 },
726 GetGuildScheduledEventUsers {
728 after: Option<u64>,
730 before: Option<u64>,
732 guild_id: u64,
734 limit: Option<u16>,
736 scheduled_event_id: u64,
738 with_member: bool,
740 },
741 GetGuildScheduledEvents {
743 guild_id: u64,
745 with_user_count: bool,
747 },
748 GetGuildSticker {
750 guild_id: u64,
752 sticker_id: u64,
754 },
755 GetGuildStickers {
757 guild_id: u64,
759 },
760 GetGuildVanityUrl {
762 guild_id: u64,
764 },
765 GetGuildVoiceRegions {
767 guild_id: u64,
769 },
770 GetGuildWebhooks {
772 guild_id: u64,
774 },
775 GetGuildWelcomeScreen {
777 guild_id: u64,
779 },
780 GetGuildWidget {
782 guild_id: u64,
784 },
785 GetGuildWidgetSettings {
787 guild_id: u64,
789 },
790 GetGuilds {
795 after: Option<u64>,
797 before: Option<u64>,
799 limit: Option<u16>,
801 shard: Option<u64>,
807 },
808 GetInteractionOriginal {
810 application_id: u64,
812 interaction_token: &'a str,
814 },
815 GetInvite {
817 code: &'a str,
819 with_counts: bool,
821 },
822 GetInviteWithExpiration {
824 code: &'a str,
826 with_counts: bool,
828 with_expiration: bool,
830 },
831 GetJoinedPrivateArchivedThreads {
833 before: Option<u64>,
835 channel_id: u64,
837 limit: Option<u64>,
839 },
840 GetMember {
842 guild_id: u64,
844 user_id: u64,
846 },
847 GetMessage {
849 channel_id: u64,
851 message_id: u64,
853 },
854 GetMessages {
856 after: Option<u64>,
858 around: Option<u64>,
860 before: Option<u64>,
862 channel_id: u64,
864 limit: Option<u16>,
866 },
867 GetNitroStickerPacks,
870 GetPins {
872 channel_id: u64,
874 limit: Option<u16>,
876 before: Option<String>,
878 },
879 GetPrivateArchivedThreads {
881 before: Option<&'a str>,
883 channel_id: u64,
885 limit: Option<u64>,
887 },
888 GetPublicArchivedThreads {
890 before: Option<&'a str>,
892 channel_id: u64,
894 limit: Option<u64>,
896 },
897 GetReactionUsers {
900 after: Option<u64>,
902 channel_id: u64,
904 emoji: &'a RequestReactionType<'a>,
906 limit: Option<u16>,
908 message_id: u64,
910 kind: Option<u8>,
912 },
913 GetRole {
915 guild_id: u64,
917 role_id: u64,
919 },
920 GetSKUs {
921 application_id: u64,
923 },
924 GetSKUSubscriptions {
925 after: Option<u64>,
927 before: Option<u64>,
929 limit: Option<u64>,
931 sku_id: u64,
933 user_id: Option<u64>,
935 },
936 GetSKUSubscription {
937 sku_id: u64,
939 subscription_id: u64,
941 },
942 GetStageInstance {
944 channel_id: u64,
946 },
947 GetStickerPack {
949 sticker_pack_id: u64,
951 },
952 GetSticker {
954 sticker_id: u64,
956 },
957 GetTemplate {
959 template_code: &'a str,
961 },
962 GetTemplates {
964 guild_id: u64,
966 },
967 GetThreadMember {
969 channel_id: u64,
971 user_id: u64,
973 },
974 GetThreadMembers {
976 after: Option<u64>,
978 channel_id: u64,
980 limit: Option<u32>,
984 with_member: Option<bool>,
986 },
987 GetUser {
989 user_id: u64,
991 },
992 GetUserConnections,
994 GetUserPrivateChannels,
996 GetUserVoiceState {
998 guild_id: u64,
1000 user_id: u64,
1002 },
1003 GetVoiceRegions,
1005 GetWebhook {
1008 token: Option<&'a str>,
1010 webhook_id: u64,
1012 },
1013 GetWebhookMessage {
1015 message_id: u64,
1017 thread_id: Option<u64>,
1019 token: &'a str,
1021 webhook_id: u64,
1023 },
1024 InteractionCallback {
1026 interaction_id: u64,
1028 interaction_token: &'a str,
1030 with_response: bool,
1032 },
1033 JoinThread {
1035 channel_id: u64,
1037 },
1038 LeaveGuild {
1040 guild_id: u64,
1042 },
1043 LeaveThread {
1045 channel_id: u64,
1047 },
1048 PinMessage {
1050 channel_id: u64,
1052 message_id: u64,
1054 },
1055 RemoveMember {
1057 guild_id: u64,
1059 user_id: u64,
1061 },
1062 RemoveMemberRole {
1064 guild_id: u64,
1066 role_id: u64,
1068 user_id: u64,
1070 },
1071 RemoveThreadMember {
1073 channel_id: u64,
1075 user_id: u64,
1077 },
1078 SearchGuildMembers {
1080 guild_id: u64,
1082 limit: Option<u16>,
1084 query: &'a str,
1086 },
1087 SearchGuildMessages {
1089 attachment_extension: Option<&'a [&'a str]>,
1091 attachment_filename: Option<&'a [&'a str]>,
1093 author_id: Option<&'a [Id<UserMarker>]>,
1095 author_type: Option<&'a [SearchFilter<AuthorType>]>,
1097 channel_id: Option<&'a [Id<ChannelMarker>]>,
1099 content: Option<&'a str>,
1101 embed_provider: Option<&'a [&'a str]>,
1103 embed_type: Option<&'a [SearchEmbedType]>,
1105 guild_id: u64,
1107 has: Option<&'a [SearchFilter<SearchHasType>]>,
1109 include_nsfw: Option<bool>,
1111 limit: Option<u8>,
1113 link_hostname: Option<&'a [&'a str]>,
1115 max_id: Option<u64>,
1117 mention_everyone: Option<bool>,
1119 mentions: Option<&'a [Id<UserMarker>]>,
1121 mentions_role_id: Option<&'a [Id<RoleMarker>]>,
1123 min_id: Option<u64>,
1125 offset: Option<u16>,
1127 pinned: Option<bool>,
1129 replied_to_message_id: Option<&'a [Id<MessageMarker>]>,
1131 replied_to_user_id: Option<&'a [Id<UserMarker>]>,
1133 slop: Option<u16>,
1136 sort_by: Option<SearchSortMode>,
1138 sort_order: Option<SearchSortOrder>,
1140 },
1141 SetGlobalCommands {
1143 application_id: u64,
1145 },
1146 SetGuildCommands {
1148 application_id: u64,
1150 guild_id: u64,
1152 },
1153 SyncGuildIntegration {
1155 guild_id: u64,
1157 integration_id: u64,
1159 },
1160 SyncTemplate {
1162 guild_id: u64,
1164 template_code: &'a str,
1166 },
1167 UnpinMessage {
1169 channel_id: u64,
1171 message_id: u64,
1173 },
1174 UpdateAutoModerationRule {
1176 auto_moderation_rule_id: u64,
1178 guild_id: u64,
1180 },
1181 UpdateChannel {
1183 channel_id: u64,
1185 },
1186 UpdateCommandPermissions {
1188 application_id: u64,
1190 command_id: u64,
1192 guild_id: u64,
1194 },
1195 UpdateCurrentMember {
1197 guild_id: u64,
1199 },
1200 UpdateCurrentUser,
1202 UpdateCurrentUserVoiceState {
1204 guild_id: u64,
1206 },
1207 UpdateEmoji {
1209 emoji_id: u64,
1211 guild_id: u64,
1213 },
1214 UpdateGlobalCommand {
1216 application_id: u64,
1218 command_id: u64,
1220 },
1221 UpdateGuild {
1223 guild_id: u64,
1225 },
1226 UpdateGuildChannels {
1228 guild_id: u64,
1230 },
1231 UpdateGuildCommand {
1233 application_id: u64,
1235 command_id: u64,
1237 guild_id: u64,
1239 },
1240 UpdateGuildIntegration {
1242 guild_id: u64,
1244 integration_id: u64,
1246 },
1247 UpdateGuildMfa {
1249 guild_id: u64,
1251 },
1252 UpdateGuildOnboarding {
1253 guild_id: u64,
1255 },
1256 UpdateGuildScheduledEvent {
1258 guild_id: u64,
1260 scheduled_event_id: u64,
1262 },
1263 UpdateGuildSticker {
1265 guild_id: u64,
1267 sticker_id: u64,
1269 },
1270 UpdateGuildWelcomeScreen {
1272 guild_id: u64,
1274 },
1275 UpdateGuildWidgetSettings {
1277 guild_id: u64,
1279 },
1280 UpdateInteractionOriginal {
1282 application_id: u64,
1284 interaction_token: &'a str,
1286 },
1287 UpdateMember {
1289 guild_id: u64,
1291 user_id: u64,
1293 },
1294 UpdateMessage {
1296 channel_id: u64,
1298 message_id: u64,
1300 },
1301 UpdateNickname {
1303 guild_id: u64,
1305 },
1306 UpdatePermissionOverwrite {
1309 channel_id: u64,
1311 target_id: u64,
1313 },
1314 UpdateRole {
1316 guild_id: u64,
1318 role_id: u64,
1320 },
1321 UpdateRolePositions {
1323 guild_id: u64,
1325 },
1326 UpdateStageInstance {
1328 channel_id: u64,
1330 },
1331 UpdateTemplate {
1333 guild_id: u64,
1335 template_code: &'a str,
1337 },
1338 UpdateUserVoiceState {
1340 guild_id: u64,
1342 user_id: u64,
1344 },
1345 UpdateWebhook {
1347 token: Option<&'a str>,
1349 webhook_id: u64,
1351 },
1352 UpdateWebhookMessage {
1354 message_id: u64,
1355 thread_id: Option<u64>,
1357 token: &'a str,
1358 webhook_id: u64,
1359 },
1360 UpdateCurrentUserApplication,
1361}
1362
1363impl Route<'_> {
1364 #[allow(clippy::too_many_lines)]
1383 pub const fn method(&self) -> Method {
1384 match self {
1385 Self::DeleteAutoModerationRule { .. }
1386 | Self::DeleteApplicationEmoji { .. }
1387 | Self::DeleteBan { .. }
1388 | Self::DeleteChannel { .. }
1389 | Self::DeleteEmoji { .. }
1390 | Self::DeleteGlobalCommand { .. }
1391 | Self::DeleteGuild { .. }
1392 | Self::DeleteGuildCommand { .. }
1393 | Self::DeleteGuildIntegration { .. }
1394 | Self::DeleteGuildScheduledEvent { .. }
1395 | Self::DeleteGuildSticker { .. }
1396 | Self::DeleteTestEntitlement { .. }
1397 | Self::DeleteInteractionOriginal { .. }
1398 | Self::DeleteInvite { .. }
1399 | Self::DeleteMessageReactions { .. }
1400 | Self::DeleteMessageSpecificReaction { .. }
1401 | Self::DeleteMessage { .. }
1402 | Self::DeletePermissionOverwrite { .. }
1403 | Self::DeleteReactionCurrentUser { .. }
1404 | Self::DeleteReaction { .. }
1405 | Self::DeleteRole { .. }
1406 | Self::DeleteStageInstance { .. }
1407 | Self::DeleteTemplate { .. }
1408 | Self::DeleteWebhookMessage { .. }
1409 | Self::DeleteWebhook { .. }
1410 | Self::LeaveGuild { .. }
1411 | Self::LeaveThread { .. }
1412 | Self::RemoveMember { .. }
1413 | Self::RemoveMemberRole { .. }
1414 | Self::RemoveThreadMember { .. }
1415 | Self::UnpinMessage { .. } => Method::Delete,
1416 Self::GetActiveThreads { .. }
1417 | Self::GetApplicationEmojis { .. }
1418 | Self::GetAnswerVoters { .. }
1419 | Self::GetAuditLogs { .. }
1420 | Self::GetAutoModerationRule { .. }
1421 | Self::GetBan { .. }
1422 | Self::GetBans { .. }
1423 | Self::GetBansWithParameters { .. }
1424 | Self::GetGatewayBot
1425 | Self::GetChannel { .. }
1426 | Self::GetChannelInvites { .. }
1427 | Self::GetChannelMemberPermissions { .. }
1428 | Self::GetChannelRolePermissions { .. }
1429 | Self::GetChannelWebhooks { .. }
1430 | Self::GetChannels { .. }
1431 | Self::GetCommandPermissions { .. }
1432 | Self::GetCurrentAuthorizationInformation
1433 | Self::GetCurrentUserApplicationInfo
1434 | Self::GetCurrentUser
1435 | Self::GetCurrentUserGuildMember { .. }
1436 | Self::GetCurrentUserVoiceState { .. }
1437 | Self::GetEmoji { .. }
1438 | Self::GetEmojis { .. }
1439 | Self::GetEntitlements { .. }
1440 | Self::GetEntitlement { .. }
1441 | Self::GetGateway
1442 | Self::GetFollowupMessage { .. }
1443 | Self::GetGlobalCommand { .. }
1444 | Self::GetGlobalCommands { .. }
1445 | Self::GetGuild { .. }
1446 | Self::GetGuildAutoModerationRules { .. }
1447 | Self::GetGuildCommand { .. }
1448 | Self::GetGuildCommandPermissions { .. }
1449 | Self::GetGuildCommands { .. }
1450 | Self::GetGuildIntegrations { .. }
1451 | Self::GetGuildInvites { .. }
1452 | Self::GetGuildMemberPermissions { .. }
1453 | Self::GetGuildMembers { .. }
1454 | Self::GetGuildOnboarding { .. }
1455 | Self::GetGuildPreview { .. }
1456 | Self::GetGuildPruneCount { .. }
1457 | Self::GetGuildRolePermissions { .. }
1458 | Self::GetGuildRoles { .. }
1459 | Self::GetGuildRoleMemberCounts { .. }
1460 | Self::GetGuildScheduledEvent { .. }
1461 | Self::GetGuildScheduledEventUsers { .. }
1462 | Self::GetGuildScheduledEvents { .. }
1463 | Self::GetGuildSticker { .. }
1464 | Self::GetGuildStickers { .. }
1465 | Self::GetGuildVanityUrl { .. }
1466 | Self::GetGuildVoiceRegions { .. }
1467 | Self::GetGuildWelcomeScreen { .. }
1468 | Self::GetGuildWebhooks { .. }
1469 | Self::GetGuildWidget { .. }
1470 | Self::GetGuildWidgetSettings { .. }
1471 | Self::GetGuilds { .. }
1472 | Self::GetInteractionOriginal { .. }
1473 | Self::GetInvite { .. }
1474 | Self::GetInviteWithExpiration { .. }
1475 | Self::GetMember { .. }
1476 | Self::GetMessage { .. }
1477 | Self::GetMessages { .. }
1478 | Self::GetNitroStickerPacks { .. }
1479 | Self::GetPins { .. }
1480 | Self::GetJoinedPrivateArchivedThreads { .. }
1481 | Self::GetPrivateArchivedThreads { .. }
1482 | Self::GetPublicArchivedThreads { .. }
1483 | Self::GetReactionUsers { .. }
1484 | Self::GetRole { .. }
1485 | Self::GetSKUs { .. }
1486 | Self::GetSKUSubscriptions { .. }
1487 | Self::GetSKUSubscription { .. }
1488 | Self::GetStageInstance { .. }
1489 | Self::GetStickerPack { .. }
1490 | Self::GetSticker { .. }
1491 | Self::GetTemplate { .. }
1492 | Self::GetTemplates { .. }
1493 | Self::GetThreadMember { .. }
1494 | Self::GetThreadMembers { .. }
1495 | Self::GetUser { .. }
1496 | Self::GetUserConnections
1497 | Self::GetUserPrivateChannels
1498 | Self::GetUserVoiceState { .. }
1499 | Self::GetVoiceRegions
1500 | Self::GetWebhook { .. }
1501 | Self::GetWebhookMessage { .. }
1502 | Self::SearchGuildMembers { .. }
1503 | Self::SearchGuildMessages { .. } => Method::Get,
1504 Self::UpdateAutoModerationRule { .. }
1505 | Self::UpdateChannel { .. }
1506 | Self::UpdateCurrentMember { .. }
1507 | Self::UpdateCurrentUser
1508 | Self::UpdateCurrentUserVoiceState { .. }
1509 | Self::UpdateEmoji { .. }
1510 | Self::UpdateGlobalCommand { .. }
1511 | Self::UpdateGuild { .. }
1512 | Self::UpdateGuildChannels { .. }
1513 | Self::UpdateGuildCommand { .. }
1514 | Self::UpdateGuildMfa { .. }
1515 | Self::UpdateGuildWidgetSettings { .. }
1516 | Self::UpdateGuildIntegration { .. }
1517 | Self::UpdateGuildScheduledEvent { .. }
1518 | Self::UpdateGuildSticker { .. }
1519 | Self::UpdateGuildWelcomeScreen { .. }
1520 | Self::UpdateInteractionOriginal { .. }
1521 | Self::UpdateMember { .. }
1522 | Self::UpdateMessage { .. }
1523 | Self::UpdateNickname { .. }
1524 | Self::UpdateRole { .. }
1525 | Self::UpdateRolePositions { .. }
1526 | Self::UpdateStageInstance { .. }
1527 | Self::UpdateTemplate { .. }
1528 | Self::UpdateUserVoiceState { .. }
1529 | Self::UpdateWebhookMessage { .. }
1530 | Self::UpdateCurrentUserApplication
1531 | Self::UpdateApplicationEmoji { .. }
1532 | Self::UpdateWebhook { .. } => Method::Patch,
1533 Self::CreateChannel { .. }
1534 | Self::AddApplicationEmoji { .. }
1535 | Self::BulkGuildBan { .. }
1536 | Self::ConsumeEntitlement { .. }
1537 | Self::CreateGlobalCommand { .. }
1538 | Self::CreateGuildCommand { .. }
1539 | Self::CreateEmoji { .. }
1540 | Self::CreateForumThread { .. }
1541 | Self::CreateGuild
1542 | Self::CreateAutoModerationRule { .. }
1543 | Self::CreateGuildFromTemplate { .. }
1544 | Self::CreateGuildIntegration { .. }
1545 | Self::CreateGuildPrune { .. }
1546 | Self::CreateGuildScheduledEvent { .. }
1547 | Self::CreateGuildSticker { .. }
1548 | Self::CreateInvite { .. }
1549 | Self::CreateMessage { .. }
1550 | Self::CreatePrivateChannel
1551 | Self::CreateThread { .. }
1552 | Self::CreateThreadFromMessage { .. }
1553 | Self::CreateRole { .. }
1554 | Self::CreateStageInstance { .. }
1555 | Self::CreateTemplate { .. }
1556 | Self::CreateTestEntitlement { .. }
1557 | Self::CreateTypingTrigger { .. }
1558 | Self::CreateWebhook { .. }
1559 | Self::CrosspostMessage { .. }
1560 | Self::DeleteMessages { .. }
1561 | Self::EndPoll { .. }
1562 | Self::ExecuteWebhook { .. }
1563 | Self::FollowNewsChannel { .. }
1564 | Self::InteractionCallback { .. }
1565 | Self::SyncGuildIntegration { .. } => Method::Post,
1566 Self::AddGuildMember { .. }
1567 | Self::AddMemberRole { .. }
1568 | Self::AddThreadMember { .. }
1569 | Self::CreateBan { .. }
1570 | Self::CreateReaction { .. }
1571 | Self::JoinThread { .. }
1572 | Self::PinMessage { .. }
1573 | Self::SetGlobalCommands { .. }
1574 | Self::SetGuildCommands { .. }
1575 | Self::SyncTemplate { .. }
1576 | Self::UpdateCommandPermissions { .. }
1577 | Self::UpdateGuildOnboarding { .. }
1578 | Self::UpdatePermissionOverwrite { .. } => Method::Put,
1579 }
1580 }
1581}
1582
1583impl Display for Route<'_> {
1617 #[allow(clippy::too_many_lines)]
1624 fn fmt(&self, f: &mut Formatter<'_>) -> FmtResult {
1625 match self {
1626 Route::AddGuildMember { guild_id, user_id }
1627 | Route::GetMember { guild_id, user_id }
1628 | Route::RemoveMember { guild_id, user_id }
1629 | Route::UpdateMember { guild_id, user_id } => {
1630 f.write_str("guilds/")?;
1631 Display::fmt(guild_id, f)?;
1632 f.write_str("/members/")?;
1633
1634 Display::fmt(user_id, f)
1635 }
1636 Route::AddMemberRole {
1637 guild_id,
1638 role_id,
1639 user_id,
1640 }
1641 | Route::RemoveMemberRole {
1642 guild_id,
1643 role_id,
1644 user_id,
1645 } => {
1646 f.write_str("guilds/")?;
1647 Display::fmt(guild_id, f)?;
1648 f.write_str("/members/")?;
1649 Display::fmt(user_id, f)?;
1650 f.write_str("/roles/")?;
1651
1652 Display::fmt(role_id, f)
1653 }
1654 Route::AddThreadMember {
1655 channel_id,
1656 user_id,
1657 }
1658 | Route::GetThreadMember {
1659 channel_id,
1660 user_id,
1661 }
1662 | Route::RemoveThreadMember {
1663 channel_id,
1664 user_id,
1665 } => {
1666 f.write_str("channels/")?;
1667 Display::fmt(channel_id, f)?;
1668 f.write_str("/thread-members/")?;
1669
1670 Display::fmt(user_id, f)
1671 }
1672 Route::BulkGuildBan { guild_id } => {
1673 f.write_str("guilds/")?;
1674 Display::fmt(guild_id, f)?;
1675
1676 f.write_str("/bulk-ban")
1677 }
1678 Route::ConsumeEntitlement {
1679 application_id,
1680 entitlement_id,
1681 } => {
1682 f.write_str("applications/")?;
1683 Display::fmt(application_id, f)?;
1684 f.write_str("/entitlements/")?;
1685 Display::fmt(entitlement_id, f)?;
1686
1687 f.write_str("/consume")
1688 }
1689 Route::CreateAutoModerationRule { guild_id, .. }
1690 | Route::GetGuildAutoModerationRules { guild_id, .. } => {
1691 f.write_str("guilds/")?;
1692 Display::fmt(guild_id, f)?;
1693
1694 f.write_str("/auto-moderation/rules")
1695 }
1696 Route::CreateChannel { guild_id }
1697 | Route::GetChannels { guild_id }
1698 | Route::UpdateGuildChannels { guild_id } => {
1699 f.write_str("guilds/")?;
1700 Display::fmt(guild_id, f)?;
1701
1702 f.write_str("/channels")
1703 }
1704 Route::CreateEmoji { guild_id } | Route::GetEmojis { guild_id } => {
1705 f.write_str("guilds/")?;
1706 Display::fmt(guild_id, f)?;
1707
1708 f.write_str("/emojis")
1709 }
1710 Route::CreateGlobalCommand { application_id }
1711 | Route::SetGlobalCommands { application_id } => {
1712 f.write_str("applications/")?;
1713 Display::fmt(application_id, f)?;
1714
1715 f.write_str("/commands")
1716 }
1717 Route::DeleteAutoModerationRule {
1718 auto_moderation_rule_id,
1719 guild_id,
1720 ..
1721 }
1722 | Route::GetAutoModerationRule {
1723 auto_moderation_rule_id,
1724 guild_id,
1725 ..
1726 }
1727 | Route::UpdateAutoModerationRule {
1728 auto_moderation_rule_id,
1729 guild_id,
1730 ..
1731 } => {
1732 f.write_str("guilds/")?;
1733 Display::fmt(guild_id, f)?;
1734 f.write_str("/auto-moderation/rules/")?;
1735
1736 Display::fmt(auto_moderation_rule_id, f)
1737 }
1738 Route::GetAnswerVoters {
1739 after,
1740 answer_id,
1741 channel_id,
1742 limit,
1743 message_id,
1744 } => {
1745 f.write_str("channels/")?;
1746 Display::fmt(channel_id, f)?;
1747 f.write_str("/polls/")?;
1748 Display::fmt(message_id, f)?;
1749 f.write_str("/answers/")?;
1750 Display::fmt(answer_id, f)?;
1751 f.write_str("?")?;
1752
1753 let mut writer = QueryStringFormatter::new(f);
1754 writer.write_opt_param("after", after.as_ref())?;
1755 writer.write_opt_param("limit", limit.as_ref())
1756 }
1757 Route::GetGlobalCommands {
1758 application_id,
1759 with_localizations,
1760 } => {
1761 f.write_str("applications/")?;
1762 Display::fmt(application_id, f)?;
1763 f.write_str("/commands")?;
1764
1765 let mut writer = QueryStringFormatter::new(f);
1766
1767 writer.write_opt_param("with_localizations", with_localizations.as_ref())
1768 }
1769 Route::CreateGuild => f.write_str("guilds"),
1770 Route::CreateGuildCommand {
1771 application_id,
1772 guild_id,
1773 }
1774 | Route::SetGuildCommands {
1775 application_id,
1776 guild_id,
1777 } => {
1778 f.write_str("applications/")?;
1779 Display::fmt(application_id, f)?;
1780 f.write_str("/guilds/")?;
1781 Display::fmt(guild_id, f)?;
1782
1783 f.write_str("/commands")
1784 }
1785 Route::GetGuildCommands {
1786 application_id,
1787 guild_id,
1788 with_localizations,
1789 } => {
1790 f.write_str("applications/")?;
1791 Display::fmt(application_id, f)?;
1792 f.write_str("/guilds/")?;
1793 Display::fmt(guild_id, f)?;
1794 f.write_str("/commands")?;
1795
1796 let mut writer = QueryStringFormatter::new(f);
1797 writer.write_opt_param("with_localizations", with_localizations.as_ref())
1798 }
1799 Route::CreateGuildFromTemplate { template_code }
1800 | Route::GetTemplate { template_code } => {
1801 f.write_str("guilds/templates/")?;
1802
1803 f.write_str(template_code)
1804 }
1805 Route::CreateTestEntitlement { application_id } => {
1806 f.write_str("applications/")?;
1807 Display::fmt(application_id, f)?;
1808
1809 f.write_str("/entitlements")
1810 }
1811 Route::CreateGuildIntegration { guild_id }
1812 | Route::GetGuildIntegrations { guild_id } => {
1813 f.write_str("guilds/")?;
1814 Display::fmt(guild_id, f)?;
1815
1816 f.write_str("/integrations")
1817 }
1818 Route::CreateGuildPrune {
1819 compute_prune_count,
1820 days,
1821 guild_id,
1822 include_roles,
1823 } => {
1824 f.write_str("guilds/")?;
1825 Display::fmt(guild_id, f)?;
1826 f.write_str("/prune")?;
1827
1828 let mut writer = QueryStringFormatter::new(f);
1829
1830 writer.write_opt_param("compute_prune_count", compute_prune_count.as_ref())?;
1831 writer.write_opt_param("days", days.as_ref())?;
1832
1833 if !include_roles.is_empty() {
1834 writer.write_param("include_roles", &QueryCsvArray(*include_roles))?;
1835 }
1836
1837 Ok(())
1838 }
1839 Route::CreateGuildScheduledEvent { guild_id } => {
1840 f.write_str("guilds/")?;
1841 Display::fmt(guild_id, f)?;
1842
1843 f.write_str("/scheduled-events")
1844 }
1845 Route::CreateGuildSticker { guild_id, .. }
1846 | Route::GetGuildStickers { guild_id, .. } => {
1847 f.write_str("guilds/")?;
1848 Display::fmt(guild_id, f)?;
1849
1850 f.write_str("/stickers")
1851 }
1852 Route::CreateInvite { channel_id } | Route::GetChannelInvites { channel_id } => {
1853 f.write_str("channels/")?;
1854 Display::fmt(channel_id, f)?;
1855
1856 f.write_str("/invites")
1857 }
1858 Route::CreateMessage { channel_id } => {
1859 f.write_str("channels/")?;
1860 Display::fmt(channel_id, f)?;
1861
1862 f.write_str("/messages")
1863 }
1864 Route::CreatePrivateChannel | Route::GetUserPrivateChannels => {
1865 f.write_str("users/@me/channels")
1866 }
1867 Route::CreateReaction {
1868 channel_id,
1869 emoji,
1870 message_id,
1871 }
1872 | Route::DeleteReactionCurrentUser {
1873 channel_id,
1874 emoji,
1875 message_id,
1876 } => {
1877 f.write_str("channels/")?;
1878 Display::fmt(channel_id, f)?;
1879 f.write_str("/messages/")?;
1880 Display::fmt(message_id, f)?;
1881 f.write_str("/reactions/")?;
1882 Display::fmt(&emoji, f)?;
1883
1884 f.write_str("/@me")
1885 }
1886 Route::CreateRole { guild_id }
1887 | Route::GetGuildRoles { guild_id }
1888 | Route::UpdateRolePositions { guild_id } => {
1889 f.write_str("guilds/")?;
1890 Display::fmt(guild_id, f)?;
1891
1892 f.write_str("/roles")
1893 }
1894 Route::GetGuildRoleMemberCounts { guild_id } => {
1895 f.write_str("guilds/")?;
1896 Display::fmt(guild_id, f)?;
1897
1898 f.write_str("/roles/member-counts")
1899 }
1900 Route::GetGuildRolePermissions { guild_id, role_id } => {
1901 f.write_str("guilds/")?;
1902 Display::fmt(guild_id, f)?;
1903 f.write_str("/permissions/role/")?;
1904
1905 Display::fmt(role_id, f)
1906 }
1907 Route::CreateStageInstance { .. } => f.write_str("stage-instances"),
1908 Route::CreateTemplate { guild_id } | Route::GetTemplates { guild_id } => {
1909 f.write_str("guilds/")?;
1910 Display::fmt(guild_id, f)?;
1911
1912 f.write_str("/templates")
1913 }
1914 Route::CreateForumThread { channel_id } | Route::CreateThread { channel_id } => {
1915 f.write_str("channels/")?;
1916 Display::fmt(channel_id, f)?;
1917
1918 f.write_str("/threads")
1919 }
1920 Route::CreateThreadFromMessage {
1921 channel_id,
1922 message_id,
1923 } => {
1924 f.write_str("channels/")?;
1925 Display::fmt(channel_id, f)?;
1926 f.write_str("/messages/")?;
1927 Display::fmt(message_id, f)?;
1928
1929 f.write_str("/threads")
1930 }
1931 Route::CreateTypingTrigger { channel_id } => {
1932 f.write_str("channels/")?;
1933 Display::fmt(channel_id, f)?;
1934
1935 f.write_str("/typing")
1936 }
1937 Route::CreateWebhook { channel_id } | Route::GetChannelWebhooks { channel_id } => {
1938 f.write_str("channels/")?;
1939 Display::fmt(channel_id, f)?;
1940
1941 f.write_str("/webhooks")
1942 }
1943 Route::CrosspostMessage {
1944 channel_id,
1945 message_id,
1946 } => {
1947 f.write_str("channels/")?;
1948 Display::fmt(channel_id, f)?;
1949 f.write_str("/messages/")?;
1950 Display::fmt(message_id, f)?;
1951
1952 f.write_str("/crosspost")
1953 }
1954 Route::DeleteBan { guild_id, user_id }
1955 | Route::GetBan { guild_id, user_id }
1956 | Route::CreateBan { guild_id, user_id } => {
1957 f.write_str("guilds/")?;
1958 Display::fmt(guild_id, f)?;
1959 f.write_str("/bans/")?;
1960
1961 Display::fmt(user_id, f)
1962 }
1963 Route::DeleteChannel { channel_id }
1964 | Route::GetChannel { channel_id }
1965 | Route::UpdateChannel { channel_id } => {
1966 f.write_str("channels/")?;
1967
1968 Display::fmt(channel_id, f)
1969 }
1970 Route::GetChannelMemberPermissions {
1971 channel_id,
1972 implicit,
1973 user_id,
1974 } => {
1975 f.write_str("channels/")?;
1976 Display::fmt(channel_id, f)?;
1977 f.write_str("/permissions/member/")?;
1978 Display::fmt(user_id, f)?;
1979
1980 let mut query_formatter = QueryStringFormatter::new(f);
1981
1982 query_formatter.write_opt_param("implicit", implicit.as_ref())
1983 }
1984 Route::GetChannelRolePermissions {
1985 channel_id,
1986 implicit,
1987 role_id,
1988 } => {
1989 f.write_str("channels/")?;
1990 Display::fmt(channel_id, f)?;
1991 f.write_str("/permissions/role/")?;
1992 Display::fmt(role_id, f)?;
1993
1994 let mut query_formatter = QueryStringFormatter::new(f);
1995
1996 query_formatter.write_opt_param("implicit", implicit.as_ref())
1997 }
1998 Route::DeleteEmoji { emoji_id, guild_id }
1999 | Route::GetEmoji { emoji_id, guild_id }
2000 | Route::UpdateEmoji { emoji_id, guild_id } => {
2001 f.write_str("guilds/")?;
2002 Display::fmt(guild_id, f)?;
2003 f.write_str("/emojis/")?;
2004
2005 Display::fmt(emoji_id, f)
2006 }
2007 Route::GetEntitlements {
2008 after,
2009 application_id,
2010 before,
2011 exclude_deleted,
2012 exclude_ended,
2013 guild_id,
2014 limit,
2015 sku_ids,
2016 user_id,
2017 } => {
2018 f.write_str("applications/")?;
2019 Display::fmt(application_id, f)?;
2020 f.write_str("/entitlements")?;
2021
2022 f.write_str("?")?;
2023
2024 if let Some(after) = after {
2025 f.write_str("after=")?;
2026 Display::fmt(after, f)?;
2027 }
2028
2029 if let Some(before) = before {
2030 f.write_str("&before=")?;
2031 Display::fmt(before, f)?;
2032 }
2033
2034 if let Some(exclude_deleted) = exclude_deleted {
2035 f.write_str("&exclude_deleted=")?;
2036 Display::fmt(exclude_deleted, f)?;
2037 }
2038
2039 if let Some(exclude_ended) = exclude_ended {
2040 f.write_str("&exclude_ended=")?;
2041 Display::fmt(exclude_ended, f)?;
2042 }
2043
2044 if let Some(guild_id) = guild_id {
2045 f.write_str("&guild_id=")?;
2046 Display::fmt(guild_id, f)?;
2047 }
2048
2049 if let Some(limit) = limit {
2050 f.write_str("&limit=")?;
2051 Display::fmt(limit, f)?;
2052 }
2053
2054 if !sku_ids.is_empty() {
2055 let sku_id_count = sku_ids.len() - 1;
2056
2057 f.write_str("&sku_ids=")?;
2058
2059 for (idx, sku_id) in sku_ids.iter().enumerate() {
2060 Display::fmt(sku_id, f)?;
2061
2062 if idx < sku_id_count {
2063 f.write_str(",")?;
2064 }
2065 }
2066 }
2067
2068 if let Some(user_id) = user_id {
2069 f.write_str("&user_id=")?;
2070 Display::fmt(user_id, f)?;
2071 }
2072
2073 Ok(())
2074 }
2075 Route::GetEntitlement {
2076 application_id,
2077 entitlement_id,
2078 }
2079 | Route::DeleteTestEntitlement {
2080 application_id,
2081 entitlement_id,
2082 } => {
2083 f.write_str("applications/")?;
2084 Display::fmt(application_id, f)?;
2085 f.write_str("/entitlements/")?;
2086
2087 Display::fmt(entitlement_id, f)
2088 }
2089 Route::DeleteGlobalCommand {
2090 application_id,
2091 command_id,
2092 }
2093 | Route::GetGlobalCommand {
2094 application_id,
2095 command_id,
2096 }
2097 | Route::UpdateGlobalCommand {
2098 application_id,
2099 command_id,
2100 } => {
2101 f.write_str("applications/")?;
2102 Display::fmt(application_id, f)?;
2103 f.write_str("/commands/")?;
2104
2105 Display::fmt(command_id, f)
2106 }
2107 Route::DeleteGuild { guild_id } | Route::UpdateGuild { guild_id } => {
2108 f.write_str("guilds/")?;
2109
2110 Display::fmt(guild_id, f)
2111 }
2112 Route::DeleteGuildCommand {
2113 application_id,
2114 command_id,
2115 guild_id,
2116 }
2117 | Route::GetGuildCommand {
2118 application_id,
2119 command_id,
2120 guild_id,
2121 }
2122 | Route::UpdateGuildCommand {
2123 application_id,
2124 command_id,
2125 guild_id,
2126 } => {
2127 f.write_str("applications/")?;
2128 Display::fmt(application_id, f)?;
2129 f.write_str("/guilds/")?;
2130 Display::fmt(guild_id, f)?;
2131 f.write_str("/commands/")?;
2132
2133 Display::fmt(command_id, f)
2134 }
2135 Route::DeleteGuildIntegration {
2136 guild_id,
2137 integration_id,
2138 }
2139 | Route::UpdateGuildIntegration {
2140 guild_id,
2141 integration_id,
2142 } => {
2143 f.write_str("guilds/")?;
2144 Display::fmt(guild_id, f)?;
2145 f.write_str("/integrations/")?;
2146
2147 Display::fmt(integration_id, f)
2148 }
2149 Route::DeleteInteractionOriginal {
2150 application_id,
2151 interaction_token,
2152 }
2153 | Route::GetInteractionOriginal {
2154 application_id,
2155 interaction_token,
2156 }
2157 | Route::UpdateInteractionOriginal {
2158 application_id,
2159 interaction_token,
2160 } => {
2161 f.write_str("webhooks/")?;
2162 Display::fmt(application_id, f)?;
2163 f.write_str("/")?;
2164 f.write_str(interaction_token)?;
2165
2166 f.write_str("/messages/@original")
2167 }
2168 Route::DeleteInvite { code } => {
2169 f.write_str("invites/")?;
2170
2171 f.write_str(code)
2172 }
2173 Route::DeleteMessageReactions {
2174 channel_id,
2175 message_id,
2176 } => {
2177 f.write_str("channels/")?;
2178 Display::fmt(channel_id, f)?;
2179 f.write_str("/messages/")?;
2180 Display::fmt(message_id, f)?;
2181
2182 f.write_str("/reactions")
2183 }
2184 Route::DeleteMessageSpecificReaction {
2185 channel_id,
2186 message_id,
2187 emoji,
2188 } => {
2189 f.write_str("channels/")?;
2190 Display::fmt(channel_id, f)?;
2191 f.write_str("/messages/")?;
2192 Display::fmt(message_id, f)?;
2193 f.write_str("/reactions/")?;
2194
2195 Display::fmt(&emoji, f)
2196 }
2197 Route::DeleteMessage {
2198 channel_id,
2199 message_id,
2200 }
2201 | Route::GetMessage {
2202 channel_id,
2203 message_id,
2204 }
2205 | Route::UpdateMessage {
2206 channel_id,
2207 message_id,
2208 } => {
2209 f.write_str("channels/")?;
2210 Display::fmt(channel_id, f)?;
2211 f.write_str("/messages/")?;
2212
2213 Display::fmt(message_id, f)
2214 }
2215 Route::DeleteMessages { channel_id } => {
2216 f.write_str("channels/")?;
2217 Display::fmt(channel_id, f)?;
2218
2219 f.write_str("/messages/bulk-delete")
2220 }
2221 Route::DeletePermissionOverwrite {
2222 channel_id,
2223 target_id,
2224 }
2225 | Route::UpdatePermissionOverwrite {
2226 channel_id,
2227 target_id,
2228 } => {
2229 f.write_str("channels/")?;
2230 Display::fmt(channel_id, f)?;
2231 f.write_str("/permissions/")?;
2232
2233 Display::fmt(target_id, f)
2234 }
2235 Route::DeleteReaction {
2236 channel_id,
2237 emoji,
2238 message_id,
2239 user_id,
2240 } => {
2241 f.write_str("channels/")?;
2242 Display::fmt(channel_id, f)?;
2243 f.write_str("/messages/")?;
2244 Display::fmt(message_id, f)?;
2245 f.write_str("/reactions/")?;
2246 Display::fmt(&emoji, f)?;
2247 f.write_str("/")?;
2248
2249 Display::fmt(user_id, f)
2250 }
2251 Route::DeleteRole { guild_id, role_id }
2252 | Route::GetRole { guild_id, role_id }
2253 | Route::UpdateRole { guild_id, role_id } => {
2254 f.write_str("guilds/")?;
2255 Display::fmt(guild_id, f)?;
2256 f.write_str("/roles/")?;
2257
2258 Display::fmt(role_id, f)
2259 }
2260 Route::DeleteStageInstance { channel_id }
2261 | Route::GetStageInstance { channel_id }
2262 | Route::UpdateStageInstance { channel_id } => {
2263 f.write_str("stage-instances/")?;
2264
2265 Display::fmt(channel_id, f)
2266 }
2267 Route::DeleteTemplate {
2268 guild_id,
2269 template_code,
2270 }
2271 | Route::SyncTemplate {
2272 guild_id,
2273 template_code,
2274 }
2275 | Route::UpdateTemplate {
2276 guild_id,
2277 template_code,
2278 } => {
2279 f.write_str("guilds/")?;
2280 Display::fmt(guild_id, f)?;
2281 f.write_str("/templates/")?;
2282
2283 f.write_str(template_code)
2284 }
2285 Route::DeleteWebhookMessage {
2286 message_id,
2287 thread_id,
2288 token,
2289 webhook_id,
2290 }
2291 | Route::GetFollowupMessage {
2292 application_id: webhook_id,
2293 interaction_token: token,
2294 thread_id,
2295 message_id,
2296 }
2297 | Route::GetWebhookMessage {
2298 message_id,
2299 token,
2300 thread_id,
2301 webhook_id,
2302 }
2303 | Route::UpdateWebhookMessage {
2304 message_id,
2305 thread_id,
2306 token,
2307 webhook_id,
2308 } => {
2309 f.write_str("webhooks/")?;
2310 Display::fmt(webhook_id, f)?;
2311 f.write_str("/")?;
2312 f.write_str(token)?;
2313 f.write_str("/messages/")?;
2314 Display::fmt(message_id, f)?;
2315
2316 let mut query_formatter = QueryStringFormatter::new(f);
2317
2318 query_formatter.write_opt_param("thread_id", thread_id.as_ref())
2319 }
2320 Route::DeleteWebhook { token, webhook_id }
2321 | Route::GetWebhook { token, webhook_id }
2322 | Route::UpdateWebhook { token, webhook_id } => {
2323 f.write_str("webhooks/")?;
2324 Display::fmt(webhook_id, f)?;
2325
2326 if let Some(token) = token {
2327 f.write_str("/")?;
2328 f.write_str(token)?;
2329 }
2330
2331 Ok(())
2332 }
2333 Route::EndPoll {
2334 channel_id,
2335 message_id,
2336 } => {
2337 f.write_str("channels/")?;
2338 Display::fmt(channel_id, f)?;
2339 f.write_str("/polls/")?;
2340 Display::fmt(message_id, f)?;
2341
2342 f.write_str("/expire")
2343 }
2344 Route::ExecuteWebhook {
2345 thread_id,
2346 token,
2347 wait,
2348 with_components,
2349 webhook_id,
2350 } => {
2351 f.write_str("webhooks/")?;
2352 Display::fmt(webhook_id, f)?;
2353 f.write_str("/")?;
2354 f.write_str(token)?;
2355
2356 let mut query_formatter = QueryStringFormatter::new(f);
2357
2358 query_formatter.write_opt_param("thread_id", thread_id.as_ref())?;
2359 query_formatter.write_opt_param("wait", wait.as_ref())?;
2360 query_formatter.write_opt_param("with_components", with_components.as_ref())
2361 }
2362 Route::FollowNewsChannel { channel_id } => {
2363 f.write_str("channels/")?;
2364 Display::fmt(channel_id, f)?;
2365
2366 f.write_str("/followers")
2367 }
2368 Route::GetActiveThreads { guild_id } => {
2369 f.write_str("guilds/")?;
2370 Display::fmt(guild_id, f)?;
2371
2372 f.write_str("/threads/active")
2373 }
2374 Route::DeleteApplicationEmoji {
2375 application_id,
2376 emoji_id,
2377 }
2378 | Route::UpdateApplicationEmoji {
2379 application_id,
2380 emoji_id,
2381 } => {
2382 f.write_str("applications/")?;
2383 Display::fmt(application_id, f)?;
2384 f.write_str("/emojis/")?;
2385
2386 Display::fmt(emoji_id, f)
2387 }
2388 Route::GetApplicationEmojis { application_id }
2389 | Route::AddApplicationEmoji { application_id } => {
2390 f.write_str("applications/")?;
2391 Display::fmt(application_id, f)?;
2392
2393 f.write_str("/emojis")
2394 }
2395 Route::GetAuditLogs {
2396 action_type,
2397 after,
2398 before,
2399 guild_id,
2400 limit,
2401 user_id,
2402 } => {
2403 f.write_str("guilds/")?;
2404 Display::fmt(guild_id, f)?;
2405 f.write_str("/audit-logs")?;
2406
2407 let mut query_formatter = QueryStringFormatter::new(f);
2408
2409 query_formatter.write_opt_param("action_type", action_type.as_ref())?;
2410 query_formatter.write_opt_param("after", after.as_ref())?;
2411 query_formatter.write_opt_param("before", before.as_ref())?;
2412 query_formatter.write_opt_param("limit", limit.as_ref())?;
2413 query_formatter.write_opt_param("user_id", user_id.as_ref())
2414 }
2415 Route::GetBans { guild_id } => {
2416 f.write_str("guilds/")?;
2417 Display::fmt(guild_id, f)?;
2418
2419 f.write_str("/bans")
2420 }
2421 Route::GetBansWithParameters {
2422 after,
2423 before,
2424 guild_id,
2425 limit,
2426 } => {
2427 f.write_str("guilds/")?;
2428 Display::fmt(guild_id, f)?;
2429 f.write_str("/bans")?;
2430
2431 let mut query_formatter = QueryStringFormatter::new(f);
2432
2433 query_formatter.write_opt_param("after", after.as_ref())?;
2434 query_formatter.write_opt_param("before", before.as_ref())?;
2435 query_formatter.write_opt_param("limit", limit.as_ref())
2436 }
2437 Route::GetGatewayBot => f.write_str("gateway/bot"),
2438 Route::GetCommandPermissions {
2439 application_id,
2440 command_id,
2441 guild_id,
2442 }
2443 | Route::UpdateCommandPermissions {
2444 application_id,
2445 command_id,
2446 guild_id,
2447 } => {
2448 f.write_str("applications/")?;
2449 Display::fmt(application_id, f)?;
2450 f.write_str("/guilds/")?;
2451 Display::fmt(guild_id, f)?;
2452 f.write_str("/commands/")?;
2453 Display::fmt(command_id, f)?;
2454
2455 f.write_str("/permissions")
2456 }
2457 Route::GetCurrentAuthorizationInformation => f.write_str("oauth2/@me"),
2458 Route::GetCurrentUserApplicationInfo | Route::UpdateCurrentUserApplication => {
2459 f.write_str("applications/@me")
2460 }
2461 Route::GetCurrentUser | Route::UpdateCurrentUser => f.write_str("users/@me"),
2462 Route::GetCurrentUserGuildMember { guild_id } => {
2463 f.write_str("users/@me/guilds/")?;
2464 Display::fmt(guild_id, f)?;
2465
2466 f.write_str("/member")
2467 }
2468 Route::GetGateway => f.write_str("gateway"),
2469 Route::GetGuild {
2470 guild_id,
2471 with_counts,
2472 } => {
2473 f.write_str("guilds/")?;
2474 Display::fmt(guild_id, f)?;
2475
2476 let mut query_formatter = QueryStringFormatter::new(f);
2477
2478 if *with_counts {
2479 query_formatter.write_param("with_counts", &true)?;
2480 }
2481
2482 Ok(())
2483 }
2484 Route::GetGuildCommandPermissions {
2485 application_id,
2486 guild_id,
2487 } => {
2488 f.write_str("applications/")?;
2489 Display::fmt(application_id, f)?;
2490 f.write_str("/guilds/")?;
2491 Display::fmt(guild_id, f)?;
2492
2493 f.write_str("/commands/permissions")
2494 }
2495 Route::GetGuildInvites { guild_id } => {
2496 f.write_str("guilds/")?;
2497 Display::fmt(guild_id, f)?;
2498
2499 f.write_str("/invites")
2500 }
2501 Route::GetGuildMemberPermissions { guild_id, user_id } => {
2502 f.write_str("guilds/")?;
2503 Display::fmt(guild_id, f)?;
2504 f.write_str("/permissions/member/")?;
2505
2506 Display::fmt(user_id, f)
2507 }
2508 Route::GetGuildMembers {
2509 after,
2510 guild_id,
2511 limit,
2512 } => {
2513 f.write_str("guilds/")?;
2514 Display::fmt(guild_id, f)?;
2515 f.write_str("/members")?;
2516
2517 let mut query_formatter = QueryStringFormatter::new(f);
2518
2519 query_formatter.write_opt_param("after", after.as_ref())?;
2520 query_formatter.write_opt_param("limit", limit.as_ref())
2521 }
2522 Route::GetGuildOnboarding { guild_id } | Route::UpdateGuildOnboarding { guild_id } => {
2523 f.write_str("guilds/")?;
2524 Display::fmt(guild_id, f)?;
2525
2526 f.write_str("/onboarding")
2527 }
2528 Route::GetGuildPreview { guild_id } => {
2529 f.write_str("guilds/")?;
2530 Display::fmt(guild_id, f)?;
2531
2532 f.write_str("/preview")
2533 }
2534 Route::GetGuildPruneCount {
2535 days,
2536 guild_id,
2537 include_roles,
2538 } => {
2539 f.write_str("guilds/")?;
2540 Display::fmt(guild_id, f)?;
2541 f.write_str("/prune")?;
2542
2543 let mut query_formatter = QueryStringFormatter::new(f);
2544
2545 query_formatter.write_opt_param("days", days.as_ref())?;
2546
2547 if !include_roles.is_empty() {
2548 query_formatter.write_param("include_roles", &QueryCsvArray(*include_roles))?;
2549 }
2550
2551 Ok(())
2552 }
2553 Route::GetGuildScheduledEvent {
2554 guild_id,
2555 scheduled_event_id,
2556 with_user_count,
2557 } => {
2558 f.write_str("guilds/")?;
2559 Display::fmt(guild_id, f)?;
2560 f.write_str("/scheduled-events/")?;
2561 Display::fmt(scheduled_event_id, f)?;
2562
2563 let mut query_formatter = QueryStringFormatter::new(f);
2564
2565 if *with_user_count {
2566 query_formatter.write_param("with_user_count", &true)?;
2567 }
2568
2569 Ok(())
2570 }
2571 Route::GetGuildScheduledEventUsers {
2572 after,
2573 before,
2574 guild_id,
2575 limit,
2576 scheduled_event_id,
2577 with_member,
2578 } => {
2579 f.write_str("guilds/")?;
2580 Display::fmt(guild_id, f)?;
2581 f.write_str("/scheduled-events/")?;
2582 Display::fmt(scheduled_event_id, f)?;
2583 f.write_str("/users")?;
2584
2585 let mut query_formatter = QueryStringFormatter::new(f);
2586
2587 query_formatter.write_opt_param("after", after.as_ref())?;
2588 query_formatter.write_opt_param("before", before.as_ref())?;
2589 query_formatter.write_opt_param("limit", limit.as_ref())?;
2590
2591 if *with_member {
2592 query_formatter.write_param("with_member", &true)?;
2593 }
2594
2595 Ok(())
2596 }
2597 Route::GetGuildScheduledEvents {
2598 guild_id,
2599 with_user_count,
2600 } => {
2601 f.write_str("guilds/")?;
2602 Display::fmt(guild_id, f)?;
2603 f.write_str("/scheduled-events")?;
2604
2605 let mut query_formatter = QueryStringFormatter::new(f);
2606
2607 if *with_user_count {
2608 query_formatter.write_param("with_user_count", &true)?;
2609 }
2610
2611 Ok(())
2612 }
2613 Route::GetGuildSticker {
2614 guild_id,
2615 sticker_id,
2616 ..
2617 }
2618 | Route::DeleteGuildSticker {
2619 guild_id,
2620 sticker_id,
2621 ..
2622 }
2623 | Route::UpdateGuildSticker {
2624 guild_id,
2625 sticker_id,
2626 ..
2627 } => {
2628 f.write_str("guilds/")?;
2629 Display::fmt(guild_id, f)?;
2630 f.write_str("/stickers/")?;
2631
2632 Display::fmt(sticker_id, f)
2633 }
2634 Route::GetGuildVanityUrl { guild_id } => {
2635 f.write_str("guilds/")?;
2636 Display::fmt(guild_id, f)?;
2637
2638 f.write_str("/vanity-url")
2639 }
2640 Route::GetGuildVoiceRegions { guild_id } => {
2641 f.write_str("guilds/")?;
2642 Display::fmt(guild_id, f)?;
2643
2644 f.write_str("/regions")
2645 }
2646 Route::GetGuildWelcomeScreen { guild_id }
2647 | Route::UpdateGuildWelcomeScreen { guild_id } => {
2648 f.write_str("guilds/")?;
2649 Display::fmt(guild_id, f)?;
2650
2651 f.write_str("/welcome-screen")
2652 }
2653 Route::GetGuildWebhooks { guild_id } => {
2654 f.write_str("guilds/")?;
2655 Display::fmt(guild_id, f)?;
2656
2657 f.write_str("/webhooks")
2658 }
2659 Route::GetGuildWidget { guild_id } => {
2660 f.write_str("guilds/")?;
2661 Display::fmt(guild_id, f)?;
2662
2663 f.write_str("/widget.json")
2664 }
2665 Route::GetGuildWidgetSettings { guild_id }
2666 | Route::UpdateGuildWidgetSettings { guild_id } => {
2667 f.write_str("guilds/")?;
2668 Display::fmt(guild_id, f)?;
2669
2670 f.write_str("/widget")
2671 }
2672 Route::GetGuilds {
2673 after,
2674 before,
2675 limit,
2676 shard,
2677 } => {
2678 f.write_str("users/@me/guilds")?;
2679
2680 let mut query_formatter = QueryStringFormatter::new(f);
2681
2682 query_formatter.write_opt_param("after", after.as_ref())?;
2683 query_formatter.write_opt_param("before", before.as_ref())?;
2684 query_formatter.write_opt_param("limit", limit.as_ref())?;
2685 query_formatter.write_opt_param("shard", shard.as_ref())
2686 }
2687 Route::GetInvite { code, with_counts } => {
2688 f.write_str("invites/")?;
2689 f.write_str(code)?;
2690
2691 let mut query_formatter = QueryStringFormatter::new(f);
2692
2693 if *with_counts {
2694 query_formatter.write_param("with_counts", &true)?;
2695 }
2696
2697 Ok(())
2698 }
2699 Route::GetInviteWithExpiration {
2700 code,
2701 with_counts,
2702 with_expiration,
2703 } => {
2704 f.write_str("invites/")?;
2705 f.write_str(code)?;
2706
2707 let mut query_formatter = QueryStringFormatter::new(f);
2708
2709 if *with_counts {
2710 query_formatter.write_param("with_counts", &true)?;
2711 }
2712
2713 if *with_expiration {
2714 query_formatter.write_param("with_expiration", &true)?;
2715 }
2716
2717 Ok(())
2718 }
2719 Route::GetMessages {
2720 channel_id,
2721 after,
2722 around,
2723 before,
2724 limit,
2725 } => {
2726 f.write_str("channels/")?;
2727 Display::fmt(channel_id, f)?;
2728 f.write_str("/messages")?;
2729
2730 let mut query_formatter = QueryStringFormatter::new(f);
2731
2732 query_formatter.write_opt_param("after", after.as_ref())?;
2733 query_formatter.write_opt_param("around", around.as_ref())?;
2734 query_formatter.write_opt_param("before", before.as_ref())?;
2735 query_formatter.write_opt_param("limit", limit.as_ref())
2736 }
2737 Route::GetNitroStickerPacks { .. } => f.write_str("sticker-packs"),
2738 Route::GetPins {
2739 channel_id,
2740 limit,
2741 before,
2742 } => {
2743 f.write_str("channels/")?;
2744 Display::fmt(channel_id, f)?;
2745
2746 f.write_str("/messages/pins")?;
2747
2748 let mut query_formatter = QueryStringFormatter::new(f);
2749
2750 query_formatter.write_opt_param("before", before.as_ref())?;
2751 query_formatter.write_opt_param("limit", limit.as_ref())
2752 }
2753 Route::GetJoinedPrivateArchivedThreads {
2754 before,
2755 channel_id,
2756 limit,
2757 } => {
2758 f.write_str("channels/")?;
2759 Display::fmt(channel_id, f)?;
2760 f.write_str("/users/@me/threads/archived/private")?;
2761
2762 let mut query_formatter = QueryStringFormatter::new(f);
2763
2764 query_formatter.write_opt_param("before", before.as_ref())?;
2765 query_formatter.write_opt_param("limit", limit.as_ref())
2766 }
2767 Route::GetPrivateArchivedThreads {
2768 before,
2769 channel_id,
2770 limit,
2771 } => {
2772 f.write_str("channels/")?;
2773 Display::fmt(channel_id, f)?;
2774 f.write_str("/threads/archived/private")?;
2775
2776 let mut query_formatter = QueryStringFormatter::new(f);
2777
2778 query_formatter.write_opt_param("before", before.as_ref())?;
2779 query_formatter.write_opt_param("limit", limit.as_ref())
2780 }
2781 Route::GetPublicArchivedThreads {
2782 before,
2783 channel_id,
2784 limit,
2785 } => {
2786 f.write_str("channels/")?;
2787 Display::fmt(channel_id, f)?;
2788 f.write_str("/threads/archived/public")?;
2789
2790 let mut query_formatter = QueryStringFormatter::new(f);
2791
2792 query_formatter.write_opt_param("before", before.as_ref())?;
2793 query_formatter.write_opt_param("limit", limit.as_ref())
2794 }
2795 Route::GetReactionUsers {
2796 after,
2797 channel_id,
2798 emoji,
2799 limit,
2800 message_id,
2801 kind,
2802 } => {
2803 f.write_str("channels/")?;
2804 Display::fmt(channel_id, f)?;
2805 f.write_str("/messages/")?;
2806 Display::fmt(message_id, f)?;
2807 f.write_str("/reactions/")?;
2808 Display::fmt(&emoji, f)?;
2809
2810 let mut query_formatter = QueryStringFormatter::new(f);
2811
2812 query_formatter.write_opt_param("after", after.as_ref())?;
2813 query_formatter.write_opt_param("limit", limit.as_ref())?;
2814 query_formatter.write_opt_param("type", kind.as_ref())
2815 }
2816 Route::GetStickerPack { sticker_pack_id } => {
2817 f.write_str("sticker-packs/")?;
2818
2819 Display::fmt(sticker_pack_id, f)
2820 }
2821 Route::GetSticker { sticker_id } => {
2822 f.write_str("stickers/")?;
2823
2824 Display::fmt(sticker_id, f)
2825 }
2826 Route::GetThreadMembers {
2827 after,
2828 channel_id,
2829 limit,
2830 with_member,
2831 } => {
2832 f.write_str("channels/")?;
2833 Display::fmt(channel_id, f)?;
2834 f.write_str("/thread-members")?;
2835
2836 let mut query_formatter = QueryStringFormatter::new(f);
2837
2838 query_formatter.write_opt_param("after", after.as_ref())?;
2839 query_formatter.write_opt_param("limit", limit.as_ref())?;
2840 query_formatter.write_opt_param("with_member", with_member.as_ref())
2841 }
2842 Route::GetUserConnections => f.write_str("users/@me/connections"),
2843 Route::GetUser { user_id } => {
2844 f.write_str("users/")?;
2845
2846 Display::fmt(user_id, f)
2847 }
2848 Route::GetVoiceRegions => f.write_str("voice/regions"),
2849 Route::InteractionCallback {
2850 interaction_id,
2851 interaction_token,
2852 with_response,
2853 } => {
2854 f.write_str("interactions/")?;
2855 Display::fmt(interaction_id, f)?;
2856 f.write_str("/")?;
2857 f.write_str(interaction_token)?;
2858
2859 f.write_str("/callback")?;
2860
2861 if *with_response {
2862 f.write_str("?with_response=true")?;
2863 }
2864
2865 Ok(())
2866 }
2867 Route::JoinThread { channel_id } | Route::LeaveThread { channel_id } => {
2868 f.write_str("channels/")?;
2869 Display::fmt(channel_id, f)?;
2870
2871 f.write_str("/thread-members/@me")
2872 }
2873 Route::LeaveGuild { guild_id } => {
2874 f.write_str("users/@me/guilds/")?;
2875
2876 Display::fmt(guild_id, f)
2877 }
2878 Route::PinMessage {
2879 channel_id,
2880 message_id,
2881 }
2882 | Route::UnpinMessage {
2883 channel_id,
2884 message_id,
2885 } => {
2886 f.write_str("channels/")?;
2887 Display::fmt(channel_id, f)?;
2888 f.write_str("/messages/pins/")?;
2889
2890 Display::fmt(message_id, f)
2891 }
2892 Route::SearchGuildMembers {
2893 guild_id,
2894 limit,
2895 query,
2896 } => {
2897 f.write_str("guilds/")?;
2898 Display::fmt(guild_id, f)?;
2899 f.write_str("/members/search")?;
2900
2901 let mut query_formatter = QueryStringFormatter::new(f);
2902
2903 query_formatter
2904 .write_param("query", &utf8_percent_encode(query, NON_ALPHANUMERIC))?;
2905 query_formatter.write_opt_param("limit", limit.as_ref())
2906 }
2907 Route::SearchGuildMessages {
2908 attachment_extension,
2909 attachment_filename,
2910 author_id,
2911 author_type,
2912 channel_id,
2913 content,
2914 embed_provider,
2915 embed_type,
2916 guild_id,
2917 has,
2918 include_nsfw,
2919 limit,
2920 link_hostname,
2921 max_id,
2922 mention_everyone,
2923 mentions,
2924 mentions_role_id,
2925 min_id,
2926 offset,
2927 pinned,
2928 replied_to_message_id,
2929 replied_to_user_id,
2930 slop,
2931 sort_by,
2932 sort_order,
2933 } => {
2934 f.write_str("guilds/")?;
2935 Display::fmt(guild_id, f)?;
2936 f.write_str("/messages/search")?;
2937
2938 let mut formatter = QueryStringFormatter::new(f);
2939
2940 if let Some(attachment_extension) = attachment_extension {
2941 formatter.write_repeating_param(
2942 "attachment_extension",
2943 attachment_extension.iter().map(|attachment_extension| {
2944 utf8_percent_encode(attachment_extension, NON_ALPHANUMERIC)
2945 }),
2946 )?;
2947 }
2948
2949 if let Some(attachment_filename) = attachment_filename {
2950 formatter.write_repeating_param(
2951 "attachment_filename",
2952 attachment_filename.iter().map(|attachment_filename| {
2953 utf8_percent_encode(attachment_filename, NON_ALPHANUMERIC)
2954 }),
2955 )?;
2956 }
2957
2958 if let Some(author_id) = author_id {
2959 formatter.write_repeating_param("author_id", author_id.iter())?;
2960 }
2961
2962 if let Some(author_type) = author_type {
2963 formatter.write_repeating_param("author_type", author_type.iter())?;
2964 }
2965
2966 if let Some(channel_id) = channel_id {
2967 formatter.write_repeating_param("channel_id", channel_id.iter())?;
2968 }
2969
2970 if let Some(content) = content {
2971 formatter
2972 .write_param("content", &utf8_percent_encode(content, NON_ALPHANUMERIC))?;
2973 }
2974
2975 if let Some(embed_provider) = embed_provider {
2976 formatter.write_repeating_param(
2977 "embed_provider",
2978 embed_provider.iter().map(|embed_provider| {
2979 utf8_percent_encode(embed_provider, NON_ALPHANUMERIC)
2980 }),
2981 )?;
2982 }
2983
2984 if let Some(embed_type) = embed_type {
2985 formatter.write_repeating_param("embed_type", embed_type.iter())?;
2986 }
2987
2988 if let Some(has) = has {
2989 formatter.write_repeating_param("has", has.iter())?;
2990 }
2991
2992 formatter.write_opt_param("include_nsfw", include_nsfw.as_ref())?;
2993 formatter.write_opt_param("limit", limit.as_ref())?;
2994
2995 if let Some(link_hostname) = link_hostname {
2996 formatter.write_repeating_param(
2997 "link_hostname",
2998 link_hostname.iter().map(|link_hostname| {
2999 utf8_percent_encode(link_hostname, NON_ALPHANUMERIC)
3000 }),
3001 )?;
3002 }
3003
3004 formatter.write_opt_param("max_id", max_id.as_ref())?;
3005 formatter.write_opt_param("mention_everyone", mention_everyone.as_ref())?;
3006
3007 if let Some(mentions) = mentions {
3008 formatter.write_repeating_param("mentions", mentions.iter())?;
3009 }
3010
3011 if let Some(mentions_role_id) = mentions_role_id {
3012 formatter.write_repeating_param("mentions_role_id", mentions_role_id.iter())?;
3013 }
3014
3015 formatter.write_opt_param("min_id", min_id.as_ref())?;
3016 formatter.write_opt_param("offset", offset.as_ref())?;
3017 formatter.write_opt_param("pinned", pinned.as_ref())?;
3018
3019 if let Some(replied_to_message_id) = replied_to_message_id {
3020 formatter.write_repeating_param(
3021 "replied_to_message_id",
3022 replied_to_message_id.iter(),
3023 )?;
3024 }
3025
3026 if let Some(replied_to_user_id) = replied_to_user_id {
3027 formatter
3028 .write_repeating_param("replied_to_user_id", replied_to_user_id.iter())?;
3029 }
3030
3031 formatter.write_opt_param("slop", slop.as_ref())?;
3032 formatter.write_opt_param("sort_by", sort_by.as_ref())?;
3033 formatter.write_opt_param("sort_order", sort_order.as_ref())?;
3034
3035 Ok(())
3036 }
3037 Route::SyncGuildIntegration {
3038 guild_id,
3039 integration_id,
3040 } => {
3041 f.write_str("guilds/")?;
3042 Display::fmt(guild_id, f)?;
3043 f.write_str("/integrations/")?;
3044 Display::fmt(integration_id, f)?;
3045
3046 f.write_str("/sync")
3047 }
3048 Route::UpdateCurrentMember { guild_id } => {
3049 f.write_str("guilds/")?;
3050 Display::fmt(guild_id, f)?;
3051
3052 f.write_str("/members/@me")
3053 }
3054 Route::GetCurrentUserVoiceState { guild_id }
3055 | Route::UpdateCurrentUserVoiceState { guild_id } => {
3056 f.write_str("guilds/")?;
3057 Display::fmt(guild_id, f)?;
3058
3059 f.write_str("/voice-states/@me")
3060 }
3061 Route::DeleteGuildScheduledEvent {
3062 guild_id,
3063 scheduled_event_id,
3064 }
3065 | Route::UpdateGuildScheduledEvent {
3066 guild_id,
3067 scheduled_event_id,
3068 } => {
3069 f.write_str("guilds/")?;
3070 Display::fmt(guild_id, f)?;
3071 f.write_str("/scheduled-events/")?;
3072
3073 Display::fmt(scheduled_event_id, f)
3074 }
3075 Route::UpdateNickname { guild_id } => {
3076 f.write_str("guilds/")?;
3077 Display::fmt(guild_id, f)?;
3078
3079 f.write_str("/members/@me/nick")
3080 }
3081 Route::GetUserVoiceState { guild_id, user_id }
3082 | Route::UpdateUserVoiceState { guild_id, user_id } => {
3083 f.write_str("guilds/")?;
3084 Display::fmt(guild_id, f)?;
3085 f.write_str("/voice-states/")?;
3086
3087 Display::fmt(user_id, f)
3088 }
3089 Route::UpdateGuildMfa { guild_id, .. } => {
3090 f.write_str("guilds/")?;
3091 Display::fmt(guild_id, f)?;
3092
3093 f.write_str("/mfa")
3094 }
3095 Route::GetSKUs { application_id } => {
3096 f.write_str("applications/")?;
3097 Display::fmt(application_id, f)?;
3098
3099 f.write_str("/skus")
3100 }
3101 Route::GetSKUSubscriptions {
3102 after,
3103 before,
3104 limit,
3105 sku_id,
3106 user_id,
3107 } => {
3108 f.write_str("skus/")?;
3109 Display::fmt(sku_id, f)?;
3110 f.write_str("/subscriptions")?;
3111
3112 let mut writer = QueryStringFormatter::new(f);
3113 writer.write_opt_param("after", after.as_ref())?;
3114 writer.write_opt_param("before", before.as_ref())?;
3115 writer.write_opt_param("limit", limit.as_ref())?;
3116
3117 writer.write_opt_param("user_id", user_id.as_ref())
3118 }
3119 Route::GetSKUSubscription {
3120 sku_id,
3121 subscription_id,
3122 } => {
3123 f.write_str("skus/")?;
3124 Display::fmt(sku_id, f)?;
3125 f.write_str("/subscriptions/")?;
3126
3127 Display::fmt(subscription_id, f)
3128 }
3129 }
3130 }
3131}
3132
3133#[cfg(test)]
3134mod tests {
3135 use super::Route;
3136 use crate::request::{Method, channel::reaction::RequestReactionType};
3137 use twilight_model::{
3138 http::message_search::{
3139 AuthorType, SearchEmbedType, SearchFilter, SearchHasType, SearchSortMode,
3140 SearchSortOrder,
3141 },
3142 id::Id,
3143 };
3144
3145 #[test]
3147 fn methods() {
3148 assert_eq!(
3149 Method::Delete,
3150 Route::DeleteInvite {
3151 code: "twilight-rs",
3152 }
3153 .method()
3154 );
3155 assert_eq!(
3156 Method::Get,
3157 Route::GetInvite {
3158 code: "twilight-rs",
3159 with_counts: false,
3160 }
3161 .method()
3162 );
3163 assert_eq!(
3164 Method::Patch,
3165 Route::UpdateMessage {
3166 channel_id: 123,
3167 message_id: 456,
3168 }
3169 .method()
3170 );
3171 assert_eq!(Method::Post, Route::CreateGuild.method());
3172 assert_eq!(
3173 Method::Put,
3174 Route::SyncTemplate {
3175 guild_id: 123,
3176 template_code: "abc",
3177 }
3178 .method()
3179 );
3180 }
3181
3182 const APPLICATION_ID: u64 = 1;
3185 const CHANNEL_ID: u64 = 2;
3186 const CODE: &str = "invitecode";
3187 const COMMAND_ID: u64 = 3;
3188 const EMOJI_ID: u64 = 4;
3189 const GUILD_ID: u64 = 5;
3190 const INTERACTION_ID: u64 = 6;
3191 const INTERACTION_TOKEN: &str = "interactiontoken";
3192 const INTEGRATION_ID: u64 = 7;
3193 const MESSAGE_ID: u64 = 8;
3194 const ROLE_ID: u64 = 9;
3195 const STICKER_ID: u64 = 10;
3196 const TEMPLATE_CODE: &str = "templatecode";
3197 const USER_ID: u64 = 11;
3198 const SCHEDULED_EVENT_ID: u64 = 12;
3199 const AUTO_MODERATION_RULE_ID: u64 = 13;
3200 const STICKER_PACK_ID: u64 = 14;
3201 const SKU_ID: u64 = 15;
3202 const SUBSCRIPTION_ID: u64 = 16;
3203 const ENTITLEMENT_ID: u64 = 17;
3204
3205 const fn emoji() -> RequestReactionType<'static> {
3206 RequestReactionType::Custom {
3207 id: Id::new(EMOJI_ID),
3208 name: None,
3209 }
3210 }
3211
3212 #[test]
3213 fn get_public_archived_threads() {
3214 let route = Route::GetPublicArchivedThreads {
3215 channel_id: 1,
3216 before: Some("2021-01-01T00:00:00Z"),
3217 limit: None,
3218 };
3219
3220 assert_eq!(
3221 "channels/1/threads/archived/public?before=2021-01-01T00:00:00Z",
3222 route.to_string()
3223 );
3224 }
3225
3226 #[test]
3227 fn update_webhook_message_thread_id() {
3228 let route = Route::UpdateWebhookMessage {
3229 message_id: 1,
3230 thread_id: Some(2),
3231 token: "token",
3232 webhook_id: 3,
3233 };
3234
3235 assert_eq!("webhooks/3/token/messages/1?thread_id=2", route.to_string());
3236 }
3237
3238 #[test]
3239 fn add_guild_member() {
3240 let route = Route::AddGuildMember {
3241 guild_id: GUILD_ID,
3242 user_id: USER_ID,
3243 };
3244 assert_eq!(
3245 route.to_string(),
3246 format!("guilds/{GUILD_ID}/members/{USER_ID}")
3247 );
3248 }
3249
3250 #[test]
3251 fn get_member() {
3252 let route = Route::GetMember {
3253 guild_id: GUILD_ID,
3254 user_id: USER_ID,
3255 };
3256 assert_eq!(
3257 route.to_string(),
3258 format!("guilds/{GUILD_ID}/members/{USER_ID}")
3259 );
3260 }
3261
3262 #[test]
3263 fn remove_member() {
3264 let route = Route::RemoveMember {
3265 guild_id: GUILD_ID,
3266 user_id: USER_ID,
3267 };
3268 assert_eq!(
3269 route.to_string(),
3270 format!("guilds/{GUILD_ID}/members/{USER_ID}")
3271 );
3272 }
3273
3274 #[test]
3275 fn update_member() {
3276 let route = Route::UpdateMember {
3277 guild_id: GUILD_ID,
3278 user_id: USER_ID,
3279 };
3280 assert_eq!(
3281 route.to_string(),
3282 format!("guilds/{GUILD_ID}/members/{USER_ID}")
3283 );
3284 }
3285
3286 #[test]
3287 fn add_member_role() {
3288 let route = Route::AddMemberRole {
3289 guild_id: GUILD_ID,
3290 role_id: ROLE_ID,
3291 user_id: USER_ID,
3292 };
3293 assert_eq!(
3294 route.to_string(),
3295 format!("guilds/{GUILD_ID}/members/{USER_ID}/roles/{ROLE_ID}")
3296 );
3297 }
3298
3299 #[test]
3300 fn remove_member_role() {
3301 let route = Route::RemoveMemberRole {
3302 guild_id: GUILD_ID,
3303 role_id: ROLE_ID,
3304 user_id: USER_ID,
3305 };
3306 assert_eq!(
3307 route.to_string(),
3308 format!("guilds/{GUILD_ID}/members/{USER_ID}/roles/{ROLE_ID}")
3309 );
3310 }
3311
3312 #[test]
3313 fn add_thread_member() {
3314 let route = Route::AddThreadMember {
3315 channel_id: CHANNEL_ID,
3316 user_id: USER_ID,
3317 };
3318 assert_eq!(
3319 route.to_string(),
3320 format!("channels/{CHANNEL_ID}/thread-members/{USER_ID}")
3321 );
3322 }
3323
3324 #[test]
3325 fn get_thread_member() {
3326 let route = Route::GetThreadMember {
3327 channel_id: CHANNEL_ID,
3328 user_id: USER_ID,
3329 };
3330 assert_eq!(
3331 route.to_string(),
3332 format!("channels/{CHANNEL_ID}/thread-members/{USER_ID}")
3333 );
3334 }
3335
3336 #[test]
3337 fn remove_thread_member() {
3338 let route = Route::RemoveThreadMember {
3339 channel_id: CHANNEL_ID,
3340 user_id: USER_ID,
3341 };
3342 assert_eq!(
3343 route.to_string(),
3344 format!("channels/{CHANNEL_ID}/thread-members/{USER_ID}")
3345 );
3346 }
3347
3348 #[test]
3349 fn create_channel() {
3350 let route = Route::CreateChannel { guild_id: GUILD_ID };
3351 assert_eq!(route.to_string(), format!("guilds/{GUILD_ID}/channels"));
3352 }
3353
3354 #[test]
3355 fn get_channels() {
3356 let route = Route::GetChannels { guild_id: GUILD_ID };
3357 assert_eq!(route.to_string(), format!("guilds/{GUILD_ID}/channels"));
3358 }
3359
3360 #[test]
3361 fn update_guild_channels() {
3362 let route = Route::UpdateGuildChannels { guild_id: GUILD_ID };
3363 assert_eq!(route.to_string(), format!("guilds/{GUILD_ID}/channels"));
3364 }
3365
3366 #[test]
3367 fn create_emoji() {
3368 let route = Route::CreateEmoji { guild_id: GUILD_ID };
3369 assert_eq!(route.to_string(), format!("guilds/{GUILD_ID}/emojis"));
3370 }
3371
3372 #[test]
3373 fn get_emojis() {
3374 let route = Route::GetEmojis { guild_id: GUILD_ID };
3375 assert_eq!(route.to_string(), format!("guilds/{GUILD_ID}/emojis"));
3376 }
3377
3378 #[test]
3379 fn create_global_command() {
3380 let route = Route::CreateGlobalCommand {
3381 application_id: APPLICATION_ID,
3382 };
3383 assert_eq!(
3384 route.to_string(),
3385 format!("applications/{APPLICATION_ID}/commands")
3386 );
3387 }
3388
3389 #[test]
3390 fn get_global_commands() {
3391 let route = Route::GetGlobalCommands {
3392 application_id: APPLICATION_ID,
3393 with_localizations: Some(true),
3394 };
3395 assert_eq!(
3396 route.to_string(),
3397 format!("applications/{APPLICATION_ID}/commands?with_localizations=true")
3398 );
3399
3400 let route = Route::GetGlobalCommands {
3401 application_id: APPLICATION_ID,
3402 with_localizations: None,
3403 };
3404 assert_eq!(
3405 route.to_string(),
3406 format!("applications/{APPLICATION_ID}/commands")
3407 );
3408 }
3409
3410 #[test]
3411 fn set_global_commands() {
3412 let route = Route::SetGlobalCommands {
3413 application_id: APPLICATION_ID,
3414 };
3415 assert_eq!(
3416 route.to_string(),
3417 format!("applications/{APPLICATION_ID}/commands")
3418 );
3419 }
3420
3421 #[test]
3422 fn create_guild() {
3423 let route = Route::CreateGuild;
3424 assert_eq!(route.to_string(), "guilds");
3425 }
3426
3427 #[test]
3428 fn create_guild_command() {
3429 let route = Route::CreateGuildCommand {
3430 application_id: APPLICATION_ID,
3431 guild_id: GUILD_ID,
3432 };
3433 assert_eq!(
3434 route.to_string(),
3435 format!("applications/{APPLICATION_ID}/guilds/{GUILD_ID}/commands")
3436 );
3437 }
3438
3439 #[test]
3440 fn get_guild_commands() {
3441 let route = Route::GetGuildCommands {
3442 application_id: APPLICATION_ID,
3443 guild_id: GUILD_ID,
3444 with_localizations: Some(true),
3445 };
3446 assert_eq!(
3447 route.to_string(),
3448 format!(
3449 "applications/{APPLICATION_ID}/guilds/{GUILD_ID}/commands?with_localizations=true"
3450 )
3451 );
3452
3453 let route = Route::GetGuildCommands {
3454 application_id: APPLICATION_ID,
3455 guild_id: GUILD_ID,
3456 with_localizations: None,
3457 };
3458 assert_eq!(
3459 route.to_string(),
3460 format!("applications/{APPLICATION_ID}/guilds/{GUILD_ID}/commands")
3461 );
3462 }
3463
3464 #[test]
3465 fn set_guild_commands() {
3466 let route = Route::SetGuildCommands {
3467 application_id: APPLICATION_ID,
3468 guild_id: GUILD_ID,
3469 };
3470 assert_eq!(
3471 route.to_string(),
3472 format!("applications/{APPLICATION_ID}/guilds/{GUILD_ID}/commands")
3473 );
3474 }
3475
3476 #[test]
3477 fn create_guild_from_template() {
3478 let route = Route::CreateGuildFromTemplate {
3479 template_code: TEMPLATE_CODE,
3480 };
3481 assert_eq!(
3482 route.to_string(),
3483 format!("guilds/templates/{TEMPLATE_CODE}")
3484 );
3485 }
3486
3487 #[test]
3488 fn get_template() {
3489 let route = Route::GetTemplate {
3490 template_code: TEMPLATE_CODE,
3491 };
3492 assert_eq!(
3493 route.to_string(),
3494 format!("guilds/templates/{TEMPLATE_CODE}")
3495 );
3496 }
3497
3498 #[test]
3499 fn create_guild_integration() {
3500 let route = Route::CreateGuildIntegration { guild_id: GUILD_ID };
3501 assert_eq!(route.to_string(), format!("guilds/{GUILD_ID}/integrations"));
3502 }
3503
3504 #[test]
3505 fn get_guild_integrations() {
3506 let route = Route::GetGuildIntegrations { guild_id: GUILD_ID };
3507 assert_eq!(route.to_string(), format!("guilds/{GUILD_ID}/integrations"));
3508 }
3509
3510 #[test]
3511 fn create_guild_sticker() {
3512 let route = Route::CreateGuildSticker { guild_id: GUILD_ID };
3513 assert_eq!(route.to_string(), format!("guilds/{GUILD_ID}/stickers"));
3514 }
3515
3516 #[test]
3517 fn get_guild_stickers() {
3518 let route = Route::GetGuildStickers { guild_id: GUILD_ID };
3519 assert_eq!(route.to_string(), format!("guilds/{GUILD_ID}/stickers"));
3520 }
3521
3522 #[test]
3523 fn create_invite() {
3524 let route = Route::CreateInvite {
3525 channel_id: CHANNEL_ID,
3526 };
3527 assert_eq!(route.to_string(), format!("channels/{CHANNEL_ID}/invites"));
3528 }
3529
3530 #[test]
3531 fn get_channel_invites() {
3532 let route = Route::GetChannelInvites {
3533 channel_id: CHANNEL_ID,
3534 };
3535 assert_eq!(route.to_string(), format!("channels/{CHANNEL_ID}/invites"));
3536 }
3537
3538 #[test]
3539 fn create_message() {
3540 let route = Route::CreateMessage {
3541 channel_id: CHANNEL_ID,
3542 };
3543 assert_eq!(route.to_string(), format!("channels/{CHANNEL_ID}/messages"));
3544 }
3545
3546 #[test]
3547 fn create_private_channel() {
3548 let route = Route::CreatePrivateChannel;
3549 assert_eq!(route.to_string(), "users/@me/channels");
3550 }
3551
3552 #[test]
3553 fn get_user_private_channels() {
3554 let route = Route::GetUserPrivateChannels;
3555 assert_eq!(route.to_string(), "users/@me/channels");
3556 }
3557
3558 #[test]
3559 fn create_reaction() {
3560 let emoji = emoji();
3561
3562 let route = Route::CreateReaction {
3563 channel_id: CHANNEL_ID,
3564 emoji: &emoji,
3565 message_id: MESSAGE_ID,
3566 };
3567 assert_eq!(
3568 route.to_string(),
3569 format!("channels/{CHANNEL_ID}/messages/{MESSAGE_ID}/reactions/{emoji}/@me")
3570 );
3571 }
3572
3573 #[test]
3574 fn delete_reaction_current_user() {
3575 let emoji = emoji();
3576
3577 let route = Route::DeleteReactionCurrentUser {
3578 channel_id: CHANNEL_ID,
3579 emoji: &emoji,
3580 message_id: MESSAGE_ID,
3581 };
3582 assert_eq!(
3583 route.to_string(),
3584 format!("channels/{CHANNEL_ID}/messages/{MESSAGE_ID}/reactions/{emoji}/@me")
3585 );
3586 }
3587
3588 #[test]
3589 fn create_role() {
3590 let route = Route::CreateRole { guild_id: GUILD_ID };
3591 assert_eq!(route.to_string(), format!("guilds/{GUILD_ID}/roles"));
3592 }
3593
3594 #[test]
3595 fn get_guild_roles() {
3596 let route = Route::GetGuildRoles { guild_id: GUILD_ID };
3597 assert_eq!(route.to_string(), format!("guilds/{GUILD_ID}/roles"));
3598 }
3599
3600 #[test]
3601 fn update_role_positions() {
3602 let route = Route::UpdateRolePositions { guild_id: GUILD_ID };
3603 assert_eq!(route.to_string(), format!("guilds/{GUILD_ID}/roles"));
3604 }
3605
3606 #[test]
3607 fn create_stage_instance() {
3608 let route = Route::CreateStageInstance;
3609 assert_eq!(route.to_string(), "stage-instances");
3610 }
3611
3612 #[test]
3613 fn create_template() {
3614 let route = Route::CreateTemplate { guild_id: GUILD_ID };
3615 assert_eq!(route.to_string(), format!("guilds/{GUILD_ID}/templates"));
3616 }
3617
3618 #[test]
3619 fn get_templates() {
3620 let route = Route::GetTemplates { guild_id: GUILD_ID };
3621 assert_eq!(route.to_string(), format!("guilds/{GUILD_ID}/templates"));
3622 }
3623
3624 #[test]
3625 fn create_thread() {
3626 let route = Route::CreateThread {
3627 channel_id: CHANNEL_ID,
3628 };
3629 assert_eq!(route.to_string(), format!("channels/{CHANNEL_ID}/threads"));
3630 }
3631
3632 #[test]
3633 fn create_thread_from_message() {
3634 let route = Route::CreateThreadFromMessage {
3635 channel_id: CHANNEL_ID,
3636 message_id: MESSAGE_ID,
3637 };
3638 assert_eq!(
3639 route.to_string(),
3640 format!("channels/{CHANNEL_ID}/messages/{MESSAGE_ID}/threads")
3641 );
3642 }
3643
3644 #[test]
3645 fn create_typing_trigger() {
3646 let route = Route::CreateTypingTrigger {
3647 channel_id: CHANNEL_ID,
3648 };
3649 assert_eq!(route.to_string(), format!("channels/{CHANNEL_ID}/typing"));
3650 }
3651
3652 #[test]
3653 fn create_webhook() {
3654 let route = Route::CreateWebhook {
3655 channel_id: CHANNEL_ID,
3656 };
3657 assert_eq!(route.to_string(), format!("channels/{CHANNEL_ID}/webhooks"));
3658 }
3659
3660 #[test]
3661 fn get_channel_webhooks() {
3662 let route = Route::GetChannelWebhooks {
3663 channel_id: CHANNEL_ID,
3664 };
3665 assert_eq!(route.to_string(), format!("channels/{CHANNEL_ID}/webhooks"));
3666 }
3667
3668 #[test]
3669 fn crosspost_message() {
3670 let route = Route::CrosspostMessage {
3671 channel_id: CHANNEL_ID,
3672 message_id: MESSAGE_ID,
3673 };
3674 assert_eq!(
3675 route.to_string(),
3676 format!("channels/{CHANNEL_ID}/messages/{MESSAGE_ID}/crosspost")
3677 );
3678 }
3679
3680 #[test]
3681 fn delete_ban() {
3682 let route = Route::DeleteBan {
3683 guild_id: GUILD_ID,
3684 user_id: USER_ID,
3685 };
3686 assert_eq!(
3687 route.to_string(),
3688 format!("guilds/{GUILD_ID}/bans/{USER_ID}")
3689 );
3690 }
3691
3692 #[test]
3693 fn get_ban() {
3694 let route = Route::GetBan {
3695 guild_id: GUILD_ID,
3696 user_id: USER_ID,
3697 };
3698 assert_eq!(
3699 route.to_string(),
3700 format!("guilds/{GUILD_ID}/bans/{USER_ID}")
3701 );
3702 }
3703
3704 #[test]
3705 fn delete_channel() {
3706 let route = Route::DeleteChannel {
3707 channel_id: CHANNEL_ID,
3708 };
3709 assert_eq!(route.to_string(), format!("channels/{CHANNEL_ID}"));
3710 }
3711
3712 #[test]
3713 fn get_channel() {
3714 let route = Route::GetChannel {
3715 channel_id: CHANNEL_ID,
3716 };
3717 assert_eq!(route.to_string(), format!("channels/{CHANNEL_ID}"));
3718 }
3719
3720 #[test]
3721 fn update_channel() {
3722 let route = Route::UpdateChannel {
3723 channel_id: CHANNEL_ID,
3724 };
3725 assert_eq!(route.to_string(), format!("channels/{CHANNEL_ID}"));
3726 }
3727
3728 #[test]
3729 fn delete_emoji() {
3730 let route = Route::DeleteEmoji {
3731 emoji_id: EMOJI_ID,
3732 guild_id: GUILD_ID,
3733 };
3734 assert_eq!(
3735 route.to_string(),
3736 format!("guilds/{GUILD_ID}/emojis/{EMOJI_ID}")
3737 );
3738 }
3739
3740 #[test]
3741 fn get_emoji() {
3742 let route = Route::GetEmoji {
3743 emoji_id: EMOJI_ID,
3744 guild_id: GUILD_ID,
3745 };
3746 assert_eq!(
3747 route.to_string(),
3748 format!("guilds/{GUILD_ID}/emojis/{EMOJI_ID}")
3749 );
3750 }
3751
3752 #[test]
3753 fn update_emoji() {
3754 let route = Route::UpdateEmoji {
3755 emoji_id: EMOJI_ID,
3756 guild_id: GUILD_ID,
3757 };
3758 assert_eq!(
3759 route.to_string(),
3760 format!("guilds/{GUILD_ID}/emojis/{EMOJI_ID}")
3761 );
3762 }
3763
3764 #[test]
3765 fn delete_global_command() {
3766 let route = Route::DeleteGlobalCommand {
3767 application_id: APPLICATION_ID,
3768 command_id: COMMAND_ID,
3769 };
3770 assert_eq!(
3771 route.to_string(),
3772 format!("applications/{APPLICATION_ID}/commands/{COMMAND_ID}")
3773 );
3774 }
3775
3776 #[test]
3777 fn get_global_command() {
3778 let route = Route::GetGlobalCommand {
3779 application_id: APPLICATION_ID,
3780 command_id: COMMAND_ID,
3781 };
3782 assert_eq!(
3783 route.to_string(),
3784 format!("applications/{APPLICATION_ID}/commands/{COMMAND_ID}")
3785 );
3786 }
3787
3788 #[test]
3789 fn update_global_command() {
3790 let route = Route::UpdateGlobalCommand {
3791 application_id: APPLICATION_ID,
3792 command_id: COMMAND_ID,
3793 };
3794 assert_eq!(
3795 route.to_string(),
3796 format!("applications/{APPLICATION_ID}/commands/{COMMAND_ID}")
3797 );
3798 }
3799
3800 #[test]
3801 fn delete_guild() {
3802 let route = Route::DeleteGuild { guild_id: GUILD_ID };
3803 assert_eq!(route.to_string(), format!("guilds/{GUILD_ID}"));
3804 }
3805
3806 #[test]
3807 fn update_guild() {
3808 let route = Route::UpdateGuild { guild_id: GUILD_ID };
3809 assert_eq!(route.to_string(), format!("guilds/{GUILD_ID}"));
3810 }
3811
3812 #[test]
3813 fn delete_guild_command() {
3814 let route = Route::DeleteGuildCommand {
3815 application_id: APPLICATION_ID,
3816 command_id: COMMAND_ID,
3817 guild_id: GUILD_ID,
3818 };
3819 assert_eq!(
3820 route.to_string(),
3821 format!("applications/{APPLICATION_ID}/guilds/{GUILD_ID}/commands/{COMMAND_ID}")
3822 );
3823 }
3824
3825 #[test]
3826 fn get_guild_command() {
3827 let route = Route::GetGuildCommand {
3828 application_id: APPLICATION_ID,
3829 command_id: COMMAND_ID,
3830 guild_id: GUILD_ID,
3831 };
3832 assert_eq!(
3833 route.to_string(),
3834 format!("applications/{APPLICATION_ID}/guilds/{GUILD_ID}/commands/{COMMAND_ID}")
3835 );
3836 }
3837
3838 #[test]
3839 fn update_guild_command() {
3840 let route = Route::UpdateGuildCommand {
3841 application_id: APPLICATION_ID,
3842 command_id: COMMAND_ID,
3843 guild_id: GUILD_ID,
3844 };
3845 assert_eq!(
3846 route.to_string(),
3847 format!("applications/{APPLICATION_ID}/guilds/{GUILD_ID}/commands/{COMMAND_ID}")
3848 );
3849 }
3850
3851 #[test]
3852 fn delete_guild_integration() {
3853 let route = Route::DeleteGuildIntegration {
3854 guild_id: GUILD_ID,
3855 integration_id: INTEGRATION_ID,
3856 };
3857 assert_eq!(
3858 route.to_string(),
3859 format!("guilds/{GUILD_ID}/integrations/{INTEGRATION_ID}")
3860 );
3861 }
3862
3863 #[test]
3864 fn update_guild_integration() {
3865 let route = Route::UpdateGuildIntegration {
3866 guild_id: GUILD_ID,
3867 integration_id: INTEGRATION_ID,
3868 };
3869 assert_eq!(
3870 route.to_string(),
3871 format!("guilds/{GUILD_ID}/integrations/{INTEGRATION_ID}")
3872 );
3873 }
3874
3875 #[test]
3876 fn delete_interaction_original() {
3877 let route = Route::DeleteInteractionOriginal {
3878 application_id: APPLICATION_ID,
3879 interaction_token: INTERACTION_TOKEN,
3880 };
3881 assert_eq!(
3882 route.to_string(),
3883 format!("webhooks/{APPLICATION_ID}/{INTERACTION_TOKEN}/messages/@original")
3884 );
3885 }
3886
3887 #[test]
3888 fn get_interaction_original() {
3889 let route = Route::GetInteractionOriginal {
3890 application_id: APPLICATION_ID,
3891 interaction_token: INTERACTION_TOKEN,
3892 };
3893 assert_eq!(
3894 route.to_string(),
3895 format!("webhooks/{APPLICATION_ID}/{INTERACTION_TOKEN}/messages/@original")
3896 );
3897 }
3898
3899 #[test]
3900 fn update_interaction_original() {
3901 let route = Route::UpdateInteractionOriginal {
3902 application_id: APPLICATION_ID,
3903 interaction_token: INTERACTION_TOKEN,
3904 };
3905 assert_eq!(
3906 route.to_string(),
3907 format!("webhooks/{APPLICATION_ID}/{INTERACTION_TOKEN}/messages/@original")
3908 );
3909 }
3910
3911 #[test]
3912 fn delete_invite() {
3913 let route = Route::DeleteInvite { code: CODE };
3914 assert_eq!(route.to_string(), format!("invites/{CODE}"));
3915 }
3916
3917 #[test]
3918 fn delete_message_reactions() {
3919 let route = Route::DeleteMessageReactions {
3920 channel_id: CHANNEL_ID,
3921 message_id: MESSAGE_ID,
3922 };
3923 assert_eq!(
3924 route.to_string(),
3925 format!("channels/{CHANNEL_ID}/messages/{MESSAGE_ID}/reactions")
3926 );
3927 }
3928
3929 #[test]
3930 fn delete_message_specific_reaction() {
3931 let emoji = emoji();
3932
3933 let route = Route::DeleteMessageSpecificReaction {
3934 channel_id: CHANNEL_ID,
3935 message_id: MESSAGE_ID,
3936 emoji: &emoji,
3937 };
3938 assert_eq!(
3939 route.to_string(),
3940 format!("channels/{CHANNEL_ID}/messages/{MESSAGE_ID}/reactions/{emoji}")
3941 );
3942 }
3943
3944 #[test]
3945 fn delete_message() {
3946 let route = Route::DeleteMessage {
3947 channel_id: CHANNEL_ID,
3948 message_id: MESSAGE_ID,
3949 };
3950 assert_eq!(
3951 route.to_string(),
3952 format!("channels/{CHANNEL_ID}/messages/{MESSAGE_ID}")
3953 );
3954 }
3955
3956 #[test]
3957 fn get_message() {
3958 let route = Route::GetMessage {
3959 channel_id: CHANNEL_ID,
3960 message_id: MESSAGE_ID,
3961 };
3962 assert_eq!(
3963 route.to_string(),
3964 format!("channels/{CHANNEL_ID}/messages/{MESSAGE_ID}")
3965 );
3966 }
3967
3968 #[test]
3969 fn update_message() {
3970 let route = Route::UpdateMessage {
3971 channel_id: CHANNEL_ID,
3972 message_id: MESSAGE_ID,
3973 };
3974 assert_eq!(
3975 route.to_string(),
3976 format!("channels/{CHANNEL_ID}/messages/{MESSAGE_ID}")
3977 );
3978 }
3979
3980 #[test]
3981 fn delete_messages() {
3982 let route = Route::DeleteMessages {
3983 channel_id: CHANNEL_ID,
3984 };
3985 assert_eq!(
3986 route.to_string(),
3987 format!("channels/{CHANNEL_ID}/messages/bulk-delete")
3988 );
3989 }
3990
3991 #[test]
3992 fn delete_permission_overwrite() {
3993 let route = Route::DeletePermissionOverwrite {
3994 channel_id: CHANNEL_ID,
3995 target_id: ROLE_ID,
3996 };
3997 assert_eq!(
3998 route.to_string(),
3999 format!("channels/{CHANNEL_ID}/permissions/{ROLE_ID}")
4000 );
4001 }
4002
4003 #[test]
4004 fn update_permission_overwrite() {
4005 let route = Route::UpdatePermissionOverwrite {
4006 channel_id: CHANNEL_ID,
4007 target_id: USER_ID,
4008 };
4009 assert_eq!(
4010 route.to_string(),
4011 format!("channels/{CHANNEL_ID}/permissions/{USER_ID}")
4012 );
4013 }
4014
4015 #[test]
4016 fn delete_reaction() {
4017 let emoji = emoji();
4018
4019 let route = Route::DeleteReaction {
4020 channel_id: CHANNEL_ID,
4021 emoji: &emoji,
4022 message_id: MESSAGE_ID,
4023 user_id: USER_ID,
4024 };
4025 assert_eq!(
4026 route.to_string(),
4027 format!("channels/{CHANNEL_ID}/messages/{MESSAGE_ID}/reactions/{emoji}/{USER_ID}")
4028 );
4029 }
4030
4031 #[test]
4032 fn delete_role() {
4033 let route = Route::DeleteRole {
4034 guild_id: GUILD_ID,
4035 role_id: ROLE_ID,
4036 };
4037 assert_eq!(
4038 route.to_string(),
4039 format!("guilds/{GUILD_ID}/roles/{ROLE_ID}")
4040 );
4041 }
4042
4043 #[test]
4044 fn update_role() {
4045 let route = Route::UpdateRole {
4046 guild_id: GUILD_ID,
4047 role_id: ROLE_ID,
4048 };
4049 assert_eq!(
4050 route.to_string(),
4051 format!("guilds/{GUILD_ID}/roles/{ROLE_ID}")
4052 );
4053 }
4054
4055 #[test]
4056 fn delete_stage_instance() {
4057 let route = Route::DeleteStageInstance {
4058 channel_id: CHANNEL_ID,
4059 };
4060 assert_eq!(route.to_string(), format!("stage-instances/{CHANNEL_ID}"));
4061 }
4062
4063 #[test]
4064 fn get_stage_instance() {
4065 let route = Route::GetStageInstance {
4066 channel_id: CHANNEL_ID,
4067 };
4068 assert_eq!(route.to_string(), format!("stage-instances/{CHANNEL_ID}"));
4069 }
4070
4071 #[test]
4072 fn update_stage_instance() {
4073 let route = Route::UpdateStageInstance {
4074 channel_id: CHANNEL_ID,
4075 };
4076 assert_eq!(route.to_string(), format!("stage-instances/{CHANNEL_ID}"));
4077 }
4078
4079 #[test]
4080 fn delete_template() {
4081 let route = Route::DeleteTemplate {
4082 guild_id: GUILD_ID,
4083 template_code: TEMPLATE_CODE,
4084 };
4085 assert_eq!(
4086 route.to_string(),
4087 format!("guilds/{GUILD_ID}/templates/{TEMPLATE_CODE}")
4088 );
4089 }
4090
4091 #[test]
4092 fn sync_template() {
4093 let route = Route::SyncTemplate {
4094 guild_id: GUILD_ID,
4095 template_code: TEMPLATE_CODE,
4096 };
4097 assert_eq!(
4098 route.to_string(),
4099 format!("guilds/{GUILD_ID}/templates/{TEMPLATE_CODE}")
4100 );
4101 }
4102
4103 #[test]
4104 fn update_template() {
4105 let route = Route::UpdateTemplate {
4106 guild_id: GUILD_ID,
4107 template_code: TEMPLATE_CODE,
4108 };
4109 assert_eq!(
4110 route.to_string(),
4111 format!("guilds/{GUILD_ID}/templates/{TEMPLATE_CODE}")
4112 );
4113 }
4114
4115 #[test]
4116 fn follow_news_channel() {
4117 let route = Route::FollowNewsChannel {
4118 channel_id: CHANNEL_ID,
4119 };
4120 assert_eq!(
4121 route.to_string(),
4122 format!("channels/{CHANNEL_ID}/followers")
4123 );
4124 }
4125
4126 #[test]
4127 fn get_active_threads() {
4128 let route = Route::GetActiveThreads { guild_id: GUILD_ID };
4129 assert_eq!(
4130 route.to_string(),
4131 format!("guilds/{GUILD_ID}/threads/active")
4132 );
4133 }
4134
4135 #[test]
4136 fn get_bans() {
4137 let route = Route::GetBans { guild_id: GUILD_ID };
4138 assert_eq!(route.to_string(), format!("guilds/{GUILD_ID}/bans"));
4139 }
4140
4141 #[test]
4142 fn get_bans_with_parameters() {
4143 let route = Route::GetBansWithParameters {
4144 after: None,
4145 before: None,
4146 guild_id: GUILD_ID,
4147 limit: None,
4148 };
4149 assert_eq!(route.to_string(), format!("guilds/{GUILD_ID}/bans"));
4150
4151 let route = Route::GetBansWithParameters {
4152 after: Some(USER_ID),
4153 before: None,
4154 guild_id: GUILD_ID,
4155 limit: None,
4156 };
4157 assert_eq!(
4158 route.to_string(),
4159 format!("guilds/{GUILD_ID}/bans?after={USER_ID}")
4160 );
4161
4162 let route = Route::GetBansWithParameters {
4163 after: None,
4164 before: Some(USER_ID),
4165 guild_id: GUILD_ID,
4166 limit: None,
4167 };
4168 assert_eq!(
4169 route.to_string(),
4170 format!("guilds/{GUILD_ID}/bans?before={USER_ID}")
4171 );
4172
4173 let route = Route::GetBansWithParameters {
4174 after: None,
4175 before: None,
4176 guild_id: GUILD_ID,
4177 limit: Some(100),
4178 };
4179 assert_eq!(
4180 route.to_string(),
4181 format!("guilds/{GUILD_ID}/bans?limit={limit}", limit = 100)
4182 );
4183
4184 let route = Route::GetBansWithParameters {
4185 after: Some(USER_ID),
4186 before: Some(USER_ID + 100),
4187 guild_id: GUILD_ID,
4188 limit: Some(25),
4189 };
4190 assert_eq!(
4191 route.to_string(),
4192 format!(
4193 "guilds/{GUILD_ID}/bans?after={USER_ID}&before={before}&limit={limit}",
4194 before = USER_ID + 100,
4195 limit = 25,
4196 )
4197 );
4198 }
4199
4200 #[test]
4201 fn get_gateway_bot() {
4202 let route = Route::GetGatewayBot;
4203 assert_eq!(route.to_string(), "gateway/bot");
4204 }
4205
4206 #[test]
4207 fn get_entitlements() {
4208 let route = Route::GetEntitlements {
4209 after: Some(32),
4210 application_id: 1,
4211 before: Some(2),
4212 exclude_deleted: Some(true),
4213 exclude_ended: Some(true),
4214 guild_id: Some(42),
4215 limit: Some(99),
4216 sku_ids: &[Id::new(7)],
4217 user_id: Some(11),
4218 };
4219
4220 assert_eq!(
4221 route.to_string(),
4222 "applications/1/entitlements?after=32&before=2&exclude_deleted=true&exclude_ended=true&guild_id=42&limit=99&sku_ids=7&user_id=11"
4223 );
4224 }
4225
4226 #[test]
4227 fn get_entitlement() {
4228 let route = Route::GetEntitlement {
4229 application_id: APPLICATION_ID,
4230 entitlement_id: ENTITLEMENT_ID,
4231 };
4232 assert_eq!(
4233 route.to_string(),
4234 format!("applications/{APPLICATION_ID}/entitlements/{ENTITLEMENT_ID}")
4235 );
4236 assert_eq!(Method::Get, route.method());
4237 }
4238
4239 #[test]
4240 fn create_test_entitlement() {
4241 let route = Route::CreateTestEntitlement { application_id: 1 };
4242
4243 assert_eq!(route.to_string(), "applications/1/entitlements");
4244 }
4245
4246 #[test]
4247 fn get_command_permissions() {
4248 let route = Route::GetCommandPermissions {
4249 application_id: APPLICATION_ID,
4250 command_id: COMMAND_ID,
4251 guild_id: GUILD_ID,
4252 };
4253 assert_eq!(
4254 route.to_string(),
4255 format!(
4256 "applications/{APPLICATION_ID}/guilds/{GUILD_ID}/commands/{COMMAND_ID}/permissions"
4257 )
4258 );
4259 }
4260
4261 #[test]
4262 fn update_command_permissions() {
4263 let route = Route::UpdateCommandPermissions {
4264 application_id: APPLICATION_ID,
4265 command_id: COMMAND_ID,
4266 guild_id: GUILD_ID,
4267 };
4268 assert_eq!(
4269 route.to_string(),
4270 format!(
4271 "applications/{APPLICATION_ID}/guilds/{GUILD_ID}/commands/{COMMAND_ID}/permissions"
4272 )
4273 );
4274 }
4275
4276 #[test]
4277 fn get_current_authorization_info() {
4278 let route = Route::GetCurrentAuthorizationInformation;
4279 assert_eq!(route.to_string(), "oauth2/@me");
4280 }
4281
4282 #[test]
4283 fn get_current_user_application_info() {
4284 let route = Route::GetCurrentUserApplicationInfo;
4285 assert_eq!(route.to_string(), "applications/@me");
4286 }
4287
4288 #[test]
4289 fn update_current_user_application() {
4290 let route = Route::UpdateCurrentUserApplication;
4291 assert_eq!(route.to_string(), "applications/@me");
4292 }
4293
4294 #[test]
4295 fn get_current_user() {
4296 let route = Route::GetCurrentUser;
4297 assert_eq!(route.to_string(), "users/@me");
4298 }
4299
4300 #[test]
4301 fn get_current_user_guild_member() {
4302 let route = Route::GetCurrentUserGuildMember { guild_id: GUILD_ID };
4303 assert_eq!(
4304 route.to_string(),
4305 format!("users/@me/guilds/{GUILD_ID}/member")
4306 );
4307 }
4308
4309 #[test]
4310 fn update_current_user() {
4311 let route = Route::UpdateCurrentUser;
4312 assert_eq!(route.to_string(), "users/@me");
4313 }
4314
4315 #[test]
4316 fn get_gateway() {
4317 let route = Route::GetGateway;
4318 assert_eq!(route.to_string(), "gateway");
4319 }
4320
4321 #[test]
4322 fn get_guild_command_permissions() {
4323 let route = Route::GetGuildCommandPermissions {
4324 application_id: APPLICATION_ID,
4325 guild_id: GUILD_ID,
4326 };
4327 assert_eq!(
4328 route.to_string(),
4329 format!("applications/{APPLICATION_ID}/guilds/{GUILD_ID}/commands/permissions")
4330 );
4331 }
4332
4333 #[test]
4334 fn get_guild_invites() {
4335 let route = Route::GetGuildInvites { guild_id: GUILD_ID };
4336 assert_eq!(route.to_string(), format!("guilds/{GUILD_ID}/invites"));
4337 }
4338
4339 #[test]
4340 fn get_guild_preview() {
4341 let route = Route::GetGuildPreview { guild_id: GUILD_ID };
4342 assert_eq!(route.to_string(), format!("guilds/{GUILD_ID}/preview"));
4343 }
4344
4345 #[test]
4346 fn get_guild_sticker() {
4347 let route = Route::GetGuildSticker {
4348 guild_id: GUILD_ID,
4349 sticker_id: STICKER_ID,
4350 };
4351 assert_eq!(
4352 route.to_string(),
4353 format!("guilds/{GUILD_ID}/stickers/{STICKER_ID}")
4354 );
4355 }
4356
4357 #[test]
4358 fn delete_guild_sticker() {
4359 let route = Route::DeleteGuildSticker {
4360 guild_id: GUILD_ID,
4361 sticker_id: STICKER_ID,
4362 };
4363 assert_eq!(
4364 route.to_string(),
4365 format!("guilds/{GUILD_ID}/stickers/{STICKER_ID}")
4366 );
4367 }
4368
4369 #[test]
4370 fn update_guild_sticker() {
4371 let route = Route::UpdateGuildSticker {
4372 guild_id: GUILD_ID,
4373 sticker_id: STICKER_ID,
4374 };
4375 assert_eq!(
4376 route.to_string(),
4377 format!("guilds/{GUILD_ID}/stickers/{STICKER_ID}")
4378 );
4379 }
4380
4381 #[test]
4382 fn get_guild_vanity_url() {
4383 let route = Route::GetGuildVanityUrl { guild_id: GUILD_ID };
4384 assert_eq!(route.to_string(), format!("guilds/{GUILD_ID}/vanity-url"));
4385 }
4386
4387 #[test]
4388 fn get_guild_voice_regions() {
4389 let route = Route::GetGuildVoiceRegions { guild_id: GUILD_ID };
4390 assert_eq!(route.to_string(), format!("guilds/{GUILD_ID}/regions"));
4391 }
4392
4393 #[test]
4394 fn get_guild_welcome_screen() {
4395 let route = Route::GetGuildWelcomeScreen { guild_id: GUILD_ID };
4396 assert_eq!(
4397 route.to_string(),
4398 format!("guilds/{GUILD_ID}/welcome-screen")
4399 );
4400 }
4401
4402 #[test]
4403 fn update_guild_welcome_screen() {
4404 let route = Route::UpdateGuildWelcomeScreen { guild_id: GUILD_ID };
4405 assert_eq!(
4406 route.to_string(),
4407 format!("guilds/{GUILD_ID}/welcome-screen")
4408 );
4409 }
4410
4411 #[test]
4412 fn get_guild_webhooks() {
4413 let route = Route::GetGuildWebhooks { guild_id: GUILD_ID };
4414 assert_eq!(route.to_string(), format!("guilds/{GUILD_ID}/webhooks"));
4415 }
4416
4417 #[test]
4418 fn get_guild_widget() {
4419 let route = Route::GetGuildWidget { guild_id: GUILD_ID };
4420 assert_eq!(route.to_string(), format!("guilds/{GUILD_ID}/widget.json"));
4421 }
4422
4423 #[test]
4424 fn get_guild_widget_settings() {
4425 let route = Route::GetGuildWidgetSettings { guild_id: GUILD_ID };
4426 assert_eq!(route.to_string(), format!("guilds/{GUILD_ID}/widget"));
4427 }
4428
4429 #[test]
4430 fn update_guild_widget_settings() {
4431 let route = Route::UpdateGuildWidgetSettings { guild_id: GUILD_ID };
4432 assert_eq!(route.to_string(), format!("guilds/{GUILD_ID}/widget"));
4433 }
4434
4435 #[test]
4436 fn get_nitro_sticker_packs() {
4437 let route = Route::GetNitroStickerPacks;
4438
4439 assert_eq!(route.to_string(), "sticker-packs");
4440 }
4441
4442 #[test]
4443 fn get_pins() {
4444 let route = Route::GetPins {
4445 channel_id: CHANNEL_ID,
4446 limit: None,
4447 before: None,
4448 };
4449 assert_eq!(
4450 route.to_string(),
4451 format!("channels/{CHANNEL_ID}/messages/pins")
4452 );
4453 }
4454
4455 #[test]
4456 fn get_sticker_pack() {
4457 let route = Route::GetStickerPack {
4458 sticker_pack_id: STICKER_PACK_ID,
4459 };
4460 assert_eq!(Method::Get, route.method());
4461 assert_eq!(
4462 route.to_string(),
4463 format!("sticker-packs/{STICKER_PACK_ID}")
4464 );
4465 }
4466
4467 #[test]
4468 fn get_sticker() {
4469 let route = Route::GetSticker {
4470 sticker_id: STICKER_ID,
4471 };
4472 assert_eq!(route.to_string(), format!("stickers/{STICKER_ID}"));
4473 }
4474
4475 #[test]
4476 fn get_thread_members() {
4477 let route = Route::GetThreadMembers {
4478 after: None,
4479 channel_id: CHANNEL_ID,
4480 limit: None,
4481 with_member: None,
4482 };
4483 assert_eq!(
4484 route.to_string(),
4485 format!("channels/{CHANNEL_ID}/thread-members")
4486 );
4487
4488 let route = Route::GetThreadMembers {
4489 after: Some(USER_ID),
4490 channel_id: CHANNEL_ID,
4491 limit: Some(1),
4492 with_member: Some(true),
4493 };
4494
4495 assert_eq!(
4496 route.to_string(),
4497 format!(
4498 "channels/{CHANNEL_ID}/thread-members?after={USER_ID}&limit=1&with_member=true"
4499 )
4500 );
4501 }
4502
4503 #[test]
4504 fn get_user_connections() {
4505 let route = Route::GetUserConnections;
4506 assert_eq!(route.to_string(), "users/@me/connections");
4507 }
4508
4509 #[test]
4510 fn get_user() {
4511 let route = Route::GetUser { user_id: USER_ID };
4512 assert_eq!(route.to_string(), format!("users/{USER_ID}"));
4513 }
4514
4515 #[test]
4516 fn get_voice_regions() {
4517 let route = Route::GetVoiceRegions;
4518 assert_eq!(route.to_string(), "voice/regions");
4519 }
4520
4521 #[test]
4522 fn interaction_callback() {
4523 let route = Route::InteractionCallback {
4524 interaction_id: INTERACTION_ID,
4525 interaction_token: INTERACTION_TOKEN,
4526 with_response: true,
4527 };
4528 assert_eq!(
4529 route.to_string(),
4530 format!(
4531 "interactions/{INTERACTION_ID}/{INTERACTION_TOKEN}/callback?with_response=true"
4532 )
4533 );
4534 }
4535
4536 #[test]
4537 fn join_thread() {
4538 let route = Route::JoinThread {
4539 channel_id: CHANNEL_ID,
4540 };
4541 assert_eq!(
4542 route.to_string(),
4543 format!("channels/{CHANNEL_ID}/thread-members/@me")
4544 );
4545 }
4546
4547 #[test]
4548 fn leave_thread() {
4549 let route = Route::LeaveThread {
4550 channel_id: CHANNEL_ID,
4551 };
4552 assert_eq!(
4553 route.to_string(),
4554 format!("channels/{CHANNEL_ID}/thread-members/@me")
4555 );
4556 }
4557
4558 #[test]
4559 fn leave_guild() {
4560 let route = Route::LeaveGuild { guild_id: GUILD_ID };
4561 assert_eq!(route.to_string(), format!("users/@me/guilds/{GUILD_ID}"));
4562 }
4563
4564 #[test]
4565 fn pin_message() {
4566 let route = Route::PinMessage {
4567 channel_id: CHANNEL_ID,
4568 message_id: MESSAGE_ID,
4569 };
4570 assert_eq!(
4571 route.to_string(),
4572 format!("channels/{CHANNEL_ID}/messages/pins/{MESSAGE_ID}")
4573 );
4574 }
4575
4576 #[test]
4577 fn unpin_message() {
4578 let route = Route::UnpinMessage {
4579 channel_id: CHANNEL_ID,
4580 message_id: MESSAGE_ID,
4581 };
4582 assert_eq!(
4583 route.to_string(),
4584 format!("channels/{CHANNEL_ID}/messages/pins/{MESSAGE_ID}")
4585 );
4586 }
4587
4588 #[test]
4589 fn sync_guild_integration() {
4590 let route = Route::SyncGuildIntegration {
4591 guild_id: GUILD_ID,
4592 integration_id: INTEGRATION_ID,
4593 };
4594 assert_eq!(
4595 route.to_string(),
4596 format!("guilds/{GUILD_ID}/integrations/{INTEGRATION_ID}/sync")
4597 );
4598 }
4599
4600 #[test]
4601 fn update_current_member() {
4602 let route = Route::UpdateCurrentMember { guild_id: GUILD_ID };
4603 assert_eq!(route.to_string(), format!("guilds/{GUILD_ID}/members/@me"));
4604 }
4605
4606 #[test]
4607 fn get_current_user_voice_state() {
4608 let route = Route::GetCurrentUserVoiceState { guild_id: GUILD_ID };
4609 assert_eq!(
4610 route.to_string(),
4611 format!("guilds/{GUILD_ID}/voice-states/@me")
4612 );
4613 }
4614
4615 #[test]
4616 fn update_current_user_voice_state() {
4617 let route = Route::UpdateCurrentUserVoiceState { guild_id: GUILD_ID };
4618 assert_eq!(
4619 route.to_string(),
4620 format!("guilds/{GUILD_ID}/voice-states/@me")
4621 );
4622 }
4623
4624 #[test]
4625 fn update_nickname() {
4626 let route = Route::UpdateNickname { guild_id: GUILD_ID };
4627 assert_eq!(
4628 route.to_string(),
4629 format!("guilds/{GUILD_ID}/members/@me/nick")
4630 );
4631 }
4632
4633 #[test]
4634 fn get_user_voice_state() {
4635 let route = Route::GetUserVoiceState {
4636 guild_id: GUILD_ID,
4637 user_id: USER_ID,
4638 };
4639 assert_eq!(
4640 route.to_string(),
4641 format!("guilds/{GUILD_ID}/voice-states/{USER_ID}")
4642 );
4643 }
4644
4645 #[test]
4646 fn update_user_voice_state() {
4647 let route = Route::UpdateUserVoiceState {
4648 guild_id: GUILD_ID,
4649 user_id: USER_ID,
4650 };
4651 assert_eq!(
4652 route.to_string(),
4653 format!("guilds/{GUILD_ID}/voice-states/{USER_ID}")
4654 );
4655 }
4656
4657 #[test]
4658 fn create_ban() {
4659 let mut route = Route::CreateBan {
4660 guild_id: GUILD_ID,
4661 user_id: USER_ID,
4662 };
4663 assert_eq!(
4664 route.to_string(),
4665 format!("guilds/{GUILD_ID}/bans/{USER_ID}")
4666 );
4667
4668 route = Route::CreateBan {
4669 guild_id: GUILD_ID,
4670 user_id: USER_ID,
4671 };
4672 assert_eq!(
4673 route.to_string(),
4674 format!("guilds/{GUILD_ID}/bans/{USER_ID}")
4675 );
4676 }
4677
4678 #[test]
4679 fn create_guild_prune_none() {
4680 let route = Route::CreateGuildPrune {
4681 compute_prune_count: None,
4682 days: None,
4683 guild_id: GUILD_ID,
4684 include_roles: &[],
4685 };
4686 assert_eq!(route.to_string(), format!("guilds/{GUILD_ID}/prune"));
4687 }
4688
4689 #[test]
4690 fn create_guild_prune_compute_prune_count_true() {
4691 let route = Route::CreateGuildPrune {
4692 compute_prune_count: Some(true),
4693 days: None,
4694 guild_id: GUILD_ID,
4695 include_roles: &[],
4696 };
4697 assert_eq!(
4698 route.to_string(),
4699 format!("guilds/{GUILD_ID}/prune?compute_prune_count=true")
4700 );
4701 }
4702
4703 #[test]
4704 fn create_guild_prune_compute_prune_count_false() {
4705 let route = Route::CreateGuildPrune {
4706 compute_prune_count: Some(false),
4707 days: None,
4708 guild_id: GUILD_ID,
4709 include_roles: &[],
4710 };
4711 assert_eq!(
4712 route.to_string(),
4713 format!("guilds/{GUILD_ID}/prune?compute_prune_count=false")
4714 );
4715 }
4716
4717 #[test]
4718 fn create_guild_prune_days() {
4719 let route = Route::CreateGuildPrune {
4720 compute_prune_count: None,
4721 days: Some(4),
4722 guild_id: GUILD_ID,
4723 include_roles: &[],
4724 };
4725 assert_eq!(route.to_string(), format!("guilds/{GUILD_ID}/prune?days=4"));
4726 }
4727
4728 #[test]
4729 fn create_guild_prune_include_one_role() {
4730 let include_roles = [Id::new(1)];
4731
4732 let route = Route::CreateGuildPrune {
4733 compute_prune_count: None,
4734 days: None,
4735 guild_id: GUILD_ID,
4736 include_roles: &include_roles,
4737 };
4738 assert_eq!(
4739 route.to_string(),
4740 format!("guilds/{GUILD_ID}/prune?include_roles=1")
4741 );
4742 }
4743
4744 #[test]
4745 fn create_guild_prune_include_two_roles() {
4746 let include_roles = [Id::new(1), Id::new(2)];
4747
4748 let route = Route::CreateGuildPrune {
4749 compute_prune_count: None,
4750 days: None,
4751 guild_id: GUILD_ID,
4752 include_roles: &include_roles,
4753 };
4754 assert_eq!(
4755 route.to_string(),
4756 format!("guilds/{GUILD_ID}/prune?include_roles=1,2")
4757 );
4758 }
4759
4760 #[test]
4761 fn create_guild_prune_all() {
4762 let include_roles = [Id::new(1), Id::new(2)];
4763
4764 let route = Route::CreateGuildPrune {
4765 compute_prune_count: Some(true),
4766 days: Some(4),
4767 guild_id: GUILD_ID,
4768 include_roles: &include_roles,
4769 };
4770 assert_eq!(
4771 route.to_string(),
4772 format!("guilds/{GUILD_ID}/prune?compute_prune_count=true&days=4&include_roles=1,2")
4773 );
4774 }
4775
4776 #[test]
4777 fn get_guild_scheduled_events() {
4778 let route = Route::GetGuildScheduledEvents {
4779 guild_id: GUILD_ID,
4780 with_user_count: false,
4781 };
4782
4783 assert_eq!(
4784 route.to_string(),
4785 format!("guilds/{GUILD_ID}/scheduled-events")
4786 );
4787
4788 let route = Route::GetGuildScheduledEvents {
4789 guild_id: GUILD_ID,
4790 with_user_count: true,
4791 };
4792
4793 assert_eq!(
4794 route.to_string(),
4795 format!("guilds/{GUILD_ID}/scheduled-events?with_user_count=true")
4796 );
4797 }
4798
4799 #[test]
4800 fn create_guild_scheduled_event() {
4801 let route = Route::CreateGuildScheduledEvent { guild_id: GUILD_ID };
4802
4803 assert_eq!(
4804 route.to_string(),
4805 format!("guilds/{GUILD_ID}/scheduled-events")
4806 );
4807 }
4808
4809 #[test]
4810 fn get_guild_scheduled_event() {
4811 let route = Route::GetGuildScheduledEvent {
4812 guild_id: GUILD_ID,
4813 scheduled_event_id: SCHEDULED_EVENT_ID,
4814 with_user_count: false,
4815 };
4816
4817 assert_eq!(
4818 route.to_string(),
4819 format!("guilds/{GUILD_ID}/scheduled-events/{SCHEDULED_EVENT_ID}")
4820 );
4821
4822 let route = Route::GetGuildScheduledEvent {
4823 guild_id: GUILD_ID,
4824 scheduled_event_id: SCHEDULED_EVENT_ID,
4825 with_user_count: true,
4826 };
4827
4828 assert_eq!(
4829 route.to_string(),
4830 format!("guilds/{GUILD_ID}/scheduled-events/{SCHEDULED_EVENT_ID}?with_user_count=true")
4831 );
4832 }
4833
4834 #[test]
4835 fn update_guild_scheduled_event() {
4836 let route = Route::UpdateGuildScheduledEvent {
4837 guild_id: GUILD_ID,
4838 scheduled_event_id: SCHEDULED_EVENT_ID,
4839 };
4840
4841 assert_eq!(
4842 route.to_string(),
4843 format!("guilds/{GUILD_ID}/scheduled-events/{SCHEDULED_EVENT_ID}")
4844 );
4845 }
4846
4847 #[test]
4848 fn delete_guild_scheduled_event() {
4849 let route = Route::DeleteGuildScheduledEvent {
4850 guild_id: GUILD_ID,
4851 scheduled_event_id: SCHEDULED_EVENT_ID,
4852 };
4853
4854 assert_eq!(
4855 route.to_string(),
4856 format!("guilds/{GUILD_ID}/scheduled-events/{SCHEDULED_EVENT_ID}")
4857 );
4858 }
4859
4860 #[test]
4861 fn get_guild_scheduled_event_users() {
4862 let route = Route::GetGuildScheduledEventUsers {
4863 after: None,
4864 before: Some(USER_ID),
4865 guild_id: GUILD_ID,
4866 limit: None,
4867 scheduled_event_id: SCHEDULED_EVENT_ID,
4868 with_member: true,
4869 };
4870
4871 assert_eq!(
4872 route.to_string(),
4873 format!(
4874 "guilds/{GUILD_ID}/scheduled-events/{SCHEDULED_EVENT_ID}/users?before={USER_ID}&with_member=true"
4875 )
4876 );
4877
4878 let route = Route::GetGuildScheduledEventUsers {
4879 after: Some(USER_ID),
4880 before: None,
4881 guild_id: GUILD_ID,
4882 limit: Some(101),
4883 scheduled_event_id: SCHEDULED_EVENT_ID,
4884 with_member: false,
4885 };
4886
4887 assert_eq!(
4888 route.to_string(),
4889 format!(
4890 "guilds/{GUILD_ID}/scheduled-events/{SCHEDULED_EVENT_ID}/users?after={USER_ID}&limit=101"
4891 )
4892 );
4893
4894 let route = Route::GetGuildScheduledEventUsers {
4895 after: Some(USER_ID),
4896 before: Some(USER_ID),
4897 guild_id: GUILD_ID,
4898 limit: Some(99),
4899 scheduled_event_id: SCHEDULED_EVENT_ID,
4900 with_member: false,
4901 };
4902
4903 assert_eq!(
4904 route.to_string(),
4905 format!(
4906 "guilds/{GUILD_ID}/scheduled-events/{SCHEDULED_EVENT_ID}/users?after={USER_ID}&before={USER_ID}&limit=99"
4907 )
4908 );
4909 }
4910
4911 #[test]
4912 fn search_guild_members() {
4913 let route = Route::SearchGuildMembers {
4914 guild_id: GUILD_ID,
4915 limit: Some(99),
4916 query: "foo bar",
4917 };
4918
4919 assert_eq!(
4920 route.to_string(),
4921 format!("guilds/{GUILD_ID}/members/search?query=foo%20bar&limit=99")
4922 );
4923
4924 let route = Route::SearchGuildMembers {
4925 guild_id: GUILD_ID,
4926 limit: Some(99),
4927 query: "foo/bar",
4928 };
4929
4930 assert_eq!(
4931 route.to_string(),
4932 format!("guilds/{GUILD_ID}/members/search?query=foo%2Fbar&limit=99")
4933 );
4934 }
4935
4936 #[test]
4937 fn search_guild_messages_no_parameters() {
4938 let route = Route::SearchGuildMessages {
4939 attachment_extension: None,
4940 attachment_filename: None,
4941 author_id: None,
4942 author_type: None,
4943 channel_id: None,
4944 content: None,
4945 embed_provider: None,
4946 embed_type: None,
4947 guild_id: GUILD_ID,
4948 has: None,
4949 include_nsfw: None,
4950 limit: None,
4951 link_hostname: None,
4952 max_id: None,
4953 mention_everyone: None,
4954 mentions: None,
4955 mentions_role_id: None,
4956 min_id: None,
4957 offset: None,
4958 pinned: None,
4959 replied_to_message_id: None,
4960 replied_to_user_id: None,
4961 slop: None,
4962 sort_by: None,
4963 sort_order: None,
4964 };
4965 assert_eq!(Method::Get, route.method());
4966 assert_eq!(
4967 route.to_string(),
4968 format!("guilds/{GUILD_ID}/messages/search")
4969 );
4970 }
4971
4972 #[test]
4973 fn search_guild_messages_all_parameters() {
4974 let route = Route::SearchGuildMessages {
4976 attachment_extension: Some(&["pdf", "txt"]),
4977 attachment_filename: Some(&["foo.pdf", "foo.txt"]),
4978 author_id: Some(&[Id::new(1), Id::new(2)]),
4979 author_type: Some(&[
4980 SearchFilter::Exclude(AuthorType::Bot),
4981 SearchFilter::Include(AuthorType::User),
4982 ]),
4983 channel_id: Some(&[Id::new(3), Id::new(4)]),
4984 content: Some("test message"),
4985 embed_provider: Some(&["one", "two"]),
4986 embed_type: Some(&[SearchEmbedType::Gif, SearchEmbedType::Image]),
4987 guild_id: GUILD_ID,
4988 has: Some(&[
4989 SearchFilter::Include(SearchHasType::File),
4990 SearchFilter::Exclude(SearchHasType::Image),
4991 ]),
4992 include_nsfw: Some(true),
4993 limit: Some(20),
4994 link_hostname: Some(&["discord.com", "github.com"]),
4995 max_id: Some(100),
4996 mention_everyone: Some(false),
4997 mentions: Some(&[Id::new(5), Id::new(6)]),
4998 mentions_role_id: Some(&[Id::new(7), Id::new(8)]),
4999 min_id: Some(1),
5000 offset: Some(1000),
5001 pinned: Some(true),
5002 replied_to_message_id: Some(&[Id::new(9), Id::new(10)]),
5003 replied_to_user_id: Some(&[Id::new(11), Id::new(12)]),
5004 slop: Some(13),
5005 sort_by: Some(SearchSortMode::Relevance),
5006 sort_order: Some(SearchSortOrder::Descending),
5007 };
5008 assert_eq!(Method::Get, route.method());
5009 assert_eq!(
5010 route.to_string(),
5011 format!("guilds/{GUILD_ID}/messages/search")
5012 + "?attachment_extension=pdf&attachment_extension=txt"
5013 + "&attachment_filename=foo%2Epdf&attachment_filename=foo%2Etxt"
5014 + "&author_id=1&author_id=2&author_type=-bot&author_type=user"
5015 + "&channel_id=3&channel_id=4&content=test%20message"
5016 + "&embed_provider=one&embed_provider=two&embed_type=gif"
5017 + "&embed_type=image&has=file&has=-image&include_nsfw=true"
5018 + "&limit=20&link_hostname=discord%2Ecom"
5019 + "&link_hostname=github%2Ecom&max_id=100"
5020 + "&mention_everyone=false&mentions=5&mentions=6"
5021 + "&mentions_role_id=7&mentions_role_id=8&min_id=1&offset=1000"
5022 + "&pinned=true&replied_to_message_id=9"
5023 + "&replied_to_message_id=10&replied_to_user_id=11"
5024 + "&replied_to_user_id=12&slop=13&sort_by=relevance"
5025 + "&sort_order=desc"
5026 );
5027 }
5028
5029 #[test]
5030 fn update_guild_mfa() {
5031 let route = Route::UpdateGuildMfa { guild_id: GUILD_ID };
5032 assert_eq!(route.to_string(), format!("guilds/{GUILD_ID}/mfa"));
5033 }
5034
5035 #[test]
5036 fn create_auto_moderation_rule() {
5037 let route = Route::CreateAutoModerationRule { guild_id: GUILD_ID };
5038 assert_eq!(
5039 route.to_string(),
5040 format!("guilds/{GUILD_ID}/auto-moderation/rules")
5041 );
5042 }
5043
5044 #[test]
5045 fn delete_auto_moderation_rule() {
5046 let route = Route::DeleteAutoModerationRule {
5047 guild_id: GUILD_ID,
5048 auto_moderation_rule_id: AUTO_MODERATION_RULE_ID,
5049 };
5050 assert_eq!(
5051 route.to_string(),
5052 format!("guilds/{GUILD_ID}/auto-moderation/rules/{AUTO_MODERATION_RULE_ID}")
5053 );
5054 }
5055
5056 #[test]
5057 fn get_auto_moderation_rule() {
5058 let route = Route::GetAutoModerationRule {
5059 guild_id: GUILD_ID,
5060 auto_moderation_rule_id: AUTO_MODERATION_RULE_ID,
5061 };
5062 assert_eq!(
5063 route.to_string(),
5064 format!("guilds/{GUILD_ID}/auto-moderation/rules/{AUTO_MODERATION_RULE_ID}")
5065 );
5066 }
5067
5068 #[test]
5069 fn get_guild_auto_moderation_rules() {
5070 let route = Route::GetGuildAutoModerationRules { guild_id: GUILD_ID };
5071 assert_eq!(
5072 route.to_string(),
5073 format!("guilds/{GUILD_ID}/auto-moderation/rules")
5074 );
5075 }
5076
5077 #[test]
5078 fn update_auto_moderation_rule() {
5079 let route = Route::UpdateAutoModerationRule {
5080 guild_id: GUILD_ID,
5081 auto_moderation_rule_id: AUTO_MODERATION_RULE_ID,
5082 };
5083 assert_eq!(
5084 route.to_string(),
5085 format!("guilds/{GUILD_ID}/auto-moderation/rules/{AUTO_MODERATION_RULE_ID}")
5086 );
5087 }
5088
5089 #[test]
5090 fn get_guild_onboarding() {
5091 let route = Route::GetGuildOnboarding { guild_id: GUILD_ID };
5092 assert_eq!(route.to_string(), format!("guilds/{GUILD_ID}/onboarding"));
5093 }
5094
5095 #[test]
5096 fn get_skus() {
5097 let route = Route::GetSKUs {
5098 application_id: APPLICATION_ID,
5099 };
5100 assert_eq!(
5101 route.to_string(),
5102 format!("applications/{APPLICATION_ID}/skus")
5103 );
5104 }
5105
5106 #[test]
5107 fn consume_entitlement() {
5108 let route = Route::ConsumeEntitlement {
5109 application_id: APPLICATION_ID,
5110 entitlement_id: ENTITLEMENT_ID,
5111 };
5112 assert_eq!(
5113 route.to_string(),
5114 format!("applications/{APPLICATION_ID}/entitlements/{ENTITLEMENT_ID}/consume")
5115 );
5116 assert_eq!(Method::Post, route.method());
5117 }
5118
5119 #[test]
5120 fn get_sku_subscriptions() {
5121 let route = Route::GetSKUSubscriptions {
5122 after: Some(18),
5123 before: Some(20),
5124 limit: Some(100),
5125 sku_id: SKU_ID,
5126 user_id: Some(USER_ID),
5127 };
5128 assert_eq!(
5129 route.to_string(),
5130 format!("skus/{SKU_ID}/subscriptions?after=18&before=20&limit=100&user_id={USER_ID}")
5131 );
5132 }
5133
5134 #[test]
5135 fn get_sku_subscription() {
5136 let route = Route::GetSKUSubscription {
5137 sku_id: SKU_ID,
5138 subscription_id: SUBSCRIPTION_ID,
5139 };
5140 assert_eq!(
5141 route.to_string(),
5142 format!("skus/{SKU_ID}/subscriptions/{SUBSCRIPTION_ID}")
5143 );
5144 }
5145
5146 #[test]
5147 fn get_channel_member_permissions() {
5148 let route = Route::GetChannelMemberPermissions {
5149 channel_id: CHANNEL_ID,
5150 implicit: Some(true),
5151 user_id: USER_ID,
5152 };
5153 assert_eq!(
5154 route.to_string(),
5155 format!("channels/{CHANNEL_ID}/permissions/member/{USER_ID}?implicit=true")
5156 );
5157 }
5158
5159 #[test]
5160 fn get_channel_role_permissions() {
5161 let route = Route::GetChannelRolePermissions {
5162 channel_id: CHANNEL_ID,
5163 implicit: Some(false),
5164 role_id: ROLE_ID,
5165 };
5166 assert_eq!(
5167 route.to_string(),
5168 format!("channels/{CHANNEL_ID}/permissions/role/{ROLE_ID}?implicit=false")
5169 );
5170 }
5171
5172 #[test]
5173 fn get_guild_member_permissions() {
5174 let route = Route::GetGuildMemberPermissions {
5175 guild_id: GUILD_ID,
5176 user_id: USER_ID,
5177 };
5178 assert_eq!(
5179 route.to_string(),
5180 format!("guilds/{GUILD_ID}/permissions/member/{USER_ID}")
5181 );
5182 }
5183
5184 #[test]
5185 fn get_guild_role_permissions() {
5186 let route = Route::GetGuildRolePermissions {
5187 guild_id: GUILD_ID,
5188 role_id: ROLE_ID,
5189 };
5190 assert_eq!(
5191 route.to_string(),
5192 format!("guilds/{GUILD_ID}/permissions/role/{ROLE_ID}")
5193 );
5194 }
5195}