1use percent_encoding::{NON_ALPHANUMERIC, utf8_percent_encode};
2
3use crate::{
4 query_formatter::{QueryArray, QueryStringFormatter},
5 request::{Method, channel::reaction::RequestReactionType},
6};
7use std::fmt::{Display, Formatter, Result as FmtResult};
8use twilight_model::id::{
9 Id,
10 marker::{RoleMarker, SkuMarker},
11};
12
13#[derive(Clone, Debug, Eq, Hash, PartialEq)]
14#[non_exhaustive]
15pub enum Route<'a> {
16 AddApplicationEmoji {
18 application_id: u64,
20 },
21 AddGuildMember {
23 guild_id: u64,
24 user_id: u64,
25 },
26 AddMemberRole {
28 guild_id: u64,
30 role_id: u64,
32 user_id: u64,
34 },
35 AddThreadMember {
37 channel_id: u64,
39 user_id: u64,
41 },
42 BulkGuildBan {
44 guild_id: u64,
45 },
46 ConsumeEntitlement {
49 application_id: u64,
51 entitlement_id: u64,
53 },
54 CreateAutoModerationRule {
56 guild_id: u64,
58 },
59 CreateBan {
61 guild_id: u64,
63 user_id: u64,
65 },
66 CreateChannel {
68 guild_id: u64,
70 },
71 CreateEmoji {
73 guild_id: u64,
75 },
76 CreateForumThread {
78 channel_id: u64,
80 },
81 CreateGlobalCommand {
83 application_id: u64,
85 },
86 CreateGuild,
88 CreateGuildCommand {
90 application_id: u64,
92 guild_id: u64,
94 },
95 CreateGuildFromTemplate {
97 template_code: &'a str,
99 },
100 CreateGuildIntegration {
102 guild_id: u64,
104 },
105 CreateGuildPrune {
107 compute_prune_count: Option<bool>,
109 days: Option<u16>,
112 guild_id: u64,
114 include_roles: &'a [Id<RoleMarker>],
119 },
120 CreateGuildScheduledEvent {
122 guild_id: u64,
124 },
125 CreateGuildSticker {
127 guild_id: u64,
129 },
130 CreateInvite {
132 channel_id: u64,
134 },
135 CreateMessage {
137 channel_id: u64,
139 },
140 CreatePrivateChannel,
142 CreateReaction {
144 channel_id: u64,
146 emoji: &'a RequestReactionType<'a>,
148 message_id: u64,
150 },
151 CreateRole {
153 guild_id: u64,
155 },
156 CreateStageInstance,
158 CreateTemplate {
160 guild_id: u64,
162 },
163 CreateTestEntitlement {
164 application_id: u64,
166 },
167 CreateThread {
169 channel_id: u64,
171 },
172 CreateThreadFromMessage {
174 channel_id: u64,
176 message_id: u64,
178 },
179 CreateTypingTrigger {
181 channel_id: u64,
183 },
184 CreateWebhook {
186 channel_id: u64,
188 },
189 CrosspostMessage {
191 channel_id: u64,
193 message_id: u64,
195 },
196 DeleteApplicationEmoji {
198 application_id: u64,
200 emoji_id: u64,
202 },
203 DeleteAutoModerationRule {
205 guild_id: u64,
207 auto_moderation_rule_id: u64,
209 },
210 DeleteBan {
212 guild_id: u64,
214 user_id: u64,
216 },
217 DeleteChannel {
219 channel_id: u64,
221 },
222 DeleteEmoji {
224 emoji_id: u64,
226 guild_id: u64,
228 },
229 DeleteGlobalCommand {
231 application_id: u64,
233 command_id: u64,
235 },
236 DeleteGuild {
238 guild_id: u64,
240 },
241 DeleteGuildCommand {
243 application_id: u64,
245 command_id: u64,
247 guild_id: u64,
249 },
250 DeleteGuildIntegration {
252 guild_id: u64,
254 integration_id: u64,
256 },
257 DeleteGuildScheduledEvent {
259 guild_id: u64,
261 scheduled_event_id: u64,
263 },
264 DeleteGuildSticker {
266 guild_id: u64,
268 sticker_id: u64,
270 },
271 DeleteInteractionOriginal {
273 application_id: u64,
275 interaction_token: &'a str,
277 },
278 DeleteInvite {
280 code: &'a str,
282 },
283 DeleteMessage {
285 channel_id: u64,
287 message_id: u64,
289 },
290 DeleteMessageReactions {
292 channel_id: u64,
294 message_id: u64,
296 },
297 DeleteMessageSpecificReaction {
300 channel_id: u64,
302 emoji: &'a RequestReactionType<'a>,
304 message_id: u64,
306 },
307 DeleteMessages {
309 channel_id: u64,
311 },
312 DeletePermissionOverwrite {
315 channel_id: u64,
317 target_id: u64,
319 },
320 DeleteReaction {
322 channel_id: u64,
324 emoji: &'a RequestReactionType<'a>,
326 message_id: u64,
328 user_id: u64,
330 },
331 DeleteReactionCurrentUser {
333 channel_id: u64,
335 emoji: &'a RequestReactionType<'a>,
337 message_id: u64,
339 },
340 DeleteRole {
342 guild_id: u64,
344 role_id: u64,
346 },
347 DeleteStageInstance {
349 channel_id: u64,
351 },
352 DeleteTemplate {
354 guild_id: u64,
356 template_code: &'a str,
358 },
359 DeleteWebhook {
361 token: Option<&'a str>,
363 webhook_id: u64,
365 },
366 DeleteWebhookMessage {
368 message_id: u64,
369 thread_id: Option<u64>,
371 token: &'a str,
372 webhook_id: u64,
373 },
374 DeleteTestEntitlement {
376 application_id: u64,
378 entitlement_id: u64,
380 },
381 UpdateApplicationEmoji {
383 application_id: u64,
385 emoji_id: u64,
387 },
388 EndPoll {
390 channel_id: u64,
391 message_id: u64,
392 },
393 ExecuteWebhook {
395 thread_id: Option<u64>,
397 token: &'a str,
399 wait: Option<bool>,
401 with_components: Option<bool>,
403 webhook_id: u64,
405 },
406 FollowNewsChannel {
408 channel_id: u64,
410 },
411 GetActiveThreads {
413 guild_id: u64,
415 },
416 GetApplicationEmojis {
417 application_id: u64,
419 },
420 GetAnswerVoters {
422 after: Option<u64>,
424 answer_id: u8,
426 channel_id: u64,
428 limit: Option<u8>,
430 message_id: u64,
432 },
433 GetAuditLogs {
435 action_type: Option<u64>,
437 after: Option<u64>,
439 before: Option<u64>,
441 guild_id: u64,
443 limit: Option<u16>,
445 user_id: Option<u64>,
447 },
448 GetAutoModerationRule {
450 guild_id: u64,
452 auto_moderation_rule_id: u64,
454 },
455 GetBan {
457 guild_id: u64,
459 user_id: u64,
461 },
462 GetBans {
464 guild_id: u64,
466 },
467 GetBansWithParameters {
469 after: Option<u64>,
471 before: Option<u64>,
473 limit: Option<u16>,
475 guild_id: u64,
477 },
478 GetChannel {
480 channel_id: u64,
482 },
483 GetChannelInvites {
485 channel_id: u64,
487 },
488 GetChannelWebhooks {
490 channel_id: u64,
492 },
493 GetChannels {
495 guild_id: u64,
497 },
498 GetCommandPermissions {
500 application_id: u64,
502 command_id: u64,
504 guild_id: u64,
506 },
507 GetCurrentAuthorizationInformation,
509 GetCurrentUser,
511 GetCurrentUserApplicationInfo,
513 GetCurrentUserGuildMember {
515 guild_id: u64,
517 },
518 GetCurrentUserVoiceState {
520 guild_id: u64,
522 },
523 GetEmoji {
525 emoji_id: u64,
527 guild_id: u64,
529 },
530 GetEmojis {
532 guild_id: u64,
534 },
535 GetEntitlements {
536 after: Option<u64>,
538 application_id: u64,
540 before: Option<u64>,
542 exclude_deleted: Option<bool>,
544 exclude_ended: Option<bool>,
546 guild_id: Option<u64>,
548 limit: Option<u8>,
550 sku_ids: &'a [Id<SkuMarker>],
552 user_id: Option<u64>,
554 },
555 GetEntitlement {
556 application_id: u64,
558 entitlement_id: u64,
560 },
561 GetFollowupMessage {
563 application_id: u64,
565 interaction_token: &'a str,
567 thread_id: Option<u64>,
569 message_id: u64,
571 },
572 GetGateway,
574 GetGatewayBot,
577 GetGlobalCommand {
579 application_id: u64,
581 command_id: u64,
583 },
584 GetGlobalCommands {
585 application_id: u64,
587 with_localizations: Option<bool>,
589 },
590 GetGuild {
592 guild_id: u64,
594 with_counts: bool,
597 },
598 GetGuildAutoModerationRules {
600 guild_id: u64,
602 },
603 GetGuildCommand {
605 application_id: u64,
607 command_id: u64,
609 guild_id: u64,
611 },
612 GetGuildCommandPermissions {
614 application_id: u64,
616 guild_id: u64,
618 },
619 GetGuildCommands {
621 application_id: u64,
623 guild_id: u64,
625 with_localizations: Option<bool>,
627 },
628 GetGuildIntegrations {
630 guild_id: u64,
632 },
633 GetGuildInvites {
635 guild_id: u64,
637 },
638 GetGuildMembers {
640 after: Option<u64>,
642 guild_id: u64,
644 limit: Option<u16>,
646 },
647 GetGuildOnboarding {
649 guild_id: u64,
651 },
652 GetGuildPreview {
654 guild_id: u64,
656 },
657 GetGuildPruneCount {
660 days: Option<u16>,
663 guild_id: u64,
665 include_roles: &'a [Id<RoleMarker>],
670 },
671 GetGuildRoleMemberCounts {
673 guild_id: u64,
674 },
675 GetGuildRoles {
677 guild_id: u64,
679 },
680 GetGuildScheduledEvent {
682 guild_id: u64,
684 scheduled_event_id: u64,
686 with_user_count: bool,
688 },
689 GetGuildScheduledEventUsers {
691 after: Option<u64>,
693 before: Option<u64>,
695 guild_id: u64,
697 limit: Option<u16>,
699 scheduled_event_id: u64,
701 with_member: bool,
703 },
704 GetGuildScheduledEvents {
706 guild_id: u64,
708 with_user_count: bool,
710 },
711 GetGuildSticker {
713 guild_id: u64,
715 sticker_id: u64,
717 },
718 GetGuildStickers {
720 guild_id: u64,
722 },
723 GetGuildVanityUrl {
725 guild_id: u64,
727 },
728 GetGuildVoiceRegions {
730 guild_id: u64,
732 },
733 GetGuildWebhooks {
735 guild_id: u64,
737 },
738 GetGuildWelcomeScreen {
740 guild_id: u64,
742 },
743 GetGuildWidget {
745 guild_id: u64,
747 },
748 GetGuildWidgetSettings {
750 guild_id: u64,
752 },
753 GetGuilds {
758 after: Option<u64>,
760 before: Option<u64>,
762 limit: Option<u16>,
764 shard: Option<u64>,
770 },
771 GetInteractionOriginal {
773 application_id: u64,
775 interaction_token: &'a str,
777 },
778 GetInvite {
780 code: &'a str,
782 with_counts: bool,
784 },
785 GetInviteWithExpiration {
787 code: &'a str,
789 with_counts: bool,
791 with_expiration: bool,
793 },
794 GetJoinedPrivateArchivedThreads {
796 before: Option<u64>,
798 channel_id: u64,
800 limit: Option<u64>,
802 },
803 GetMember {
805 guild_id: u64,
807 user_id: u64,
809 },
810 GetMessage {
812 channel_id: u64,
814 message_id: u64,
816 },
817 GetMessages {
819 after: Option<u64>,
821 around: Option<u64>,
823 before: Option<u64>,
825 channel_id: u64,
827 limit: Option<u16>,
829 },
830 GetNitroStickerPacks,
833 GetPins {
835 channel_id: u64,
837 limit: Option<u16>,
839 before: Option<String>,
841 },
842 GetPrivateArchivedThreads {
844 before: Option<&'a str>,
846 channel_id: u64,
848 limit: Option<u64>,
850 },
851 GetPublicArchivedThreads {
853 before: Option<&'a str>,
855 channel_id: u64,
857 limit: Option<u64>,
859 },
860 GetReactionUsers {
863 after: Option<u64>,
865 channel_id: u64,
867 emoji: &'a RequestReactionType<'a>,
869 limit: Option<u16>,
871 message_id: u64,
873 kind: Option<u8>,
875 },
876 GetRole {
878 guild_id: u64,
880 role_id: u64,
882 },
883 GetSKUs {
884 application_id: u64,
886 },
887 GetSKUSubscriptions {
888 after: Option<u64>,
890 before: Option<u64>,
892 limit: Option<u64>,
894 sku_id: u64,
896 user_id: Option<u64>,
898 },
899 GetSKUSubscription {
900 sku_id: u64,
902 subscription_id: u64,
904 },
905 GetStageInstance {
907 channel_id: u64,
909 },
910 GetStickerPack {
912 sticker_pack_id: u64,
914 },
915 GetSticker {
917 sticker_id: u64,
919 },
920 GetTemplate {
922 template_code: &'a str,
924 },
925 GetTemplates {
927 guild_id: u64,
929 },
930 GetThreadMember {
932 channel_id: u64,
934 user_id: u64,
936 },
937 GetThreadMembers {
939 after: Option<u64>,
941 channel_id: u64,
943 limit: Option<u32>,
947 with_member: Option<bool>,
949 },
950 GetUser {
952 user_id: u64,
954 },
955 GetUserConnections,
957 GetUserPrivateChannels,
959 GetUserVoiceState {
961 guild_id: u64,
963 user_id: u64,
965 },
966 GetVoiceRegions,
968 GetWebhook {
971 token: Option<&'a str>,
973 webhook_id: u64,
975 },
976 GetWebhookMessage {
978 message_id: u64,
980 thread_id: Option<u64>,
982 token: &'a str,
984 webhook_id: u64,
986 },
987 InteractionCallback {
989 interaction_id: u64,
991 interaction_token: &'a str,
993 with_response: bool,
995 },
996 JoinThread {
998 channel_id: u64,
1000 },
1001 LeaveGuild {
1003 guild_id: u64,
1005 },
1006 LeaveThread {
1008 channel_id: u64,
1010 },
1011 PinMessage {
1013 channel_id: u64,
1015 message_id: u64,
1017 },
1018 RemoveMember {
1020 guild_id: u64,
1022 user_id: u64,
1024 },
1025 RemoveMemberRole {
1027 guild_id: u64,
1029 role_id: u64,
1031 user_id: u64,
1033 },
1034 RemoveThreadMember {
1036 channel_id: u64,
1038 user_id: u64,
1040 },
1041 SearchGuildMembers {
1043 guild_id: u64,
1045 limit: Option<u16>,
1047 query: &'a str,
1049 },
1050 SetGlobalCommands {
1052 application_id: u64,
1054 },
1055 SetGuildCommands {
1057 application_id: u64,
1059 guild_id: u64,
1061 },
1062 SyncGuildIntegration {
1064 guild_id: u64,
1066 integration_id: u64,
1068 },
1069 SyncTemplate {
1071 guild_id: u64,
1073 template_code: &'a str,
1075 },
1076 UnpinMessage {
1078 channel_id: u64,
1080 message_id: u64,
1082 },
1083 UpdateAutoModerationRule {
1085 auto_moderation_rule_id: u64,
1087 guild_id: u64,
1089 },
1090 UpdateChannel {
1092 channel_id: u64,
1094 },
1095 UpdateCommandPermissions {
1097 application_id: u64,
1099 command_id: u64,
1101 guild_id: u64,
1103 },
1104 UpdateCurrentMember {
1106 guild_id: u64,
1108 },
1109 UpdateCurrentUser,
1111 UpdateCurrentUserVoiceState {
1113 guild_id: u64,
1115 },
1116 UpdateEmoji {
1118 emoji_id: u64,
1120 guild_id: u64,
1122 },
1123 UpdateGlobalCommand {
1125 application_id: u64,
1127 command_id: u64,
1129 },
1130 UpdateGuild {
1132 guild_id: u64,
1134 },
1135 UpdateGuildChannels {
1137 guild_id: u64,
1139 },
1140 UpdateGuildCommand {
1142 application_id: u64,
1144 command_id: u64,
1146 guild_id: u64,
1148 },
1149 UpdateGuildIntegration {
1151 guild_id: u64,
1153 integration_id: u64,
1155 },
1156 UpdateGuildMfa {
1158 guild_id: u64,
1160 },
1161 UpdateGuildOnboarding {
1162 guild_id: u64,
1164 },
1165 UpdateGuildScheduledEvent {
1167 guild_id: u64,
1169 scheduled_event_id: u64,
1171 },
1172 UpdateGuildSticker {
1174 guild_id: u64,
1176 sticker_id: u64,
1178 },
1179 UpdateGuildWelcomeScreen {
1181 guild_id: u64,
1183 },
1184 UpdateGuildWidgetSettings {
1186 guild_id: u64,
1188 },
1189 UpdateInteractionOriginal {
1191 application_id: u64,
1193 interaction_token: &'a str,
1195 },
1196 UpdateMember {
1198 guild_id: u64,
1200 user_id: u64,
1202 },
1203 UpdateMessage {
1205 channel_id: u64,
1207 message_id: u64,
1209 },
1210 UpdateNickname {
1212 guild_id: u64,
1214 },
1215 UpdatePermissionOverwrite {
1218 channel_id: u64,
1220 target_id: u64,
1222 },
1223 UpdateRole {
1225 guild_id: u64,
1227 role_id: u64,
1229 },
1230 UpdateRolePositions {
1232 guild_id: u64,
1234 },
1235 UpdateStageInstance {
1237 channel_id: u64,
1239 },
1240 UpdateTemplate {
1242 guild_id: u64,
1244 template_code: &'a str,
1246 },
1247 UpdateUserVoiceState {
1249 guild_id: u64,
1251 user_id: u64,
1253 },
1254 UpdateWebhook {
1256 token: Option<&'a str>,
1258 webhook_id: u64,
1260 },
1261 UpdateWebhookMessage {
1263 message_id: u64,
1264 thread_id: Option<u64>,
1266 token: &'a str,
1267 webhook_id: u64,
1268 },
1269 UpdateCurrentUserApplication,
1270}
1271
1272impl Route<'_> {
1273 #[allow(clippy::too_many_lines)]
1292 pub const fn method(&self) -> Method {
1293 match self {
1294 Self::DeleteAutoModerationRule { .. }
1295 | Self::DeleteApplicationEmoji { .. }
1296 | Self::DeleteBan { .. }
1297 | Self::DeleteChannel { .. }
1298 | Self::DeleteEmoji { .. }
1299 | Self::DeleteGlobalCommand { .. }
1300 | Self::DeleteGuild { .. }
1301 | Self::DeleteGuildCommand { .. }
1302 | Self::DeleteGuildIntegration { .. }
1303 | Self::DeleteGuildScheduledEvent { .. }
1304 | Self::DeleteGuildSticker { .. }
1305 | Self::DeleteTestEntitlement { .. }
1306 | Self::DeleteInteractionOriginal { .. }
1307 | Self::DeleteInvite { .. }
1308 | Self::DeleteMessageReactions { .. }
1309 | Self::DeleteMessageSpecificReaction { .. }
1310 | Self::DeleteMessage { .. }
1311 | Self::DeletePermissionOverwrite { .. }
1312 | Self::DeleteReactionCurrentUser { .. }
1313 | Self::DeleteReaction { .. }
1314 | Self::DeleteRole { .. }
1315 | Self::DeleteStageInstance { .. }
1316 | Self::DeleteTemplate { .. }
1317 | Self::DeleteWebhookMessage { .. }
1318 | Self::DeleteWebhook { .. }
1319 | Self::LeaveGuild { .. }
1320 | Self::LeaveThread { .. }
1321 | Self::RemoveMember { .. }
1322 | Self::RemoveMemberRole { .. }
1323 | Self::RemoveThreadMember { .. }
1324 | Self::UnpinMessage { .. } => Method::Delete,
1325 Self::GetActiveThreads { .. }
1326 | Self::GetApplicationEmojis { .. }
1327 | Self::GetAnswerVoters { .. }
1328 | Self::GetAuditLogs { .. }
1329 | Self::GetAutoModerationRule { .. }
1330 | Self::GetBan { .. }
1331 | Self::GetBans { .. }
1332 | Self::GetBansWithParameters { .. }
1333 | Self::GetGatewayBot
1334 | Self::GetChannel { .. }
1335 | Self::GetChannelInvites { .. }
1336 | Self::GetChannelWebhooks { .. }
1337 | Self::GetChannels { .. }
1338 | Self::GetCommandPermissions { .. }
1339 | Self::GetCurrentAuthorizationInformation
1340 | Self::GetCurrentUserApplicationInfo
1341 | Self::GetCurrentUser
1342 | Self::GetCurrentUserGuildMember { .. }
1343 | Self::GetCurrentUserVoiceState { .. }
1344 | Self::GetEmoji { .. }
1345 | Self::GetEmojis { .. }
1346 | Self::GetEntitlements { .. }
1347 | Self::GetEntitlement { .. }
1348 | Self::GetGateway
1349 | Self::GetFollowupMessage { .. }
1350 | Self::GetGlobalCommand { .. }
1351 | Self::GetGlobalCommands { .. }
1352 | Self::GetGuild { .. }
1353 | Self::GetGuildAutoModerationRules { .. }
1354 | Self::GetGuildCommand { .. }
1355 | Self::GetGuildCommandPermissions { .. }
1356 | Self::GetGuildCommands { .. }
1357 | Self::GetGuildIntegrations { .. }
1358 | Self::GetGuildInvites { .. }
1359 | Self::GetGuildMembers { .. }
1360 | Self::GetGuildOnboarding { .. }
1361 | Self::GetGuildPreview { .. }
1362 | Self::GetGuildPruneCount { .. }
1363 | Self::GetGuildRoles { .. }
1364 | Self::GetGuildRoleMemberCounts { .. }
1365 | Self::GetGuildScheduledEvent { .. }
1366 | Self::GetGuildScheduledEventUsers { .. }
1367 | Self::GetGuildScheduledEvents { .. }
1368 | Self::GetGuildSticker { .. }
1369 | Self::GetGuildStickers { .. }
1370 | Self::GetGuildVanityUrl { .. }
1371 | Self::GetGuildVoiceRegions { .. }
1372 | Self::GetGuildWelcomeScreen { .. }
1373 | Self::GetGuildWebhooks { .. }
1374 | Self::GetGuildWidget { .. }
1375 | Self::GetGuildWidgetSettings { .. }
1376 | Self::GetGuilds { .. }
1377 | Self::GetInteractionOriginal { .. }
1378 | Self::GetInvite { .. }
1379 | Self::GetInviteWithExpiration { .. }
1380 | Self::GetMember { .. }
1381 | Self::GetMessage { .. }
1382 | Self::GetMessages { .. }
1383 | Self::GetNitroStickerPacks { .. }
1384 | Self::GetPins { .. }
1385 | Self::GetJoinedPrivateArchivedThreads { .. }
1386 | Self::GetPrivateArchivedThreads { .. }
1387 | Self::GetPublicArchivedThreads { .. }
1388 | Self::GetReactionUsers { .. }
1389 | Self::GetRole { .. }
1390 | Self::GetSKUs { .. }
1391 | Self::GetSKUSubscriptions { .. }
1392 | Self::GetSKUSubscription { .. }
1393 | Self::GetStageInstance { .. }
1394 | Self::GetStickerPack { .. }
1395 | Self::GetSticker { .. }
1396 | Self::GetTemplate { .. }
1397 | Self::GetTemplates { .. }
1398 | Self::GetThreadMember { .. }
1399 | Self::GetThreadMembers { .. }
1400 | Self::GetUser { .. }
1401 | Self::GetUserConnections
1402 | Self::GetUserPrivateChannels
1403 | Self::GetUserVoiceState { .. }
1404 | Self::GetVoiceRegions
1405 | Self::GetWebhook { .. }
1406 | Self::GetWebhookMessage { .. }
1407 | Self::SearchGuildMembers { .. } => Method::Get,
1408 Self::UpdateAutoModerationRule { .. }
1409 | Self::UpdateChannel { .. }
1410 | Self::UpdateCurrentMember { .. }
1411 | Self::UpdateCurrentUser
1412 | Self::UpdateCurrentUserVoiceState { .. }
1413 | Self::UpdateEmoji { .. }
1414 | Self::UpdateGlobalCommand { .. }
1415 | Self::UpdateGuild { .. }
1416 | Self::UpdateGuildChannels { .. }
1417 | Self::UpdateGuildCommand { .. }
1418 | Self::UpdateGuildMfa { .. }
1419 | Self::UpdateGuildWidgetSettings { .. }
1420 | Self::UpdateGuildIntegration { .. }
1421 | Self::UpdateGuildScheduledEvent { .. }
1422 | Self::UpdateGuildSticker { .. }
1423 | Self::UpdateGuildWelcomeScreen { .. }
1424 | Self::UpdateInteractionOriginal { .. }
1425 | Self::UpdateMember { .. }
1426 | Self::UpdateMessage { .. }
1427 | Self::UpdateNickname { .. }
1428 | Self::UpdateRole { .. }
1429 | Self::UpdateRolePositions { .. }
1430 | Self::UpdateStageInstance { .. }
1431 | Self::UpdateTemplate { .. }
1432 | Self::UpdateUserVoiceState { .. }
1433 | Self::UpdateWebhookMessage { .. }
1434 | Self::UpdateCurrentUserApplication
1435 | Self::UpdateApplicationEmoji { .. }
1436 | Self::UpdateWebhook { .. } => Method::Patch,
1437 Self::CreateChannel { .. }
1438 | Self::AddApplicationEmoji { .. }
1439 | Self::BulkGuildBan { .. }
1440 | Self::ConsumeEntitlement { .. }
1441 | Self::CreateGlobalCommand { .. }
1442 | Self::CreateGuildCommand { .. }
1443 | Self::CreateEmoji { .. }
1444 | Self::CreateForumThread { .. }
1445 | Self::CreateGuild
1446 | Self::CreateAutoModerationRule { .. }
1447 | Self::CreateGuildFromTemplate { .. }
1448 | Self::CreateGuildIntegration { .. }
1449 | Self::CreateGuildPrune { .. }
1450 | Self::CreateGuildScheduledEvent { .. }
1451 | Self::CreateGuildSticker { .. }
1452 | Self::CreateInvite { .. }
1453 | Self::CreateMessage { .. }
1454 | Self::CreatePrivateChannel
1455 | Self::CreateThread { .. }
1456 | Self::CreateThreadFromMessage { .. }
1457 | Self::CreateRole { .. }
1458 | Self::CreateStageInstance { .. }
1459 | Self::CreateTemplate { .. }
1460 | Self::CreateTestEntitlement { .. }
1461 | Self::CreateTypingTrigger { .. }
1462 | Self::CreateWebhook { .. }
1463 | Self::CrosspostMessage { .. }
1464 | Self::DeleteMessages { .. }
1465 | Self::EndPoll { .. }
1466 | Self::ExecuteWebhook { .. }
1467 | Self::FollowNewsChannel { .. }
1468 | Self::InteractionCallback { .. }
1469 | Self::SyncGuildIntegration { .. } => Method::Post,
1470 Self::AddGuildMember { .. }
1471 | Self::AddMemberRole { .. }
1472 | Self::AddThreadMember { .. }
1473 | Self::CreateBan { .. }
1474 | Self::CreateReaction { .. }
1475 | Self::JoinThread { .. }
1476 | Self::PinMessage { .. }
1477 | Self::SetGlobalCommands { .. }
1478 | Self::SetGuildCommands { .. }
1479 | Self::SyncTemplate { .. }
1480 | Self::UpdateCommandPermissions { .. }
1481 | Self::UpdateGuildOnboarding { .. }
1482 | Self::UpdatePermissionOverwrite { .. } => Method::Put,
1483 }
1484 }
1485}
1486
1487impl Display for Route<'_> {
1521 #[allow(clippy::too_many_lines)]
1528 fn fmt(&self, f: &mut Formatter<'_>) -> FmtResult {
1529 match self {
1530 Route::AddGuildMember { guild_id, user_id }
1531 | Route::GetMember { guild_id, user_id }
1532 | Route::RemoveMember { guild_id, user_id }
1533 | Route::UpdateMember { guild_id, user_id } => {
1534 f.write_str("guilds/")?;
1535 Display::fmt(guild_id, f)?;
1536 f.write_str("/members/")?;
1537
1538 Display::fmt(user_id, f)
1539 }
1540 Route::AddMemberRole {
1541 guild_id,
1542 role_id,
1543 user_id,
1544 }
1545 | Route::RemoveMemberRole {
1546 guild_id,
1547 role_id,
1548 user_id,
1549 } => {
1550 f.write_str("guilds/")?;
1551 Display::fmt(guild_id, f)?;
1552 f.write_str("/members/")?;
1553 Display::fmt(user_id, f)?;
1554 f.write_str("/roles/")?;
1555
1556 Display::fmt(role_id, f)
1557 }
1558 Route::AddThreadMember {
1559 channel_id,
1560 user_id,
1561 }
1562 | Route::GetThreadMember {
1563 channel_id,
1564 user_id,
1565 }
1566 | Route::RemoveThreadMember {
1567 channel_id,
1568 user_id,
1569 } => {
1570 f.write_str("channels/")?;
1571 Display::fmt(channel_id, f)?;
1572 f.write_str("/thread-members/")?;
1573
1574 Display::fmt(user_id, f)
1575 }
1576 Route::BulkGuildBan { guild_id } => {
1577 f.write_str("guilds/")?;
1578 Display::fmt(guild_id, f)?;
1579
1580 f.write_str("/bulk-ban")
1581 }
1582 Route::ConsumeEntitlement {
1583 application_id,
1584 entitlement_id,
1585 } => {
1586 f.write_str("applications/")?;
1587 Display::fmt(application_id, f)?;
1588 f.write_str("/entitlements/")?;
1589 Display::fmt(entitlement_id, f)?;
1590
1591 f.write_str("/consume")
1592 }
1593 Route::CreateAutoModerationRule { guild_id, .. }
1594 | Route::GetGuildAutoModerationRules { guild_id, .. } => {
1595 f.write_str("guilds/")?;
1596 Display::fmt(guild_id, f)?;
1597
1598 f.write_str("/auto-moderation/rules")
1599 }
1600 Route::CreateChannel { guild_id }
1601 | Route::GetChannels { guild_id }
1602 | Route::UpdateGuildChannels { guild_id } => {
1603 f.write_str("guilds/")?;
1604 Display::fmt(guild_id, f)?;
1605
1606 f.write_str("/channels")
1607 }
1608 Route::CreateEmoji { guild_id } | Route::GetEmojis { guild_id } => {
1609 f.write_str("guilds/")?;
1610 Display::fmt(guild_id, f)?;
1611
1612 f.write_str("/emojis")
1613 }
1614 Route::CreateGlobalCommand { application_id }
1615 | Route::SetGlobalCommands { application_id } => {
1616 f.write_str("applications/")?;
1617 Display::fmt(application_id, f)?;
1618
1619 f.write_str("/commands")
1620 }
1621 Route::DeleteAutoModerationRule {
1622 auto_moderation_rule_id,
1623 guild_id,
1624 ..
1625 }
1626 | Route::GetAutoModerationRule {
1627 auto_moderation_rule_id,
1628 guild_id,
1629 ..
1630 }
1631 | Route::UpdateAutoModerationRule {
1632 auto_moderation_rule_id,
1633 guild_id,
1634 ..
1635 } => {
1636 f.write_str("guilds/")?;
1637 Display::fmt(guild_id, f)?;
1638 f.write_str("/auto-moderation/rules/")?;
1639
1640 Display::fmt(auto_moderation_rule_id, f)
1641 }
1642 Route::GetAnswerVoters {
1643 after,
1644 answer_id,
1645 channel_id,
1646 limit,
1647 message_id,
1648 } => {
1649 f.write_str("channels/")?;
1650 Display::fmt(channel_id, f)?;
1651 f.write_str("/polls/")?;
1652 Display::fmt(message_id, f)?;
1653 f.write_str("/answers/")?;
1654 Display::fmt(answer_id, f)?;
1655 f.write_str("?")?;
1656
1657 let mut writer = QueryStringFormatter::new(f);
1658 writer.write_opt_param("after", after.as_ref())?;
1659 writer.write_opt_param("limit", limit.as_ref())
1660 }
1661 Route::GetGlobalCommands {
1662 application_id,
1663 with_localizations,
1664 } => {
1665 f.write_str("applications/")?;
1666 Display::fmt(application_id, f)?;
1667 f.write_str("/commands")?;
1668
1669 let mut writer = QueryStringFormatter::new(f);
1670
1671 writer.write_opt_param("with_localizations", with_localizations.as_ref())
1672 }
1673 Route::CreateGuild => f.write_str("guilds"),
1674 Route::CreateGuildCommand {
1675 application_id,
1676 guild_id,
1677 }
1678 | Route::SetGuildCommands {
1679 application_id,
1680 guild_id,
1681 } => {
1682 f.write_str("applications/")?;
1683 Display::fmt(application_id, f)?;
1684 f.write_str("/guilds/")?;
1685 Display::fmt(guild_id, f)?;
1686
1687 f.write_str("/commands")
1688 }
1689 Route::GetGuildCommands {
1690 application_id,
1691 guild_id,
1692 with_localizations,
1693 } => {
1694 f.write_str("applications/")?;
1695 Display::fmt(application_id, f)?;
1696 f.write_str("/guilds/")?;
1697 Display::fmt(guild_id, f)?;
1698 f.write_str("/commands")?;
1699
1700 let mut writer = QueryStringFormatter::new(f);
1701 writer.write_opt_param("with_localizations", with_localizations.as_ref())
1702 }
1703 Route::CreateGuildFromTemplate { template_code }
1704 | Route::GetTemplate { template_code } => {
1705 f.write_str("guilds/templates/")?;
1706
1707 f.write_str(template_code)
1708 }
1709 Route::CreateTestEntitlement { application_id } => {
1710 f.write_str("applications/")?;
1711 Display::fmt(application_id, f)?;
1712
1713 f.write_str("/entitlements")
1714 }
1715 Route::CreateGuildIntegration { guild_id }
1716 | Route::GetGuildIntegrations { guild_id } => {
1717 f.write_str("guilds/")?;
1718 Display::fmt(guild_id, f)?;
1719
1720 f.write_str("/integrations")
1721 }
1722 Route::CreateGuildPrune {
1723 compute_prune_count,
1724 days,
1725 guild_id,
1726 include_roles,
1727 } => {
1728 f.write_str("guilds/")?;
1729 Display::fmt(guild_id, f)?;
1730 f.write_str("/prune")?;
1731
1732 let mut writer = QueryStringFormatter::new(f);
1733
1734 writer.write_opt_param("compute_prune_count", compute_prune_count.as_ref())?;
1735 writer.write_opt_param("days", days.as_ref())?;
1736
1737 if !include_roles.is_empty() {
1738 writer.write_param("include_roles", &QueryArray(*include_roles))?;
1739 }
1740
1741 Ok(())
1742 }
1743 Route::CreateGuildScheduledEvent { guild_id } => {
1744 f.write_str("guilds/")?;
1745 Display::fmt(guild_id, f)?;
1746
1747 f.write_str("/scheduled-events")
1748 }
1749 Route::CreateGuildSticker { guild_id, .. }
1750 | Route::GetGuildStickers { guild_id, .. } => {
1751 f.write_str("guilds/")?;
1752 Display::fmt(guild_id, f)?;
1753
1754 f.write_str("/stickers")
1755 }
1756 Route::CreateInvite { channel_id } | Route::GetChannelInvites { channel_id } => {
1757 f.write_str("channels/")?;
1758 Display::fmt(channel_id, f)?;
1759
1760 f.write_str("/invites")
1761 }
1762 Route::CreateMessage { channel_id } => {
1763 f.write_str("channels/")?;
1764 Display::fmt(channel_id, f)?;
1765
1766 f.write_str("/messages")
1767 }
1768 Route::CreatePrivateChannel | Route::GetUserPrivateChannels => {
1769 f.write_str("users/@me/channels")
1770 }
1771 Route::CreateReaction {
1772 channel_id,
1773 emoji,
1774 message_id,
1775 }
1776 | Route::DeleteReactionCurrentUser {
1777 channel_id,
1778 emoji,
1779 message_id,
1780 } => {
1781 f.write_str("channels/")?;
1782 Display::fmt(channel_id, f)?;
1783 f.write_str("/messages/")?;
1784 Display::fmt(message_id, f)?;
1785 f.write_str("/reactions/")?;
1786 Display::fmt(&emoji, f)?;
1787
1788 f.write_str("/@me")
1789 }
1790 Route::CreateRole { guild_id }
1791 | Route::GetGuildRoles { guild_id }
1792 | Route::UpdateRolePositions { guild_id } => {
1793 f.write_str("guilds/")?;
1794 Display::fmt(guild_id, f)?;
1795
1796 f.write_str("/roles")
1797 }
1798 Route::GetGuildRoleMemberCounts { guild_id } => {
1799 f.write_str("guilds/")?;
1800 Display::fmt(guild_id, f)?;
1801
1802 f.write_str("/roles/member-counts")
1803 }
1804 Route::CreateStageInstance { .. } => f.write_str("stage-instances"),
1805 Route::CreateTemplate { guild_id } | Route::GetTemplates { guild_id } => {
1806 f.write_str("guilds/")?;
1807 Display::fmt(guild_id, f)?;
1808
1809 f.write_str("/templates")
1810 }
1811 Route::CreateForumThread { channel_id } | Route::CreateThread { channel_id } => {
1812 f.write_str("channels/")?;
1813 Display::fmt(channel_id, f)?;
1814
1815 f.write_str("/threads")
1816 }
1817 Route::CreateThreadFromMessage {
1818 channel_id,
1819 message_id,
1820 } => {
1821 f.write_str("channels/")?;
1822 Display::fmt(channel_id, f)?;
1823 f.write_str("/messages/")?;
1824 Display::fmt(message_id, f)?;
1825
1826 f.write_str("/threads")
1827 }
1828 Route::CreateTypingTrigger { channel_id } => {
1829 f.write_str("channels/")?;
1830 Display::fmt(channel_id, f)?;
1831
1832 f.write_str("/typing")
1833 }
1834 Route::CreateWebhook { channel_id } | Route::GetChannelWebhooks { channel_id } => {
1835 f.write_str("channels/")?;
1836 Display::fmt(channel_id, f)?;
1837
1838 f.write_str("/webhooks")
1839 }
1840 Route::CrosspostMessage {
1841 channel_id,
1842 message_id,
1843 } => {
1844 f.write_str("channels/")?;
1845 Display::fmt(channel_id, f)?;
1846 f.write_str("/messages/")?;
1847 Display::fmt(message_id, f)?;
1848
1849 f.write_str("/crosspost")
1850 }
1851 Route::DeleteBan { guild_id, user_id }
1852 | Route::GetBan { guild_id, user_id }
1853 | Route::CreateBan { guild_id, user_id } => {
1854 f.write_str("guilds/")?;
1855 Display::fmt(guild_id, f)?;
1856 f.write_str("/bans/")?;
1857
1858 Display::fmt(user_id, f)
1859 }
1860 Route::DeleteChannel { channel_id }
1861 | Route::GetChannel { channel_id }
1862 | Route::UpdateChannel { channel_id } => {
1863 f.write_str("channels/")?;
1864
1865 Display::fmt(channel_id, f)
1866 }
1867 Route::DeleteEmoji { emoji_id, guild_id }
1868 | Route::GetEmoji { emoji_id, guild_id }
1869 | Route::UpdateEmoji { emoji_id, guild_id } => {
1870 f.write_str("guilds/")?;
1871 Display::fmt(guild_id, f)?;
1872 f.write_str("/emojis/")?;
1873
1874 Display::fmt(emoji_id, f)
1875 }
1876 Route::GetEntitlements {
1877 after,
1878 application_id,
1879 before,
1880 exclude_deleted,
1881 exclude_ended,
1882 guild_id,
1883 limit,
1884 sku_ids,
1885 user_id,
1886 } => {
1887 f.write_str("applications/")?;
1888 Display::fmt(application_id, f)?;
1889 f.write_str("/entitlements")?;
1890
1891 f.write_str("?")?;
1892
1893 if let Some(after) = after {
1894 f.write_str("after=")?;
1895 Display::fmt(after, f)?;
1896 }
1897
1898 if let Some(before) = before {
1899 f.write_str("&before=")?;
1900 Display::fmt(before, f)?;
1901 }
1902
1903 if let Some(exclude_deleted) = exclude_deleted {
1904 f.write_str("&exclude_deleted=")?;
1905 Display::fmt(exclude_deleted, f)?;
1906 }
1907
1908 if let Some(exclude_ended) = exclude_ended {
1909 f.write_str("&exclude_ended=")?;
1910 Display::fmt(exclude_ended, f)?;
1911 }
1912
1913 if let Some(guild_id) = guild_id {
1914 f.write_str("&guild_id=")?;
1915 Display::fmt(guild_id, f)?;
1916 }
1917
1918 if let Some(limit) = limit {
1919 f.write_str("&limit=")?;
1920 Display::fmt(limit, f)?;
1921 }
1922
1923 if !sku_ids.is_empty() {
1924 let sku_id_count = sku_ids.len() - 1;
1925
1926 f.write_str("&sku_ids=")?;
1927
1928 for (idx, sku_id) in sku_ids.iter().enumerate() {
1929 Display::fmt(sku_id, f)?;
1930
1931 if idx < sku_id_count {
1932 f.write_str(",")?;
1933 }
1934 }
1935 }
1936
1937 if let Some(user_id) = user_id {
1938 f.write_str("&user_id=")?;
1939 Display::fmt(user_id, f)?;
1940 }
1941
1942 Ok(())
1943 }
1944 Route::GetEntitlement {
1945 application_id,
1946 entitlement_id,
1947 }
1948 | Route::DeleteTestEntitlement {
1949 application_id,
1950 entitlement_id,
1951 } => {
1952 f.write_str("applications/")?;
1953 Display::fmt(application_id, f)?;
1954 f.write_str("/entitlements/")?;
1955
1956 Display::fmt(entitlement_id, f)
1957 }
1958 Route::DeleteGlobalCommand {
1959 application_id,
1960 command_id,
1961 }
1962 | Route::GetGlobalCommand {
1963 application_id,
1964 command_id,
1965 }
1966 | Route::UpdateGlobalCommand {
1967 application_id,
1968 command_id,
1969 } => {
1970 f.write_str("applications/")?;
1971 Display::fmt(application_id, f)?;
1972 f.write_str("/commands/")?;
1973
1974 Display::fmt(command_id, f)
1975 }
1976 Route::DeleteGuild { guild_id } | Route::UpdateGuild { guild_id } => {
1977 f.write_str("guilds/")?;
1978
1979 Display::fmt(guild_id, f)
1980 }
1981 Route::DeleteGuildCommand {
1982 application_id,
1983 command_id,
1984 guild_id,
1985 }
1986 | Route::GetGuildCommand {
1987 application_id,
1988 command_id,
1989 guild_id,
1990 }
1991 | Route::UpdateGuildCommand {
1992 application_id,
1993 command_id,
1994 guild_id,
1995 } => {
1996 f.write_str("applications/")?;
1997 Display::fmt(application_id, f)?;
1998 f.write_str("/guilds/")?;
1999 Display::fmt(guild_id, f)?;
2000 f.write_str("/commands/")?;
2001
2002 Display::fmt(command_id, f)
2003 }
2004 Route::DeleteGuildIntegration {
2005 guild_id,
2006 integration_id,
2007 }
2008 | Route::UpdateGuildIntegration {
2009 guild_id,
2010 integration_id,
2011 } => {
2012 f.write_str("guilds/")?;
2013 Display::fmt(guild_id, f)?;
2014 f.write_str("/integrations/")?;
2015
2016 Display::fmt(integration_id, f)
2017 }
2018 Route::DeleteInteractionOriginal {
2019 application_id,
2020 interaction_token,
2021 }
2022 | Route::GetInteractionOriginal {
2023 application_id,
2024 interaction_token,
2025 }
2026 | Route::UpdateInteractionOriginal {
2027 application_id,
2028 interaction_token,
2029 } => {
2030 f.write_str("webhooks/")?;
2031 Display::fmt(application_id, f)?;
2032 f.write_str("/")?;
2033 f.write_str(interaction_token)?;
2034
2035 f.write_str("/messages/@original")
2036 }
2037 Route::DeleteInvite { code } => {
2038 f.write_str("invites/")?;
2039
2040 f.write_str(code)
2041 }
2042 Route::DeleteMessageReactions {
2043 channel_id,
2044 message_id,
2045 } => {
2046 f.write_str("channels/")?;
2047 Display::fmt(channel_id, f)?;
2048 f.write_str("/messages/")?;
2049 Display::fmt(message_id, f)?;
2050
2051 f.write_str("/reactions")
2052 }
2053 Route::DeleteMessageSpecificReaction {
2054 channel_id,
2055 message_id,
2056 emoji,
2057 } => {
2058 f.write_str("channels/")?;
2059 Display::fmt(channel_id, f)?;
2060 f.write_str("/messages/")?;
2061 Display::fmt(message_id, f)?;
2062 f.write_str("/reactions/")?;
2063
2064 Display::fmt(&emoji, f)
2065 }
2066 Route::DeleteMessage {
2067 channel_id,
2068 message_id,
2069 }
2070 | Route::GetMessage {
2071 channel_id,
2072 message_id,
2073 }
2074 | Route::UpdateMessage {
2075 channel_id,
2076 message_id,
2077 } => {
2078 f.write_str("channels/")?;
2079 Display::fmt(channel_id, f)?;
2080 f.write_str("/messages/")?;
2081
2082 Display::fmt(message_id, f)
2083 }
2084 Route::DeleteMessages { channel_id } => {
2085 f.write_str("channels/")?;
2086 Display::fmt(channel_id, f)?;
2087
2088 f.write_str("/messages/bulk-delete")
2089 }
2090 Route::DeletePermissionOverwrite {
2091 channel_id,
2092 target_id,
2093 }
2094 | Route::UpdatePermissionOverwrite {
2095 channel_id,
2096 target_id,
2097 } => {
2098 f.write_str("channels/")?;
2099 Display::fmt(channel_id, f)?;
2100 f.write_str("/permissions/")?;
2101
2102 Display::fmt(target_id, f)
2103 }
2104 Route::DeleteReaction {
2105 channel_id,
2106 emoji,
2107 message_id,
2108 user_id,
2109 } => {
2110 f.write_str("channels/")?;
2111 Display::fmt(channel_id, f)?;
2112 f.write_str("/messages/")?;
2113 Display::fmt(message_id, f)?;
2114 f.write_str("/reactions/")?;
2115 Display::fmt(&emoji, f)?;
2116 f.write_str("/")?;
2117
2118 Display::fmt(user_id, f)
2119 }
2120 Route::DeleteRole { guild_id, role_id }
2121 | Route::GetRole { guild_id, role_id }
2122 | Route::UpdateRole { guild_id, role_id } => {
2123 f.write_str("guilds/")?;
2124 Display::fmt(guild_id, f)?;
2125 f.write_str("/roles/")?;
2126
2127 Display::fmt(role_id, f)
2128 }
2129 Route::DeleteStageInstance { channel_id }
2130 | Route::GetStageInstance { channel_id }
2131 | Route::UpdateStageInstance { channel_id } => {
2132 f.write_str("stage-instances/")?;
2133
2134 Display::fmt(channel_id, f)
2135 }
2136 Route::DeleteTemplate {
2137 guild_id,
2138 template_code,
2139 }
2140 | Route::SyncTemplate {
2141 guild_id,
2142 template_code,
2143 }
2144 | Route::UpdateTemplate {
2145 guild_id,
2146 template_code,
2147 } => {
2148 f.write_str("guilds/")?;
2149 Display::fmt(guild_id, f)?;
2150 f.write_str("/templates/")?;
2151
2152 f.write_str(template_code)
2153 }
2154 Route::DeleteWebhookMessage {
2155 message_id,
2156 thread_id,
2157 token,
2158 webhook_id,
2159 }
2160 | Route::GetFollowupMessage {
2161 application_id: webhook_id,
2162 interaction_token: token,
2163 thread_id,
2164 message_id,
2165 }
2166 | Route::GetWebhookMessage {
2167 message_id,
2168 token,
2169 thread_id,
2170 webhook_id,
2171 }
2172 | Route::UpdateWebhookMessage {
2173 message_id,
2174 thread_id,
2175 token,
2176 webhook_id,
2177 } => {
2178 f.write_str("webhooks/")?;
2179 Display::fmt(webhook_id, f)?;
2180 f.write_str("/")?;
2181 f.write_str(token)?;
2182 f.write_str("/messages/")?;
2183 Display::fmt(message_id, f)?;
2184
2185 let mut query_formatter = QueryStringFormatter::new(f);
2186
2187 query_formatter.write_opt_param("thread_id", thread_id.as_ref())
2188 }
2189 Route::DeleteWebhook { token, webhook_id }
2190 | Route::GetWebhook { token, webhook_id }
2191 | Route::UpdateWebhook { token, webhook_id } => {
2192 f.write_str("webhooks/")?;
2193 Display::fmt(webhook_id, f)?;
2194
2195 if let Some(token) = token {
2196 f.write_str("/")?;
2197 f.write_str(token)?;
2198 }
2199
2200 Ok(())
2201 }
2202 Route::EndPoll {
2203 channel_id,
2204 message_id,
2205 } => {
2206 f.write_str("channels/")?;
2207 Display::fmt(channel_id, f)?;
2208 f.write_str("/polls/")?;
2209 Display::fmt(message_id, f)?;
2210
2211 f.write_str("/expire")
2212 }
2213 Route::ExecuteWebhook {
2214 thread_id,
2215 token,
2216 wait,
2217 with_components,
2218 webhook_id,
2219 } => {
2220 f.write_str("webhooks/")?;
2221 Display::fmt(webhook_id, f)?;
2222 f.write_str("/")?;
2223 f.write_str(token)?;
2224
2225 let mut query_formatter = QueryStringFormatter::new(f);
2226
2227 query_formatter.write_opt_param("thread_id", thread_id.as_ref())?;
2228 query_formatter.write_opt_param("wait", wait.as_ref())?;
2229 query_formatter.write_opt_param("with_components", with_components.as_ref())
2230 }
2231 Route::FollowNewsChannel { channel_id } => {
2232 f.write_str("channels/")?;
2233 Display::fmt(channel_id, f)?;
2234
2235 f.write_str("/followers")
2236 }
2237 Route::GetActiveThreads { guild_id } => {
2238 f.write_str("guilds/")?;
2239 Display::fmt(guild_id, f)?;
2240
2241 f.write_str("/threads/active")
2242 }
2243 Route::DeleteApplicationEmoji {
2244 application_id,
2245 emoji_id,
2246 }
2247 | Route::UpdateApplicationEmoji {
2248 application_id,
2249 emoji_id,
2250 } => {
2251 f.write_str("applications/")?;
2252 Display::fmt(application_id, f)?;
2253 f.write_str("/emojis/")?;
2254
2255 Display::fmt(emoji_id, f)
2256 }
2257 Route::GetApplicationEmojis { application_id }
2258 | Route::AddApplicationEmoji { application_id } => {
2259 f.write_str("applications/")?;
2260 Display::fmt(application_id, f)?;
2261
2262 f.write_str("/emojis")
2263 }
2264 Route::GetAuditLogs {
2265 action_type,
2266 after,
2267 before,
2268 guild_id,
2269 limit,
2270 user_id,
2271 } => {
2272 f.write_str("guilds/")?;
2273 Display::fmt(guild_id, f)?;
2274 f.write_str("/audit-logs")?;
2275
2276 let mut query_formatter = QueryStringFormatter::new(f);
2277
2278 query_formatter.write_opt_param("action_type", action_type.as_ref())?;
2279 query_formatter.write_opt_param("after", after.as_ref())?;
2280 query_formatter.write_opt_param("before", before.as_ref())?;
2281 query_formatter.write_opt_param("limit", limit.as_ref())?;
2282 query_formatter.write_opt_param("user_id", user_id.as_ref())
2283 }
2284 Route::GetBans { guild_id } => {
2285 f.write_str("guilds/")?;
2286 Display::fmt(guild_id, f)?;
2287
2288 f.write_str("/bans")
2289 }
2290 Route::GetBansWithParameters {
2291 after,
2292 before,
2293 guild_id,
2294 limit,
2295 } => {
2296 f.write_str("guilds/")?;
2297 Display::fmt(guild_id, f)?;
2298 f.write_str("/bans")?;
2299
2300 let mut query_formatter = QueryStringFormatter::new(f);
2301
2302 query_formatter.write_opt_param("after", after.as_ref())?;
2303 query_formatter.write_opt_param("before", before.as_ref())?;
2304 query_formatter.write_opt_param("limit", limit.as_ref())
2305 }
2306 Route::GetGatewayBot => f.write_str("gateway/bot"),
2307 Route::GetCommandPermissions {
2308 application_id,
2309 command_id,
2310 guild_id,
2311 }
2312 | Route::UpdateCommandPermissions {
2313 application_id,
2314 command_id,
2315 guild_id,
2316 } => {
2317 f.write_str("applications/")?;
2318 Display::fmt(application_id, f)?;
2319 f.write_str("/guilds/")?;
2320 Display::fmt(guild_id, f)?;
2321 f.write_str("/commands/")?;
2322 Display::fmt(command_id, f)?;
2323
2324 f.write_str("/permissions")
2325 }
2326 Route::GetCurrentAuthorizationInformation => f.write_str("oauth2/@me"),
2327 Route::GetCurrentUserApplicationInfo | Route::UpdateCurrentUserApplication => {
2328 f.write_str("applications/@me")
2329 }
2330 Route::GetCurrentUser | Route::UpdateCurrentUser => f.write_str("users/@me"),
2331 Route::GetCurrentUserGuildMember { guild_id } => {
2332 f.write_str("users/@me/guilds/")?;
2333 Display::fmt(guild_id, f)?;
2334
2335 f.write_str("/member")
2336 }
2337 Route::GetGateway => f.write_str("gateway"),
2338 Route::GetGuild {
2339 guild_id,
2340 with_counts,
2341 } => {
2342 f.write_str("guilds/")?;
2343 Display::fmt(guild_id, f)?;
2344
2345 let mut query_formatter = QueryStringFormatter::new(f);
2346
2347 if *with_counts {
2348 query_formatter.write_param("with_counts", &true)?;
2349 }
2350
2351 Ok(())
2352 }
2353 Route::GetGuildCommandPermissions {
2354 application_id,
2355 guild_id,
2356 } => {
2357 f.write_str("applications/")?;
2358 Display::fmt(application_id, f)?;
2359 f.write_str("/guilds/")?;
2360 Display::fmt(guild_id, f)?;
2361
2362 f.write_str("/commands/permissions")
2363 }
2364 Route::GetGuildInvites { guild_id } => {
2365 f.write_str("guilds/")?;
2366 Display::fmt(guild_id, f)?;
2367
2368 f.write_str("/invites")
2369 }
2370 Route::GetGuildMembers {
2371 after,
2372 guild_id,
2373 limit,
2374 } => {
2375 f.write_str("guilds/")?;
2376 Display::fmt(guild_id, f)?;
2377 f.write_str("/members")?;
2378
2379 let mut query_formatter = QueryStringFormatter::new(f);
2380
2381 query_formatter.write_opt_param("after", after.as_ref())?;
2382 query_formatter.write_opt_param("limit", limit.as_ref())
2383 }
2384 Route::GetGuildOnboarding { guild_id } | Route::UpdateGuildOnboarding { guild_id } => {
2385 f.write_str("guilds/")?;
2386 Display::fmt(guild_id, f)?;
2387
2388 f.write_str("/onboarding")
2389 }
2390 Route::GetGuildPreview { guild_id } => {
2391 f.write_str("guilds/")?;
2392 Display::fmt(guild_id, f)?;
2393
2394 f.write_str("/preview")
2395 }
2396 Route::GetGuildPruneCount {
2397 days,
2398 guild_id,
2399 include_roles,
2400 } => {
2401 f.write_str("guilds/")?;
2402 Display::fmt(guild_id, f)?;
2403 f.write_str("/prune")?;
2404
2405 let mut query_formatter = QueryStringFormatter::new(f);
2406
2407 query_formatter.write_opt_param("days", days.as_ref())?;
2408
2409 if !include_roles.is_empty() {
2410 query_formatter.write_param("include_roles", &QueryArray(*include_roles))?;
2411 }
2412
2413 Ok(())
2414 }
2415 Route::GetGuildScheduledEvent {
2416 guild_id,
2417 scheduled_event_id,
2418 with_user_count,
2419 } => {
2420 f.write_str("guilds/")?;
2421 Display::fmt(guild_id, f)?;
2422 f.write_str("/scheduled-events/")?;
2423 Display::fmt(scheduled_event_id, f)?;
2424
2425 let mut query_formatter = QueryStringFormatter::new(f);
2426
2427 if *with_user_count {
2428 query_formatter.write_param("with_user_count", &true)?;
2429 }
2430
2431 Ok(())
2432 }
2433 Route::GetGuildScheduledEventUsers {
2434 after,
2435 before,
2436 guild_id,
2437 limit,
2438 scheduled_event_id,
2439 with_member,
2440 } => {
2441 f.write_str("guilds/")?;
2442 Display::fmt(guild_id, f)?;
2443 f.write_str("/scheduled-events/")?;
2444 Display::fmt(scheduled_event_id, f)?;
2445 f.write_str("/users")?;
2446
2447 let mut query_formatter = QueryStringFormatter::new(f);
2448
2449 query_formatter.write_opt_param("after", after.as_ref())?;
2450 query_formatter.write_opt_param("before", before.as_ref())?;
2451 query_formatter.write_opt_param("limit", limit.as_ref())?;
2452
2453 if *with_member {
2454 query_formatter.write_param("with_member", &true)?;
2455 }
2456
2457 Ok(())
2458 }
2459 Route::GetGuildScheduledEvents {
2460 guild_id,
2461 with_user_count,
2462 } => {
2463 f.write_str("guilds/")?;
2464 Display::fmt(guild_id, f)?;
2465 f.write_str("/scheduled-events")?;
2466
2467 let mut query_formatter = QueryStringFormatter::new(f);
2468
2469 if *with_user_count {
2470 query_formatter.write_param("with_user_count", &true)?;
2471 }
2472
2473 Ok(())
2474 }
2475 Route::GetGuildSticker {
2476 guild_id,
2477 sticker_id,
2478 ..
2479 }
2480 | Route::DeleteGuildSticker {
2481 guild_id,
2482 sticker_id,
2483 ..
2484 }
2485 | Route::UpdateGuildSticker {
2486 guild_id,
2487 sticker_id,
2488 ..
2489 } => {
2490 f.write_str("guilds/")?;
2491 Display::fmt(guild_id, f)?;
2492 f.write_str("/stickers/")?;
2493
2494 Display::fmt(sticker_id, f)
2495 }
2496 Route::GetGuildVanityUrl { guild_id } => {
2497 f.write_str("guilds/")?;
2498 Display::fmt(guild_id, f)?;
2499
2500 f.write_str("/vanity-url")
2501 }
2502 Route::GetGuildVoiceRegions { guild_id } => {
2503 f.write_str("guilds/")?;
2504 Display::fmt(guild_id, f)?;
2505
2506 f.write_str("/regions")
2507 }
2508 Route::GetGuildWelcomeScreen { guild_id }
2509 | Route::UpdateGuildWelcomeScreen { guild_id } => {
2510 f.write_str("guilds/")?;
2511 Display::fmt(guild_id, f)?;
2512
2513 f.write_str("/welcome-screen")
2514 }
2515 Route::GetGuildWebhooks { guild_id } => {
2516 f.write_str("guilds/")?;
2517 Display::fmt(guild_id, f)?;
2518
2519 f.write_str("/webhooks")
2520 }
2521 Route::GetGuildWidget { guild_id } => {
2522 f.write_str("guilds/")?;
2523 Display::fmt(guild_id, f)?;
2524
2525 f.write_str("/widget.json")
2526 }
2527 Route::GetGuildWidgetSettings { guild_id }
2528 | Route::UpdateGuildWidgetSettings { guild_id } => {
2529 f.write_str("guilds/")?;
2530 Display::fmt(guild_id, f)?;
2531
2532 f.write_str("/widget")
2533 }
2534 Route::GetGuilds {
2535 after,
2536 before,
2537 limit,
2538 shard,
2539 } => {
2540 f.write_str("users/@me/guilds")?;
2541
2542 let mut query_formatter = QueryStringFormatter::new(f);
2543
2544 query_formatter.write_opt_param("after", after.as_ref())?;
2545 query_formatter.write_opt_param("before", before.as_ref())?;
2546 query_formatter.write_opt_param("limit", limit.as_ref())?;
2547 query_formatter.write_opt_param("shard", shard.as_ref())
2548 }
2549 Route::GetInvite { code, with_counts } => {
2550 f.write_str("invites/")?;
2551 f.write_str(code)?;
2552
2553 let mut query_formatter = QueryStringFormatter::new(f);
2554
2555 if *with_counts {
2556 query_formatter.write_param("with_counts", &true)?;
2557 }
2558
2559 Ok(())
2560 }
2561 Route::GetInviteWithExpiration {
2562 code,
2563 with_counts,
2564 with_expiration,
2565 } => {
2566 f.write_str("invites/")?;
2567 f.write_str(code)?;
2568
2569 let mut query_formatter = QueryStringFormatter::new(f);
2570
2571 if *with_counts {
2572 query_formatter.write_param("with_counts", &true)?;
2573 }
2574
2575 if *with_expiration {
2576 query_formatter.write_param("with_expiration", &true)?;
2577 }
2578
2579 Ok(())
2580 }
2581 Route::GetMessages {
2582 channel_id,
2583 after,
2584 around,
2585 before,
2586 limit,
2587 } => {
2588 f.write_str("channels/")?;
2589 Display::fmt(channel_id, f)?;
2590 f.write_str("/messages")?;
2591
2592 let mut query_formatter = QueryStringFormatter::new(f);
2593
2594 query_formatter.write_opt_param("after", after.as_ref())?;
2595 query_formatter.write_opt_param("around", around.as_ref())?;
2596 query_formatter.write_opt_param("before", before.as_ref())?;
2597 query_formatter.write_opt_param("limit", limit.as_ref())
2598 }
2599 Route::GetNitroStickerPacks { .. } => f.write_str("sticker-packs"),
2600 Route::GetPins {
2601 channel_id,
2602 limit,
2603 before,
2604 } => {
2605 f.write_str("channels/")?;
2606 Display::fmt(channel_id, f)?;
2607
2608 f.write_str("/messages/pins")?;
2609
2610 let mut query_formatter = QueryStringFormatter::new(f);
2611
2612 query_formatter.write_opt_param("before", before.as_ref())?;
2613 query_formatter.write_opt_param("limit", limit.as_ref())
2614 }
2615 Route::GetJoinedPrivateArchivedThreads {
2616 before,
2617 channel_id,
2618 limit,
2619 } => {
2620 f.write_str("channels/")?;
2621 Display::fmt(channel_id, f)?;
2622 f.write_str("/users/@me/threads/archived/private")?;
2623
2624 let mut query_formatter = QueryStringFormatter::new(f);
2625
2626 query_formatter.write_opt_param("before", before.as_ref())?;
2627 query_formatter.write_opt_param("limit", limit.as_ref())
2628 }
2629 Route::GetPrivateArchivedThreads {
2630 before,
2631 channel_id,
2632 limit,
2633 } => {
2634 f.write_str("channels/")?;
2635 Display::fmt(channel_id, f)?;
2636 f.write_str("/threads/archived/private")?;
2637
2638 let mut query_formatter = QueryStringFormatter::new(f);
2639
2640 query_formatter.write_opt_param("before", before.as_ref())?;
2641 query_formatter.write_opt_param("limit", limit.as_ref())
2642 }
2643 Route::GetPublicArchivedThreads {
2644 before,
2645 channel_id,
2646 limit,
2647 } => {
2648 f.write_str("channels/")?;
2649 Display::fmt(channel_id, f)?;
2650 f.write_str("/threads/archived/public")?;
2651
2652 let mut query_formatter = QueryStringFormatter::new(f);
2653
2654 query_formatter.write_opt_param("before", before.as_ref())?;
2655 query_formatter.write_opt_param("limit", limit.as_ref())
2656 }
2657 Route::GetReactionUsers {
2658 after,
2659 channel_id,
2660 emoji,
2661 limit,
2662 message_id,
2663 kind,
2664 } => {
2665 f.write_str("channels/")?;
2666 Display::fmt(channel_id, f)?;
2667 f.write_str("/messages/")?;
2668 Display::fmt(message_id, f)?;
2669 f.write_str("/reactions/")?;
2670 Display::fmt(&emoji, f)?;
2671
2672 let mut query_formatter = QueryStringFormatter::new(f);
2673
2674 query_formatter.write_opt_param("after", after.as_ref())?;
2675 query_formatter.write_opt_param("limit", limit.as_ref())?;
2676 query_formatter.write_opt_param("type", kind.as_ref())
2677 }
2678 Route::GetStickerPack { sticker_pack_id } => {
2679 f.write_str("sticker-packs/")?;
2680
2681 Display::fmt(sticker_pack_id, f)
2682 }
2683 Route::GetSticker { sticker_id } => {
2684 f.write_str("stickers/")?;
2685
2686 Display::fmt(sticker_id, f)
2687 }
2688 Route::GetThreadMembers {
2689 after,
2690 channel_id,
2691 limit,
2692 with_member,
2693 } => {
2694 f.write_str("channels/")?;
2695 Display::fmt(channel_id, f)?;
2696 f.write_str("/thread-members")?;
2697
2698 let mut query_formatter = QueryStringFormatter::new(f);
2699
2700 query_formatter.write_opt_param("after", after.as_ref())?;
2701 query_formatter.write_opt_param("limit", limit.as_ref())?;
2702 query_formatter.write_opt_param("with_member", with_member.as_ref())
2703 }
2704 Route::GetUserConnections => f.write_str("users/@me/connections"),
2705 Route::GetUser { user_id } => {
2706 f.write_str("users/")?;
2707
2708 Display::fmt(user_id, f)
2709 }
2710 Route::GetVoiceRegions => f.write_str("voice/regions"),
2711 Route::InteractionCallback {
2712 interaction_id,
2713 interaction_token,
2714 with_response,
2715 } => {
2716 f.write_str("interactions/")?;
2717 Display::fmt(interaction_id, f)?;
2718 f.write_str("/")?;
2719 f.write_str(interaction_token)?;
2720
2721 f.write_str("/callback")?;
2722
2723 if *with_response {
2724 f.write_str("?with_response=true")?;
2725 }
2726
2727 Ok(())
2728 }
2729 Route::JoinThread { channel_id } | Route::LeaveThread { channel_id } => {
2730 f.write_str("channels/")?;
2731 Display::fmt(channel_id, f)?;
2732
2733 f.write_str("/thread-members/@me")
2734 }
2735 Route::LeaveGuild { guild_id } => {
2736 f.write_str("users/@me/guilds/")?;
2737
2738 Display::fmt(guild_id, f)
2739 }
2740 Route::PinMessage {
2741 channel_id,
2742 message_id,
2743 }
2744 | Route::UnpinMessage {
2745 channel_id,
2746 message_id,
2747 } => {
2748 f.write_str("channels/")?;
2749 Display::fmt(channel_id, f)?;
2750 f.write_str("/messages/pins/")?;
2751
2752 Display::fmt(message_id, f)
2753 }
2754 Route::SearchGuildMembers {
2755 guild_id,
2756 limit,
2757 query,
2758 } => {
2759 f.write_str("guilds/")?;
2760 Display::fmt(guild_id, f)?;
2761 f.write_str("/members/search")?;
2762
2763 let mut query_formatter = QueryStringFormatter::new(f);
2764
2765 query_formatter
2766 .write_param("query", &utf8_percent_encode(query, NON_ALPHANUMERIC))?;
2767 query_formatter.write_opt_param("limit", limit.as_ref())
2768 }
2769 Route::SyncGuildIntegration {
2770 guild_id,
2771 integration_id,
2772 } => {
2773 f.write_str("guilds/")?;
2774 Display::fmt(guild_id, f)?;
2775 f.write_str("/integrations/")?;
2776 Display::fmt(integration_id, f)?;
2777
2778 f.write_str("/sync")
2779 }
2780 Route::UpdateCurrentMember { guild_id } => {
2781 f.write_str("guilds/")?;
2782 Display::fmt(guild_id, f)?;
2783
2784 f.write_str("/members/@me")
2785 }
2786 Route::GetCurrentUserVoiceState { guild_id }
2787 | Route::UpdateCurrentUserVoiceState { guild_id } => {
2788 f.write_str("guilds/")?;
2789 Display::fmt(guild_id, f)?;
2790
2791 f.write_str("/voice-states/@me")
2792 }
2793 Route::DeleteGuildScheduledEvent {
2794 guild_id,
2795 scheduled_event_id,
2796 }
2797 | Route::UpdateGuildScheduledEvent {
2798 guild_id,
2799 scheduled_event_id,
2800 } => {
2801 f.write_str("guilds/")?;
2802 Display::fmt(guild_id, f)?;
2803 f.write_str("/scheduled-events/")?;
2804
2805 Display::fmt(scheduled_event_id, f)
2806 }
2807 Route::UpdateNickname { guild_id } => {
2808 f.write_str("guilds/")?;
2809 Display::fmt(guild_id, f)?;
2810
2811 f.write_str("/members/@me/nick")
2812 }
2813 Route::GetUserVoiceState { guild_id, user_id }
2814 | Route::UpdateUserVoiceState { guild_id, user_id } => {
2815 f.write_str("guilds/")?;
2816 Display::fmt(guild_id, f)?;
2817 f.write_str("/voice-states/")?;
2818
2819 Display::fmt(user_id, f)
2820 }
2821 Route::UpdateGuildMfa { guild_id, .. } => {
2822 f.write_str("guilds/")?;
2823 Display::fmt(guild_id, f)?;
2824
2825 f.write_str("/mfa")
2826 }
2827 Route::GetSKUs { application_id } => {
2828 f.write_str("applications/")?;
2829 Display::fmt(application_id, f)?;
2830
2831 f.write_str("/skus")
2832 }
2833 Route::GetSKUSubscriptions {
2834 after,
2835 before,
2836 limit,
2837 sku_id,
2838 user_id,
2839 } => {
2840 f.write_str("skus/")?;
2841 Display::fmt(sku_id, f)?;
2842 f.write_str("/subscriptions")?;
2843
2844 let mut writer = QueryStringFormatter::new(f);
2845 writer.write_opt_param("after", after.as_ref())?;
2846 writer.write_opt_param("before", before.as_ref())?;
2847 writer.write_opt_param("limit", limit.as_ref())?;
2848
2849 writer.write_opt_param("user_id", user_id.as_ref())
2850 }
2851 Route::GetSKUSubscription {
2852 sku_id,
2853 subscription_id,
2854 } => {
2855 f.write_str("skus/")?;
2856 Display::fmt(sku_id, f)?;
2857 f.write_str("/subscriptions/")?;
2858
2859 Display::fmt(subscription_id, f)
2860 }
2861 }
2862 }
2863}
2864
2865#[cfg(test)]
2866mod tests {
2867 use super::Route;
2868 use crate::request::{Method, channel::reaction::RequestReactionType};
2869 use twilight_model::id::Id;
2870
2871 #[test]
2873 fn methods() {
2874 assert_eq!(
2875 Method::Delete,
2876 Route::DeleteInvite {
2877 code: "twilight-rs",
2878 }
2879 .method()
2880 );
2881 assert_eq!(
2882 Method::Get,
2883 Route::GetInvite {
2884 code: "twilight-rs",
2885 with_counts: false,
2886 }
2887 .method()
2888 );
2889 assert_eq!(
2890 Method::Patch,
2891 Route::UpdateMessage {
2892 channel_id: 123,
2893 message_id: 456,
2894 }
2895 .method()
2896 );
2897 assert_eq!(Method::Post, Route::CreateGuild.method());
2898 assert_eq!(
2899 Method::Put,
2900 Route::SyncTemplate {
2901 guild_id: 123,
2902 template_code: "abc",
2903 }
2904 .method()
2905 );
2906 }
2907
2908 const APPLICATION_ID: u64 = 1;
2911 const CHANNEL_ID: u64 = 2;
2912 const CODE: &str = "invitecode";
2913 const COMMAND_ID: u64 = 3;
2914 const EMOJI_ID: u64 = 4;
2915 const GUILD_ID: u64 = 5;
2916 const INTERACTION_ID: u64 = 6;
2917 const INTERACTION_TOKEN: &str = "interactiontoken";
2918 const INTEGRATION_ID: u64 = 7;
2919 const MESSAGE_ID: u64 = 8;
2920 const ROLE_ID: u64 = 9;
2921 const STICKER_ID: u64 = 10;
2922 const TEMPLATE_CODE: &str = "templatecode";
2923 const USER_ID: u64 = 11;
2924 const SCHEDULED_EVENT_ID: u64 = 12;
2925 const AUTO_MODERATION_RULE_ID: u64 = 13;
2926 const STICKER_PACK_ID: u64 = 14;
2927 const SKU_ID: u64 = 15;
2928 const SUBSCRIPTION_ID: u64 = 16;
2929 const ENTITLEMENT_ID: u64 = 17;
2930
2931 const fn emoji() -> RequestReactionType<'static> {
2932 RequestReactionType::Custom {
2933 id: Id::new(EMOJI_ID),
2934 name: None,
2935 }
2936 }
2937
2938 #[test]
2939 fn get_public_archived_threads() {
2940 let route = Route::GetPublicArchivedThreads {
2941 channel_id: 1,
2942 before: Some("2021-01-01T00:00:00Z"),
2943 limit: None,
2944 };
2945
2946 assert_eq!(
2947 "channels/1/threads/archived/public?before=2021-01-01T00:00:00Z",
2948 route.to_string()
2949 );
2950 }
2951
2952 #[test]
2953 fn update_webhook_message_thread_id() {
2954 let route = Route::UpdateWebhookMessage {
2955 message_id: 1,
2956 thread_id: Some(2),
2957 token: "token",
2958 webhook_id: 3,
2959 };
2960
2961 assert_eq!("webhooks/3/token/messages/1?thread_id=2", route.to_string());
2962 }
2963
2964 #[test]
2965 fn add_guild_member() {
2966 let route = Route::AddGuildMember {
2967 guild_id: GUILD_ID,
2968 user_id: USER_ID,
2969 };
2970 assert_eq!(
2971 route.to_string(),
2972 format!("guilds/{GUILD_ID}/members/{USER_ID}")
2973 );
2974 }
2975
2976 #[test]
2977 fn get_member() {
2978 let route = Route::GetMember {
2979 guild_id: GUILD_ID,
2980 user_id: USER_ID,
2981 };
2982 assert_eq!(
2983 route.to_string(),
2984 format!("guilds/{GUILD_ID}/members/{USER_ID}")
2985 );
2986 }
2987
2988 #[test]
2989 fn remove_member() {
2990 let route = Route::RemoveMember {
2991 guild_id: GUILD_ID,
2992 user_id: USER_ID,
2993 };
2994 assert_eq!(
2995 route.to_string(),
2996 format!("guilds/{GUILD_ID}/members/{USER_ID}")
2997 );
2998 }
2999
3000 #[test]
3001 fn update_member() {
3002 let route = Route::UpdateMember {
3003 guild_id: GUILD_ID,
3004 user_id: USER_ID,
3005 };
3006 assert_eq!(
3007 route.to_string(),
3008 format!("guilds/{GUILD_ID}/members/{USER_ID}")
3009 );
3010 }
3011
3012 #[test]
3013 fn add_member_role() {
3014 let route = Route::AddMemberRole {
3015 guild_id: GUILD_ID,
3016 role_id: ROLE_ID,
3017 user_id: USER_ID,
3018 };
3019 assert_eq!(
3020 route.to_string(),
3021 format!("guilds/{GUILD_ID}/members/{USER_ID}/roles/{ROLE_ID}")
3022 );
3023 }
3024
3025 #[test]
3026 fn remove_member_role() {
3027 let route = Route::RemoveMemberRole {
3028 guild_id: GUILD_ID,
3029 role_id: ROLE_ID,
3030 user_id: USER_ID,
3031 };
3032 assert_eq!(
3033 route.to_string(),
3034 format!("guilds/{GUILD_ID}/members/{USER_ID}/roles/{ROLE_ID}")
3035 );
3036 }
3037
3038 #[test]
3039 fn add_thread_member() {
3040 let route = Route::AddThreadMember {
3041 channel_id: CHANNEL_ID,
3042 user_id: USER_ID,
3043 };
3044 assert_eq!(
3045 route.to_string(),
3046 format!("channels/{CHANNEL_ID}/thread-members/{USER_ID}")
3047 );
3048 }
3049
3050 #[test]
3051 fn get_thread_member() {
3052 let route = Route::GetThreadMember {
3053 channel_id: CHANNEL_ID,
3054 user_id: USER_ID,
3055 };
3056 assert_eq!(
3057 route.to_string(),
3058 format!("channels/{CHANNEL_ID}/thread-members/{USER_ID}")
3059 );
3060 }
3061
3062 #[test]
3063 fn remove_thread_member() {
3064 let route = Route::RemoveThreadMember {
3065 channel_id: CHANNEL_ID,
3066 user_id: USER_ID,
3067 };
3068 assert_eq!(
3069 route.to_string(),
3070 format!("channels/{CHANNEL_ID}/thread-members/{USER_ID}")
3071 );
3072 }
3073
3074 #[test]
3075 fn create_channel() {
3076 let route = Route::CreateChannel { guild_id: GUILD_ID };
3077 assert_eq!(route.to_string(), format!("guilds/{GUILD_ID}/channels"));
3078 }
3079
3080 #[test]
3081 fn get_channels() {
3082 let route = Route::GetChannels { guild_id: GUILD_ID };
3083 assert_eq!(route.to_string(), format!("guilds/{GUILD_ID}/channels"));
3084 }
3085
3086 #[test]
3087 fn update_guild_channels() {
3088 let route = Route::UpdateGuildChannels { guild_id: GUILD_ID };
3089 assert_eq!(route.to_string(), format!("guilds/{GUILD_ID}/channels"));
3090 }
3091
3092 #[test]
3093 fn create_emoji() {
3094 let route = Route::CreateEmoji { guild_id: GUILD_ID };
3095 assert_eq!(route.to_string(), format!("guilds/{GUILD_ID}/emojis"));
3096 }
3097
3098 #[test]
3099 fn get_emojis() {
3100 let route = Route::GetEmojis { guild_id: GUILD_ID };
3101 assert_eq!(route.to_string(), format!("guilds/{GUILD_ID}/emojis"));
3102 }
3103
3104 #[test]
3105 fn create_global_command() {
3106 let route = Route::CreateGlobalCommand {
3107 application_id: APPLICATION_ID,
3108 };
3109 assert_eq!(
3110 route.to_string(),
3111 format!("applications/{APPLICATION_ID}/commands")
3112 );
3113 }
3114
3115 #[test]
3116 fn get_global_commands() {
3117 let route = Route::GetGlobalCommands {
3118 application_id: APPLICATION_ID,
3119 with_localizations: Some(true),
3120 };
3121 assert_eq!(
3122 route.to_string(),
3123 format!("applications/{APPLICATION_ID}/commands?with_localizations=true")
3124 );
3125
3126 let route = Route::GetGlobalCommands {
3127 application_id: APPLICATION_ID,
3128 with_localizations: None,
3129 };
3130 assert_eq!(
3131 route.to_string(),
3132 format!("applications/{APPLICATION_ID}/commands")
3133 );
3134 }
3135
3136 #[test]
3137 fn set_global_commands() {
3138 let route = Route::SetGlobalCommands {
3139 application_id: APPLICATION_ID,
3140 };
3141 assert_eq!(
3142 route.to_string(),
3143 format!("applications/{APPLICATION_ID}/commands")
3144 );
3145 }
3146
3147 #[test]
3148 fn create_guild() {
3149 let route = Route::CreateGuild;
3150 assert_eq!(route.to_string(), "guilds");
3151 }
3152
3153 #[test]
3154 fn create_guild_command() {
3155 let route = Route::CreateGuildCommand {
3156 application_id: APPLICATION_ID,
3157 guild_id: GUILD_ID,
3158 };
3159 assert_eq!(
3160 route.to_string(),
3161 format!("applications/{APPLICATION_ID}/guilds/{GUILD_ID}/commands")
3162 );
3163 }
3164
3165 #[test]
3166 fn get_guild_commands() {
3167 let route = Route::GetGuildCommands {
3168 application_id: APPLICATION_ID,
3169 guild_id: GUILD_ID,
3170 with_localizations: Some(true),
3171 };
3172 assert_eq!(
3173 route.to_string(),
3174 format!(
3175 "applications/{APPLICATION_ID}/guilds/{GUILD_ID}/commands?with_localizations=true"
3176 )
3177 );
3178
3179 let route = Route::GetGuildCommands {
3180 application_id: APPLICATION_ID,
3181 guild_id: GUILD_ID,
3182 with_localizations: None,
3183 };
3184 assert_eq!(
3185 route.to_string(),
3186 format!("applications/{APPLICATION_ID}/guilds/{GUILD_ID}/commands")
3187 );
3188 }
3189
3190 #[test]
3191 fn set_guild_commands() {
3192 let route = Route::SetGuildCommands {
3193 application_id: APPLICATION_ID,
3194 guild_id: GUILD_ID,
3195 };
3196 assert_eq!(
3197 route.to_string(),
3198 format!("applications/{APPLICATION_ID}/guilds/{GUILD_ID}/commands")
3199 );
3200 }
3201
3202 #[test]
3203 fn create_guild_from_template() {
3204 let route = Route::CreateGuildFromTemplate {
3205 template_code: TEMPLATE_CODE,
3206 };
3207 assert_eq!(
3208 route.to_string(),
3209 format!("guilds/templates/{TEMPLATE_CODE}")
3210 );
3211 }
3212
3213 #[test]
3214 fn get_template() {
3215 let route = Route::GetTemplate {
3216 template_code: TEMPLATE_CODE,
3217 };
3218 assert_eq!(
3219 route.to_string(),
3220 format!("guilds/templates/{TEMPLATE_CODE}")
3221 );
3222 }
3223
3224 #[test]
3225 fn create_guild_integration() {
3226 let route = Route::CreateGuildIntegration { guild_id: GUILD_ID };
3227 assert_eq!(route.to_string(), format!("guilds/{GUILD_ID}/integrations"));
3228 }
3229
3230 #[test]
3231 fn get_guild_integrations() {
3232 let route = Route::GetGuildIntegrations { guild_id: GUILD_ID };
3233 assert_eq!(route.to_string(), format!("guilds/{GUILD_ID}/integrations"));
3234 }
3235
3236 #[test]
3237 fn create_guild_sticker() {
3238 let route = Route::CreateGuildSticker { guild_id: GUILD_ID };
3239 assert_eq!(route.to_string(), format!("guilds/{GUILD_ID}/stickers"));
3240 }
3241
3242 #[test]
3243 fn get_guild_stickers() {
3244 let route = Route::GetGuildStickers { guild_id: GUILD_ID };
3245 assert_eq!(route.to_string(), format!("guilds/{GUILD_ID}/stickers"));
3246 }
3247
3248 #[test]
3249 fn create_invite() {
3250 let route = Route::CreateInvite {
3251 channel_id: CHANNEL_ID,
3252 };
3253 assert_eq!(route.to_string(), format!("channels/{CHANNEL_ID}/invites"));
3254 }
3255
3256 #[test]
3257 fn get_channel_invites() {
3258 let route = Route::GetChannelInvites {
3259 channel_id: CHANNEL_ID,
3260 };
3261 assert_eq!(route.to_string(), format!("channels/{CHANNEL_ID}/invites"));
3262 }
3263
3264 #[test]
3265 fn create_message() {
3266 let route = Route::CreateMessage {
3267 channel_id: CHANNEL_ID,
3268 };
3269 assert_eq!(route.to_string(), format!("channels/{CHANNEL_ID}/messages"));
3270 }
3271
3272 #[test]
3273 fn create_private_channel() {
3274 let route = Route::CreatePrivateChannel;
3275 assert_eq!(route.to_string(), "users/@me/channels");
3276 }
3277
3278 #[test]
3279 fn get_user_private_channels() {
3280 let route = Route::GetUserPrivateChannels;
3281 assert_eq!(route.to_string(), "users/@me/channels");
3282 }
3283
3284 #[test]
3285 fn create_reaction() {
3286 let emoji = emoji();
3287
3288 let route = Route::CreateReaction {
3289 channel_id: CHANNEL_ID,
3290 emoji: &emoji,
3291 message_id: MESSAGE_ID,
3292 };
3293 assert_eq!(
3294 route.to_string(),
3295 format!("channels/{CHANNEL_ID}/messages/{MESSAGE_ID}/reactions/{emoji}/@me")
3296 );
3297 }
3298
3299 #[test]
3300 fn delete_reaction_current_user() {
3301 let emoji = emoji();
3302
3303 let route = Route::DeleteReactionCurrentUser {
3304 channel_id: CHANNEL_ID,
3305 emoji: &emoji,
3306 message_id: MESSAGE_ID,
3307 };
3308 assert_eq!(
3309 route.to_string(),
3310 format!("channels/{CHANNEL_ID}/messages/{MESSAGE_ID}/reactions/{emoji}/@me")
3311 );
3312 }
3313
3314 #[test]
3315 fn create_role() {
3316 let route = Route::CreateRole { guild_id: GUILD_ID };
3317 assert_eq!(route.to_string(), format!("guilds/{GUILD_ID}/roles"));
3318 }
3319
3320 #[test]
3321 fn get_guild_roles() {
3322 let route = Route::GetGuildRoles { guild_id: GUILD_ID };
3323 assert_eq!(route.to_string(), format!("guilds/{GUILD_ID}/roles"));
3324 }
3325
3326 #[test]
3327 fn update_role_positions() {
3328 let route = Route::UpdateRolePositions { guild_id: GUILD_ID };
3329 assert_eq!(route.to_string(), format!("guilds/{GUILD_ID}/roles"));
3330 }
3331
3332 #[test]
3333 fn create_stage_instance() {
3334 let route = Route::CreateStageInstance;
3335 assert_eq!(route.to_string(), "stage-instances");
3336 }
3337
3338 #[test]
3339 fn create_template() {
3340 let route = Route::CreateTemplate { guild_id: GUILD_ID };
3341 assert_eq!(route.to_string(), format!("guilds/{GUILD_ID}/templates"));
3342 }
3343
3344 #[test]
3345 fn get_templates() {
3346 let route = Route::GetTemplates { guild_id: GUILD_ID };
3347 assert_eq!(route.to_string(), format!("guilds/{GUILD_ID}/templates"));
3348 }
3349
3350 #[test]
3351 fn create_thread() {
3352 let route = Route::CreateThread {
3353 channel_id: CHANNEL_ID,
3354 };
3355 assert_eq!(route.to_string(), format!("channels/{CHANNEL_ID}/threads"));
3356 }
3357
3358 #[test]
3359 fn create_thread_from_message() {
3360 let route = Route::CreateThreadFromMessage {
3361 channel_id: CHANNEL_ID,
3362 message_id: MESSAGE_ID,
3363 };
3364 assert_eq!(
3365 route.to_string(),
3366 format!("channels/{CHANNEL_ID}/messages/{MESSAGE_ID}/threads")
3367 );
3368 }
3369
3370 #[test]
3371 fn create_typing_trigger() {
3372 let route = Route::CreateTypingTrigger {
3373 channel_id: CHANNEL_ID,
3374 };
3375 assert_eq!(route.to_string(), format!("channels/{CHANNEL_ID}/typing"));
3376 }
3377
3378 #[test]
3379 fn create_webhook() {
3380 let route = Route::CreateWebhook {
3381 channel_id: CHANNEL_ID,
3382 };
3383 assert_eq!(route.to_string(), format!("channels/{CHANNEL_ID}/webhooks"));
3384 }
3385
3386 #[test]
3387 fn get_channel_webhooks() {
3388 let route = Route::GetChannelWebhooks {
3389 channel_id: CHANNEL_ID,
3390 };
3391 assert_eq!(route.to_string(), format!("channels/{CHANNEL_ID}/webhooks"));
3392 }
3393
3394 #[test]
3395 fn crosspost_message() {
3396 let route = Route::CrosspostMessage {
3397 channel_id: CHANNEL_ID,
3398 message_id: MESSAGE_ID,
3399 };
3400 assert_eq!(
3401 route.to_string(),
3402 format!("channels/{CHANNEL_ID}/messages/{MESSAGE_ID}/crosspost")
3403 );
3404 }
3405
3406 #[test]
3407 fn delete_ban() {
3408 let route = Route::DeleteBan {
3409 guild_id: GUILD_ID,
3410 user_id: USER_ID,
3411 };
3412 assert_eq!(
3413 route.to_string(),
3414 format!("guilds/{GUILD_ID}/bans/{USER_ID}")
3415 );
3416 }
3417
3418 #[test]
3419 fn get_ban() {
3420 let route = Route::GetBan {
3421 guild_id: GUILD_ID,
3422 user_id: USER_ID,
3423 };
3424 assert_eq!(
3425 route.to_string(),
3426 format!("guilds/{GUILD_ID}/bans/{USER_ID}")
3427 );
3428 }
3429
3430 #[test]
3431 fn delete_channel() {
3432 let route = Route::DeleteChannel {
3433 channel_id: CHANNEL_ID,
3434 };
3435 assert_eq!(route.to_string(), format!("channels/{CHANNEL_ID}"));
3436 }
3437
3438 #[test]
3439 fn get_channel() {
3440 let route = Route::GetChannel {
3441 channel_id: CHANNEL_ID,
3442 };
3443 assert_eq!(route.to_string(), format!("channels/{CHANNEL_ID}"));
3444 }
3445
3446 #[test]
3447 fn update_channel() {
3448 let route = Route::UpdateChannel {
3449 channel_id: CHANNEL_ID,
3450 };
3451 assert_eq!(route.to_string(), format!("channels/{CHANNEL_ID}"));
3452 }
3453
3454 #[test]
3455 fn delete_emoji() {
3456 let route = Route::DeleteEmoji {
3457 emoji_id: EMOJI_ID,
3458 guild_id: GUILD_ID,
3459 };
3460 assert_eq!(
3461 route.to_string(),
3462 format!("guilds/{GUILD_ID}/emojis/{EMOJI_ID}")
3463 );
3464 }
3465
3466 #[test]
3467 fn get_emoji() {
3468 let route = Route::GetEmoji {
3469 emoji_id: EMOJI_ID,
3470 guild_id: GUILD_ID,
3471 };
3472 assert_eq!(
3473 route.to_string(),
3474 format!("guilds/{GUILD_ID}/emojis/{EMOJI_ID}")
3475 );
3476 }
3477
3478 #[test]
3479 fn update_emoji() {
3480 let route = Route::UpdateEmoji {
3481 emoji_id: EMOJI_ID,
3482 guild_id: GUILD_ID,
3483 };
3484 assert_eq!(
3485 route.to_string(),
3486 format!("guilds/{GUILD_ID}/emojis/{EMOJI_ID}")
3487 );
3488 }
3489
3490 #[test]
3491 fn delete_global_command() {
3492 let route = Route::DeleteGlobalCommand {
3493 application_id: APPLICATION_ID,
3494 command_id: COMMAND_ID,
3495 };
3496 assert_eq!(
3497 route.to_string(),
3498 format!("applications/{APPLICATION_ID}/commands/{COMMAND_ID}")
3499 );
3500 }
3501
3502 #[test]
3503 fn get_global_command() {
3504 let route = Route::GetGlobalCommand {
3505 application_id: APPLICATION_ID,
3506 command_id: COMMAND_ID,
3507 };
3508 assert_eq!(
3509 route.to_string(),
3510 format!("applications/{APPLICATION_ID}/commands/{COMMAND_ID}")
3511 );
3512 }
3513
3514 #[test]
3515 fn update_global_command() {
3516 let route = Route::UpdateGlobalCommand {
3517 application_id: APPLICATION_ID,
3518 command_id: COMMAND_ID,
3519 };
3520 assert_eq!(
3521 route.to_string(),
3522 format!("applications/{APPLICATION_ID}/commands/{COMMAND_ID}")
3523 );
3524 }
3525
3526 #[test]
3527 fn delete_guild() {
3528 let route = Route::DeleteGuild { guild_id: GUILD_ID };
3529 assert_eq!(route.to_string(), format!("guilds/{GUILD_ID}"));
3530 }
3531
3532 #[test]
3533 fn update_guild() {
3534 let route = Route::UpdateGuild { guild_id: GUILD_ID };
3535 assert_eq!(route.to_string(), format!("guilds/{GUILD_ID}"));
3536 }
3537
3538 #[test]
3539 fn delete_guild_command() {
3540 let route = Route::DeleteGuildCommand {
3541 application_id: APPLICATION_ID,
3542 command_id: COMMAND_ID,
3543 guild_id: GUILD_ID,
3544 };
3545 assert_eq!(
3546 route.to_string(),
3547 format!("applications/{APPLICATION_ID}/guilds/{GUILD_ID}/commands/{COMMAND_ID}")
3548 );
3549 }
3550
3551 #[test]
3552 fn get_guild_command() {
3553 let route = Route::GetGuildCommand {
3554 application_id: APPLICATION_ID,
3555 command_id: COMMAND_ID,
3556 guild_id: GUILD_ID,
3557 };
3558 assert_eq!(
3559 route.to_string(),
3560 format!("applications/{APPLICATION_ID}/guilds/{GUILD_ID}/commands/{COMMAND_ID}")
3561 );
3562 }
3563
3564 #[test]
3565 fn update_guild_command() {
3566 let route = Route::UpdateGuildCommand {
3567 application_id: APPLICATION_ID,
3568 command_id: COMMAND_ID,
3569 guild_id: GUILD_ID,
3570 };
3571 assert_eq!(
3572 route.to_string(),
3573 format!("applications/{APPLICATION_ID}/guilds/{GUILD_ID}/commands/{COMMAND_ID}")
3574 );
3575 }
3576
3577 #[test]
3578 fn delete_guild_integration() {
3579 let route = Route::DeleteGuildIntegration {
3580 guild_id: GUILD_ID,
3581 integration_id: INTEGRATION_ID,
3582 };
3583 assert_eq!(
3584 route.to_string(),
3585 format!("guilds/{GUILD_ID}/integrations/{INTEGRATION_ID}")
3586 );
3587 }
3588
3589 #[test]
3590 fn update_guild_integration() {
3591 let route = Route::UpdateGuildIntegration {
3592 guild_id: GUILD_ID,
3593 integration_id: INTEGRATION_ID,
3594 };
3595 assert_eq!(
3596 route.to_string(),
3597 format!("guilds/{GUILD_ID}/integrations/{INTEGRATION_ID}")
3598 );
3599 }
3600
3601 #[test]
3602 fn delete_interaction_original() {
3603 let route = Route::DeleteInteractionOriginal {
3604 application_id: APPLICATION_ID,
3605 interaction_token: INTERACTION_TOKEN,
3606 };
3607 assert_eq!(
3608 route.to_string(),
3609 format!("webhooks/{APPLICATION_ID}/{INTERACTION_TOKEN}/messages/@original")
3610 );
3611 }
3612
3613 #[test]
3614 fn get_interaction_original() {
3615 let route = Route::GetInteractionOriginal {
3616 application_id: APPLICATION_ID,
3617 interaction_token: INTERACTION_TOKEN,
3618 };
3619 assert_eq!(
3620 route.to_string(),
3621 format!("webhooks/{APPLICATION_ID}/{INTERACTION_TOKEN}/messages/@original")
3622 );
3623 }
3624
3625 #[test]
3626 fn update_interaction_original() {
3627 let route = Route::UpdateInteractionOriginal {
3628 application_id: APPLICATION_ID,
3629 interaction_token: INTERACTION_TOKEN,
3630 };
3631 assert_eq!(
3632 route.to_string(),
3633 format!("webhooks/{APPLICATION_ID}/{INTERACTION_TOKEN}/messages/@original")
3634 );
3635 }
3636
3637 #[test]
3638 fn delete_invite() {
3639 let route = Route::DeleteInvite { code: CODE };
3640 assert_eq!(route.to_string(), format!("invites/{CODE}"));
3641 }
3642
3643 #[test]
3644 fn delete_message_reactions() {
3645 let route = Route::DeleteMessageReactions {
3646 channel_id: CHANNEL_ID,
3647 message_id: MESSAGE_ID,
3648 };
3649 assert_eq!(
3650 route.to_string(),
3651 format!("channels/{CHANNEL_ID}/messages/{MESSAGE_ID}/reactions")
3652 );
3653 }
3654
3655 #[test]
3656 fn delete_message_specific_reaction() {
3657 let emoji = emoji();
3658
3659 let route = Route::DeleteMessageSpecificReaction {
3660 channel_id: CHANNEL_ID,
3661 message_id: MESSAGE_ID,
3662 emoji: &emoji,
3663 };
3664 assert_eq!(
3665 route.to_string(),
3666 format!("channels/{CHANNEL_ID}/messages/{MESSAGE_ID}/reactions/{emoji}")
3667 );
3668 }
3669
3670 #[test]
3671 fn delete_message() {
3672 let route = Route::DeleteMessage {
3673 channel_id: CHANNEL_ID,
3674 message_id: MESSAGE_ID,
3675 };
3676 assert_eq!(
3677 route.to_string(),
3678 format!("channels/{CHANNEL_ID}/messages/{MESSAGE_ID}")
3679 );
3680 }
3681
3682 #[test]
3683 fn get_message() {
3684 let route = Route::GetMessage {
3685 channel_id: CHANNEL_ID,
3686 message_id: MESSAGE_ID,
3687 };
3688 assert_eq!(
3689 route.to_string(),
3690 format!("channels/{CHANNEL_ID}/messages/{MESSAGE_ID}")
3691 );
3692 }
3693
3694 #[test]
3695 fn update_message() {
3696 let route = Route::UpdateMessage {
3697 channel_id: CHANNEL_ID,
3698 message_id: MESSAGE_ID,
3699 };
3700 assert_eq!(
3701 route.to_string(),
3702 format!("channels/{CHANNEL_ID}/messages/{MESSAGE_ID}")
3703 );
3704 }
3705
3706 #[test]
3707 fn delete_messages() {
3708 let route = Route::DeleteMessages {
3709 channel_id: CHANNEL_ID,
3710 };
3711 assert_eq!(
3712 route.to_string(),
3713 format!("channels/{CHANNEL_ID}/messages/bulk-delete")
3714 );
3715 }
3716
3717 #[test]
3718 fn delete_permission_overwrite() {
3719 let route = Route::DeletePermissionOverwrite {
3720 channel_id: CHANNEL_ID,
3721 target_id: ROLE_ID,
3722 };
3723 assert_eq!(
3724 route.to_string(),
3725 format!("channels/{CHANNEL_ID}/permissions/{ROLE_ID}")
3726 );
3727 }
3728
3729 #[test]
3730 fn update_permission_overwrite() {
3731 let route = Route::UpdatePermissionOverwrite {
3732 channel_id: CHANNEL_ID,
3733 target_id: USER_ID,
3734 };
3735 assert_eq!(
3736 route.to_string(),
3737 format!("channels/{CHANNEL_ID}/permissions/{USER_ID}")
3738 );
3739 }
3740
3741 #[test]
3742 fn delete_reaction() {
3743 let emoji = emoji();
3744
3745 let route = Route::DeleteReaction {
3746 channel_id: CHANNEL_ID,
3747 emoji: &emoji,
3748 message_id: MESSAGE_ID,
3749 user_id: USER_ID,
3750 };
3751 assert_eq!(
3752 route.to_string(),
3753 format!("channels/{CHANNEL_ID}/messages/{MESSAGE_ID}/reactions/{emoji}/{USER_ID}")
3754 );
3755 }
3756
3757 #[test]
3758 fn delete_role() {
3759 let route = Route::DeleteRole {
3760 guild_id: GUILD_ID,
3761 role_id: ROLE_ID,
3762 };
3763 assert_eq!(
3764 route.to_string(),
3765 format!("guilds/{GUILD_ID}/roles/{ROLE_ID}")
3766 );
3767 }
3768
3769 #[test]
3770 fn update_role() {
3771 let route = Route::UpdateRole {
3772 guild_id: GUILD_ID,
3773 role_id: ROLE_ID,
3774 };
3775 assert_eq!(
3776 route.to_string(),
3777 format!("guilds/{GUILD_ID}/roles/{ROLE_ID}")
3778 );
3779 }
3780
3781 #[test]
3782 fn delete_stage_instance() {
3783 let route = Route::DeleteStageInstance {
3784 channel_id: CHANNEL_ID,
3785 };
3786 assert_eq!(route.to_string(), format!("stage-instances/{CHANNEL_ID}"));
3787 }
3788
3789 #[test]
3790 fn get_stage_instance() {
3791 let route = Route::GetStageInstance {
3792 channel_id: CHANNEL_ID,
3793 };
3794 assert_eq!(route.to_string(), format!("stage-instances/{CHANNEL_ID}"));
3795 }
3796
3797 #[test]
3798 fn update_stage_instance() {
3799 let route = Route::UpdateStageInstance {
3800 channel_id: CHANNEL_ID,
3801 };
3802 assert_eq!(route.to_string(), format!("stage-instances/{CHANNEL_ID}"));
3803 }
3804
3805 #[test]
3806 fn delete_template() {
3807 let route = Route::DeleteTemplate {
3808 guild_id: GUILD_ID,
3809 template_code: TEMPLATE_CODE,
3810 };
3811 assert_eq!(
3812 route.to_string(),
3813 format!("guilds/{GUILD_ID}/templates/{TEMPLATE_CODE}")
3814 );
3815 }
3816
3817 #[test]
3818 fn sync_template() {
3819 let route = Route::SyncTemplate {
3820 guild_id: GUILD_ID,
3821 template_code: TEMPLATE_CODE,
3822 };
3823 assert_eq!(
3824 route.to_string(),
3825 format!("guilds/{GUILD_ID}/templates/{TEMPLATE_CODE}")
3826 );
3827 }
3828
3829 #[test]
3830 fn update_template() {
3831 let route = Route::UpdateTemplate {
3832 guild_id: GUILD_ID,
3833 template_code: TEMPLATE_CODE,
3834 };
3835 assert_eq!(
3836 route.to_string(),
3837 format!("guilds/{GUILD_ID}/templates/{TEMPLATE_CODE}")
3838 );
3839 }
3840
3841 #[test]
3842 fn follow_news_channel() {
3843 let route = Route::FollowNewsChannel {
3844 channel_id: CHANNEL_ID,
3845 };
3846 assert_eq!(
3847 route.to_string(),
3848 format!("channels/{CHANNEL_ID}/followers")
3849 );
3850 }
3851
3852 #[test]
3853 fn get_active_threads() {
3854 let route = Route::GetActiveThreads { guild_id: GUILD_ID };
3855 assert_eq!(
3856 route.to_string(),
3857 format!("guilds/{GUILD_ID}/threads/active")
3858 );
3859 }
3860
3861 #[test]
3862 fn get_bans() {
3863 let route = Route::GetBans { guild_id: GUILD_ID };
3864 assert_eq!(route.to_string(), format!("guilds/{GUILD_ID}/bans"));
3865 }
3866
3867 #[test]
3868 fn get_bans_with_parameters() {
3869 let route = Route::GetBansWithParameters {
3870 after: None,
3871 before: None,
3872 guild_id: GUILD_ID,
3873 limit: None,
3874 };
3875 assert_eq!(route.to_string(), format!("guilds/{GUILD_ID}/bans"));
3876
3877 let route = Route::GetBansWithParameters {
3878 after: Some(USER_ID),
3879 before: None,
3880 guild_id: GUILD_ID,
3881 limit: None,
3882 };
3883 assert_eq!(
3884 route.to_string(),
3885 format!("guilds/{GUILD_ID}/bans?after={USER_ID}")
3886 );
3887
3888 let route = Route::GetBansWithParameters {
3889 after: None,
3890 before: Some(USER_ID),
3891 guild_id: GUILD_ID,
3892 limit: None,
3893 };
3894 assert_eq!(
3895 route.to_string(),
3896 format!("guilds/{GUILD_ID}/bans?before={USER_ID}")
3897 );
3898
3899 let route = Route::GetBansWithParameters {
3900 after: None,
3901 before: None,
3902 guild_id: GUILD_ID,
3903 limit: Some(100),
3904 };
3905 assert_eq!(
3906 route.to_string(),
3907 format!("guilds/{GUILD_ID}/bans?limit={limit}", limit = 100)
3908 );
3909
3910 let route = Route::GetBansWithParameters {
3911 after: Some(USER_ID),
3912 before: Some(USER_ID + 100),
3913 guild_id: GUILD_ID,
3914 limit: Some(25),
3915 };
3916 assert_eq!(
3917 route.to_string(),
3918 format!(
3919 "guilds/{GUILD_ID}/bans?after={USER_ID}&before={before}&limit={limit}",
3920 before = USER_ID + 100,
3921 limit = 25,
3922 )
3923 );
3924 }
3925
3926 #[test]
3927 fn get_gateway_bot() {
3928 let route = Route::GetGatewayBot;
3929 assert_eq!(route.to_string(), "gateway/bot");
3930 }
3931
3932 #[test]
3933 fn get_entitlements() {
3934 let route = Route::GetEntitlements {
3935 after: Some(32),
3936 application_id: 1,
3937 before: Some(2),
3938 exclude_deleted: Some(true),
3939 exclude_ended: Some(true),
3940 guild_id: Some(42),
3941 limit: Some(99),
3942 sku_ids: &[Id::new(7)],
3943 user_id: Some(11),
3944 };
3945
3946 assert_eq!(
3947 route.to_string(),
3948 "applications/1/entitlements?after=32&before=2&exclude_deleted=true&exclude_ended=true&guild_id=42&limit=99&sku_ids=7&user_id=11"
3949 );
3950 }
3951
3952 #[test]
3953 fn get_entitlement() {
3954 let route = Route::GetEntitlement {
3955 application_id: APPLICATION_ID,
3956 entitlement_id: ENTITLEMENT_ID,
3957 };
3958 assert_eq!(
3959 route.to_string(),
3960 format!("applications/{APPLICATION_ID}/entitlements/{ENTITLEMENT_ID}")
3961 );
3962 assert_eq!(Method::Get, route.method());
3963 }
3964
3965 #[test]
3966 fn create_test_entitlement() {
3967 let route = Route::CreateTestEntitlement { application_id: 1 };
3968
3969 assert_eq!(route.to_string(), "applications/1/entitlements");
3970 }
3971
3972 #[test]
3973 fn get_command_permissions() {
3974 let route = Route::GetCommandPermissions {
3975 application_id: APPLICATION_ID,
3976 command_id: COMMAND_ID,
3977 guild_id: GUILD_ID,
3978 };
3979 assert_eq!(
3980 route.to_string(),
3981 format!(
3982 "applications/{APPLICATION_ID}/guilds/{GUILD_ID}/commands/{COMMAND_ID}/permissions"
3983 )
3984 );
3985 }
3986
3987 #[test]
3988 fn update_command_permissions() {
3989 let route = Route::UpdateCommandPermissions {
3990 application_id: APPLICATION_ID,
3991 command_id: COMMAND_ID,
3992 guild_id: GUILD_ID,
3993 };
3994 assert_eq!(
3995 route.to_string(),
3996 format!(
3997 "applications/{APPLICATION_ID}/guilds/{GUILD_ID}/commands/{COMMAND_ID}/permissions"
3998 )
3999 );
4000 }
4001
4002 #[test]
4003 fn get_current_authorization_info() {
4004 let route = Route::GetCurrentAuthorizationInformation;
4005 assert_eq!(route.to_string(), "oauth2/@me");
4006 }
4007
4008 #[test]
4009 fn get_current_user_application_info() {
4010 let route = Route::GetCurrentUserApplicationInfo;
4011 assert_eq!(route.to_string(), "applications/@me");
4012 }
4013
4014 #[test]
4015 fn update_current_user_application() {
4016 let route = Route::UpdateCurrentUserApplication;
4017 assert_eq!(route.to_string(), "applications/@me");
4018 }
4019
4020 #[test]
4021 fn get_current_user() {
4022 let route = Route::GetCurrentUser;
4023 assert_eq!(route.to_string(), "users/@me");
4024 }
4025
4026 #[test]
4027 fn get_current_user_guild_member() {
4028 let route = Route::GetCurrentUserGuildMember { guild_id: GUILD_ID };
4029 assert_eq!(
4030 route.to_string(),
4031 format!("users/@me/guilds/{GUILD_ID}/member")
4032 );
4033 }
4034
4035 #[test]
4036 fn update_current_user() {
4037 let route = Route::UpdateCurrentUser;
4038 assert_eq!(route.to_string(), "users/@me");
4039 }
4040
4041 #[test]
4042 fn get_gateway() {
4043 let route = Route::GetGateway;
4044 assert_eq!(route.to_string(), "gateway");
4045 }
4046
4047 #[test]
4048 fn get_guild_command_permissions() {
4049 let route = Route::GetGuildCommandPermissions {
4050 application_id: APPLICATION_ID,
4051 guild_id: GUILD_ID,
4052 };
4053 assert_eq!(
4054 route.to_string(),
4055 format!("applications/{APPLICATION_ID}/guilds/{GUILD_ID}/commands/permissions")
4056 );
4057 }
4058
4059 #[test]
4060 fn get_guild_invites() {
4061 let route = Route::GetGuildInvites { guild_id: GUILD_ID };
4062 assert_eq!(route.to_string(), format!("guilds/{GUILD_ID}/invites"));
4063 }
4064
4065 #[test]
4066 fn get_guild_preview() {
4067 let route = Route::GetGuildPreview { guild_id: GUILD_ID };
4068 assert_eq!(route.to_string(), format!("guilds/{GUILD_ID}/preview"));
4069 }
4070
4071 #[test]
4072 fn get_guild_sticker() {
4073 let route = Route::GetGuildSticker {
4074 guild_id: GUILD_ID,
4075 sticker_id: STICKER_ID,
4076 };
4077 assert_eq!(
4078 route.to_string(),
4079 format!("guilds/{GUILD_ID}/stickers/{STICKER_ID}")
4080 );
4081 }
4082
4083 #[test]
4084 fn delete_guild_sticker() {
4085 let route = Route::DeleteGuildSticker {
4086 guild_id: GUILD_ID,
4087 sticker_id: STICKER_ID,
4088 };
4089 assert_eq!(
4090 route.to_string(),
4091 format!("guilds/{GUILD_ID}/stickers/{STICKER_ID}")
4092 );
4093 }
4094
4095 #[test]
4096 fn update_guild_sticker() {
4097 let route = Route::UpdateGuildSticker {
4098 guild_id: GUILD_ID,
4099 sticker_id: STICKER_ID,
4100 };
4101 assert_eq!(
4102 route.to_string(),
4103 format!("guilds/{GUILD_ID}/stickers/{STICKER_ID}")
4104 );
4105 }
4106
4107 #[test]
4108 fn get_guild_vanity_url() {
4109 let route = Route::GetGuildVanityUrl { guild_id: GUILD_ID };
4110 assert_eq!(route.to_string(), format!("guilds/{GUILD_ID}/vanity-url"));
4111 }
4112
4113 #[test]
4114 fn get_guild_voice_regions() {
4115 let route = Route::GetGuildVoiceRegions { guild_id: GUILD_ID };
4116 assert_eq!(route.to_string(), format!("guilds/{GUILD_ID}/regions"));
4117 }
4118
4119 #[test]
4120 fn get_guild_welcome_screen() {
4121 let route = Route::GetGuildWelcomeScreen { guild_id: GUILD_ID };
4122 assert_eq!(
4123 route.to_string(),
4124 format!("guilds/{GUILD_ID}/welcome-screen")
4125 );
4126 }
4127
4128 #[test]
4129 fn update_guild_welcome_screen() {
4130 let route = Route::UpdateGuildWelcomeScreen { guild_id: GUILD_ID };
4131 assert_eq!(
4132 route.to_string(),
4133 format!("guilds/{GUILD_ID}/welcome-screen")
4134 );
4135 }
4136
4137 #[test]
4138 fn get_guild_webhooks() {
4139 let route = Route::GetGuildWebhooks { guild_id: GUILD_ID };
4140 assert_eq!(route.to_string(), format!("guilds/{GUILD_ID}/webhooks"));
4141 }
4142
4143 #[test]
4144 fn get_guild_widget() {
4145 let route = Route::GetGuildWidget { guild_id: GUILD_ID };
4146 assert_eq!(route.to_string(), format!("guilds/{GUILD_ID}/widget.json"));
4147 }
4148
4149 #[test]
4150 fn get_guild_widget_settings() {
4151 let route = Route::GetGuildWidgetSettings { guild_id: GUILD_ID };
4152 assert_eq!(route.to_string(), format!("guilds/{GUILD_ID}/widget"));
4153 }
4154
4155 #[test]
4156 fn update_guild_widget_settings() {
4157 let route = Route::UpdateGuildWidgetSettings { guild_id: GUILD_ID };
4158 assert_eq!(route.to_string(), format!("guilds/{GUILD_ID}/widget"));
4159 }
4160
4161 #[test]
4162 fn get_nitro_sticker_packs() {
4163 let route = Route::GetNitroStickerPacks;
4164
4165 assert_eq!(route.to_string(), "sticker-packs");
4166 }
4167
4168 #[test]
4169 fn get_pins() {
4170 let route = Route::GetPins {
4171 channel_id: CHANNEL_ID,
4172 limit: None,
4173 before: None,
4174 };
4175 assert_eq!(
4176 route.to_string(),
4177 format!("channels/{CHANNEL_ID}/messages/pins")
4178 );
4179 }
4180
4181 #[test]
4182 fn get_sticker_pack() {
4183 let route = Route::GetStickerPack {
4184 sticker_pack_id: STICKER_PACK_ID,
4185 };
4186 assert_eq!(Method::Get, route.method());
4187 assert_eq!(
4188 route.to_string(),
4189 format!("sticker-packs/{STICKER_PACK_ID}")
4190 );
4191 }
4192
4193 #[test]
4194 fn get_sticker() {
4195 let route = Route::GetSticker {
4196 sticker_id: STICKER_ID,
4197 };
4198 assert_eq!(route.to_string(), format!("stickers/{STICKER_ID}"));
4199 }
4200
4201 #[test]
4202 fn get_thread_members() {
4203 let route = Route::GetThreadMembers {
4204 after: None,
4205 channel_id: CHANNEL_ID,
4206 limit: None,
4207 with_member: None,
4208 };
4209 assert_eq!(
4210 route.to_string(),
4211 format!("channels/{CHANNEL_ID}/thread-members")
4212 );
4213
4214 let route = Route::GetThreadMembers {
4215 after: Some(USER_ID),
4216 channel_id: CHANNEL_ID,
4217 limit: Some(1),
4218 with_member: Some(true),
4219 };
4220
4221 assert_eq!(
4222 route.to_string(),
4223 format!(
4224 "channels/{CHANNEL_ID}/thread-members?after={USER_ID}&limit=1&with_member=true"
4225 )
4226 );
4227 }
4228
4229 #[test]
4230 fn get_user_connections() {
4231 let route = Route::GetUserConnections;
4232 assert_eq!(route.to_string(), "users/@me/connections");
4233 }
4234
4235 #[test]
4236 fn get_user() {
4237 let route = Route::GetUser { user_id: USER_ID };
4238 assert_eq!(route.to_string(), format!("users/{USER_ID}"));
4239 }
4240
4241 #[test]
4242 fn get_voice_regions() {
4243 let route = Route::GetVoiceRegions;
4244 assert_eq!(route.to_string(), "voice/regions");
4245 }
4246
4247 #[test]
4248 fn interaction_callback() {
4249 let route = Route::InteractionCallback {
4250 interaction_id: INTERACTION_ID,
4251 interaction_token: INTERACTION_TOKEN,
4252 with_response: true,
4253 };
4254 assert_eq!(
4255 route.to_string(),
4256 format!(
4257 "interactions/{INTERACTION_ID}/{INTERACTION_TOKEN}/callback?with_response=true"
4258 )
4259 );
4260 }
4261
4262 #[test]
4263 fn join_thread() {
4264 let route = Route::JoinThread {
4265 channel_id: CHANNEL_ID,
4266 };
4267 assert_eq!(
4268 route.to_string(),
4269 format!("channels/{CHANNEL_ID}/thread-members/@me")
4270 );
4271 }
4272
4273 #[test]
4274 fn leave_thread() {
4275 let route = Route::LeaveThread {
4276 channel_id: CHANNEL_ID,
4277 };
4278 assert_eq!(
4279 route.to_string(),
4280 format!("channels/{CHANNEL_ID}/thread-members/@me")
4281 );
4282 }
4283
4284 #[test]
4285 fn leave_guild() {
4286 let route = Route::LeaveGuild { guild_id: GUILD_ID };
4287 assert_eq!(route.to_string(), format!("users/@me/guilds/{GUILD_ID}"));
4288 }
4289
4290 #[test]
4291 fn pin_message() {
4292 let route = Route::PinMessage {
4293 channel_id: CHANNEL_ID,
4294 message_id: MESSAGE_ID,
4295 };
4296 assert_eq!(
4297 route.to_string(),
4298 format!("channels/{CHANNEL_ID}/messages/pins/{MESSAGE_ID}")
4299 );
4300 }
4301
4302 #[test]
4303 fn unpin_message() {
4304 let route = Route::UnpinMessage {
4305 channel_id: CHANNEL_ID,
4306 message_id: MESSAGE_ID,
4307 };
4308 assert_eq!(
4309 route.to_string(),
4310 format!("channels/{CHANNEL_ID}/messages/pins/{MESSAGE_ID}")
4311 );
4312 }
4313
4314 #[test]
4315 fn sync_guild_integration() {
4316 let route = Route::SyncGuildIntegration {
4317 guild_id: GUILD_ID,
4318 integration_id: INTEGRATION_ID,
4319 };
4320 assert_eq!(
4321 route.to_string(),
4322 format!("guilds/{GUILD_ID}/integrations/{INTEGRATION_ID}/sync")
4323 );
4324 }
4325
4326 #[test]
4327 fn update_current_member() {
4328 let route = Route::UpdateCurrentMember { guild_id: GUILD_ID };
4329 assert_eq!(route.to_string(), format!("guilds/{GUILD_ID}/members/@me"));
4330 }
4331
4332 #[test]
4333 fn get_current_user_voice_state() {
4334 let route = Route::GetCurrentUserVoiceState { guild_id: GUILD_ID };
4335 assert_eq!(
4336 route.to_string(),
4337 format!("guilds/{GUILD_ID}/voice-states/@me")
4338 );
4339 }
4340
4341 #[test]
4342 fn update_current_user_voice_state() {
4343 let route = Route::UpdateCurrentUserVoiceState { guild_id: GUILD_ID };
4344 assert_eq!(
4345 route.to_string(),
4346 format!("guilds/{GUILD_ID}/voice-states/@me")
4347 );
4348 }
4349
4350 #[test]
4351 fn update_nickname() {
4352 let route = Route::UpdateNickname { guild_id: GUILD_ID };
4353 assert_eq!(
4354 route.to_string(),
4355 format!("guilds/{GUILD_ID}/members/@me/nick")
4356 );
4357 }
4358
4359 #[test]
4360 fn get_user_voice_state() {
4361 let route = Route::GetUserVoiceState {
4362 guild_id: GUILD_ID,
4363 user_id: USER_ID,
4364 };
4365 assert_eq!(
4366 route.to_string(),
4367 format!("guilds/{GUILD_ID}/voice-states/{USER_ID}")
4368 );
4369 }
4370
4371 #[test]
4372 fn update_user_voice_state() {
4373 let route = Route::UpdateUserVoiceState {
4374 guild_id: GUILD_ID,
4375 user_id: USER_ID,
4376 };
4377 assert_eq!(
4378 route.to_string(),
4379 format!("guilds/{GUILD_ID}/voice-states/{USER_ID}")
4380 );
4381 }
4382
4383 #[test]
4384 fn create_ban() {
4385 let mut route = Route::CreateBan {
4386 guild_id: GUILD_ID,
4387 user_id: USER_ID,
4388 };
4389 assert_eq!(
4390 route.to_string(),
4391 format!("guilds/{GUILD_ID}/bans/{USER_ID}")
4392 );
4393
4394 route = Route::CreateBan {
4395 guild_id: GUILD_ID,
4396 user_id: USER_ID,
4397 };
4398 assert_eq!(
4399 route.to_string(),
4400 format!("guilds/{GUILD_ID}/bans/{USER_ID}")
4401 );
4402 }
4403
4404 #[test]
4405 fn create_guild_prune_none() {
4406 let route = Route::CreateGuildPrune {
4407 compute_prune_count: None,
4408 days: None,
4409 guild_id: GUILD_ID,
4410 include_roles: &[],
4411 };
4412 assert_eq!(route.to_string(), format!("guilds/{GUILD_ID}/prune"));
4413 }
4414
4415 #[test]
4416 fn create_guild_prune_compute_prune_count_true() {
4417 let route = Route::CreateGuildPrune {
4418 compute_prune_count: Some(true),
4419 days: None,
4420 guild_id: GUILD_ID,
4421 include_roles: &[],
4422 };
4423 assert_eq!(
4424 route.to_string(),
4425 format!("guilds/{GUILD_ID}/prune?compute_prune_count=true")
4426 );
4427 }
4428
4429 #[test]
4430 fn create_guild_prune_compute_prune_count_false() {
4431 let route = Route::CreateGuildPrune {
4432 compute_prune_count: Some(false),
4433 days: None,
4434 guild_id: GUILD_ID,
4435 include_roles: &[],
4436 };
4437 assert_eq!(
4438 route.to_string(),
4439 format!("guilds/{GUILD_ID}/prune?compute_prune_count=false")
4440 );
4441 }
4442
4443 #[test]
4444 fn create_guild_prune_days() {
4445 let route = Route::CreateGuildPrune {
4446 compute_prune_count: None,
4447 days: Some(4),
4448 guild_id: GUILD_ID,
4449 include_roles: &[],
4450 };
4451 assert_eq!(route.to_string(), format!("guilds/{GUILD_ID}/prune?days=4"));
4452 }
4453
4454 #[test]
4455 fn create_guild_prune_include_one_role() {
4456 let include_roles = [Id::new(1)];
4457
4458 let route = Route::CreateGuildPrune {
4459 compute_prune_count: None,
4460 days: None,
4461 guild_id: GUILD_ID,
4462 include_roles: &include_roles,
4463 };
4464 assert_eq!(
4465 route.to_string(),
4466 format!("guilds/{GUILD_ID}/prune?include_roles=1")
4467 );
4468 }
4469
4470 #[test]
4471 fn create_guild_prune_include_two_roles() {
4472 let include_roles = [Id::new(1), Id::new(2)];
4473
4474 let route = Route::CreateGuildPrune {
4475 compute_prune_count: None,
4476 days: None,
4477 guild_id: GUILD_ID,
4478 include_roles: &include_roles,
4479 };
4480 assert_eq!(
4481 route.to_string(),
4482 format!("guilds/{GUILD_ID}/prune?include_roles=1,2")
4483 );
4484 }
4485
4486 #[test]
4487 fn create_guild_prune_all() {
4488 let include_roles = [Id::new(1), Id::new(2)];
4489
4490 let route = Route::CreateGuildPrune {
4491 compute_prune_count: Some(true),
4492 days: Some(4),
4493 guild_id: GUILD_ID,
4494 include_roles: &include_roles,
4495 };
4496 assert_eq!(
4497 route.to_string(),
4498 format!("guilds/{GUILD_ID}/prune?compute_prune_count=true&days=4&include_roles=1,2")
4499 );
4500 }
4501
4502 #[test]
4503 fn get_guild_scheduled_events() {
4504 let route = Route::GetGuildScheduledEvents {
4505 guild_id: GUILD_ID,
4506 with_user_count: false,
4507 };
4508
4509 assert_eq!(
4510 route.to_string(),
4511 format!("guilds/{GUILD_ID}/scheduled-events")
4512 );
4513
4514 let route = Route::GetGuildScheduledEvents {
4515 guild_id: GUILD_ID,
4516 with_user_count: true,
4517 };
4518
4519 assert_eq!(
4520 route.to_string(),
4521 format!("guilds/{GUILD_ID}/scheduled-events?with_user_count=true")
4522 );
4523 }
4524
4525 #[test]
4526 fn create_guild_scheduled_event() {
4527 let route = Route::CreateGuildScheduledEvent { guild_id: GUILD_ID };
4528
4529 assert_eq!(
4530 route.to_string(),
4531 format!("guilds/{GUILD_ID}/scheduled-events")
4532 );
4533 }
4534
4535 #[test]
4536 fn get_guild_scheduled_event() {
4537 let route = Route::GetGuildScheduledEvent {
4538 guild_id: GUILD_ID,
4539 scheduled_event_id: SCHEDULED_EVENT_ID,
4540 with_user_count: false,
4541 };
4542
4543 assert_eq!(
4544 route.to_string(),
4545 format!("guilds/{GUILD_ID}/scheduled-events/{SCHEDULED_EVENT_ID}")
4546 );
4547
4548 let route = Route::GetGuildScheduledEvent {
4549 guild_id: GUILD_ID,
4550 scheduled_event_id: SCHEDULED_EVENT_ID,
4551 with_user_count: true,
4552 };
4553
4554 assert_eq!(
4555 route.to_string(),
4556 format!("guilds/{GUILD_ID}/scheduled-events/{SCHEDULED_EVENT_ID}?with_user_count=true")
4557 );
4558 }
4559
4560 #[test]
4561 fn update_guild_scheduled_event() {
4562 let route = Route::UpdateGuildScheduledEvent {
4563 guild_id: GUILD_ID,
4564 scheduled_event_id: SCHEDULED_EVENT_ID,
4565 };
4566
4567 assert_eq!(
4568 route.to_string(),
4569 format!("guilds/{GUILD_ID}/scheduled-events/{SCHEDULED_EVENT_ID}")
4570 );
4571 }
4572
4573 #[test]
4574 fn delete_guild_scheduled_event() {
4575 let route = Route::DeleteGuildScheduledEvent {
4576 guild_id: GUILD_ID,
4577 scheduled_event_id: SCHEDULED_EVENT_ID,
4578 };
4579
4580 assert_eq!(
4581 route.to_string(),
4582 format!("guilds/{GUILD_ID}/scheduled-events/{SCHEDULED_EVENT_ID}")
4583 );
4584 }
4585
4586 #[test]
4587 fn get_guild_scheduled_event_users() {
4588 let route = Route::GetGuildScheduledEventUsers {
4589 after: None,
4590 before: Some(USER_ID),
4591 guild_id: GUILD_ID,
4592 limit: None,
4593 scheduled_event_id: SCHEDULED_EVENT_ID,
4594 with_member: true,
4595 };
4596
4597 assert_eq!(
4598 route.to_string(),
4599 format!(
4600 "guilds/{GUILD_ID}/scheduled-events/{SCHEDULED_EVENT_ID}/users?before={USER_ID}&with_member=true"
4601 )
4602 );
4603
4604 let route = Route::GetGuildScheduledEventUsers {
4605 after: Some(USER_ID),
4606 before: None,
4607 guild_id: GUILD_ID,
4608 limit: Some(101),
4609 scheduled_event_id: SCHEDULED_EVENT_ID,
4610 with_member: false,
4611 };
4612
4613 assert_eq!(
4614 route.to_string(),
4615 format!(
4616 "guilds/{GUILD_ID}/scheduled-events/{SCHEDULED_EVENT_ID}/users?after={USER_ID}&limit=101"
4617 )
4618 );
4619
4620 let route = Route::GetGuildScheduledEventUsers {
4621 after: Some(USER_ID),
4622 before: Some(USER_ID),
4623 guild_id: GUILD_ID,
4624 limit: Some(99),
4625 scheduled_event_id: SCHEDULED_EVENT_ID,
4626 with_member: false,
4627 };
4628
4629 assert_eq!(
4630 route.to_string(),
4631 format!(
4632 "guilds/{GUILD_ID}/scheduled-events/{SCHEDULED_EVENT_ID}/users?after={USER_ID}&before={USER_ID}&limit=99"
4633 )
4634 );
4635 }
4636
4637 #[test]
4638 fn search_guild_members() {
4639 let route = Route::SearchGuildMembers {
4640 guild_id: GUILD_ID,
4641 limit: Some(99),
4642 query: "foo bar",
4643 };
4644
4645 assert_eq!(
4646 route.to_string(),
4647 format!("guilds/{GUILD_ID}/members/search?query=foo%20bar&limit=99")
4648 );
4649
4650 let route = Route::SearchGuildMembers {
4651 guild_id: GUILD_ID,
4652 limit: Some(99),
4653 query: "foo/bar",
4654 };
4655
4656 assert_eq!(
4657 route.to_string(),
4658 format!("guilds/{GUILD_ID}/members/search?query=foo%2Fbar&limit=99")
4659 );
4660 }
4661
4662 #[test]
4663 fn update_guild_mfa() {
4664 let route = Route::UpdateGuildMfa { guild_id: GUILD_ID };
4665 assert_eq!(route.to_string(), format!("guilds/{GUILD_ID}/mfa"));
4666 }
4667
4668 #[test]
4669 fn create_auto_moderation_rule() {
4670 let route = Route::CreateAutoModerationRule { guild_id: GUILD_ID };
4671 assert_eq!(
4672 route.to_string(),
4673 format!("guilds/{GUILD_ID}/auto-moderation/rules")
4674 );
4675 }
4676
4677 #[test]
4678 fn delete_auto_moderation_rule() {
4679 let route = Route::DeleteAutoModerationRule {
4680 guild_id: GUILD_ID,
4681 auto_moderation_rule_id: AUTO_MODERATION_RULE_ID,
4682 };
4683 assert_eq!(
4684 route.to_string(),
4685 format!("guilds/{GUILD_ID}/auto-moderation/rules/{AUTO_MODERATION_RULE_ID}")
4686 );
4687 }
4688
4689 #[test]
4690 fn get_auto_moderation_rule() {
4691 let route = Route::GetAutoModerationRule {
4692 guild_id: GUILD_ID,
4693 auto_moderation_rule_id: AUTO_MODERATION_RULE_ID,
4694 };
4695 assert_eq!(
4696 route.to_string(),
4697 format!("guilds/{GUILD_ID}/auto-moderation/rules/{AUTO_MODERATION_RULE_ID}")
4698 );
4699 }
4700
4701 #[test]
4702 fn get_guild_auto_moderation_rules() {
4703 let route = Route::GetGuildAutoModerationRules { guild_id: GUILD_ID };
4704 assert_eq!(
4705 route.to_string(),
4706 format!("guilds/{GUILD_ID}/auto-moderation/rules")
4707 );
4708 }
4709
4710 #[test]
4711 fn update_auto_moderation_rule() {
4712 let route = Route::UpdateAutoModerationRule {
4713 guild_id: GUILD_ID,
4714 auto_moderation_rule_id: AUTO_MODERATION_RULE_ID,
4715 };
4716 assert_eq!(
4717 route.to_string(),
4718 format!("guilds/{GUILD_ID}/auto-moderation/rules/{AUTO_MODERATION_RULE_ID}")
4719 );
4720 }
4721
4722 #[test]
4723 fn get_guild_onboarding() {
4724 let route = Route::GetGuildOnboarding { guild_id: GUILD_ID };
4725 assert_eq!(route.to_string(), format!("guilds/{GUILD_ID}/onboarding"));
4726 }
4727
4728 #[test]
4729 fn get_skus() {
4730 let route = Route::GetSKUs {
4731 application_id: APPLICATION_ID,
4732 };
4733 assert_eq!(
4734 route.to_string(),
4735 format!("applications/{APPLICATION_ID}/skus")
4736 );
4737 }
4738
4739 #[test]
4740 fn consume_entitlement() {
4741 let route = Route::ConsumeEntitlement {
4742 application_id: APPLICATION_ID,
4743 entitlement_id: ENTITLEMENT_ID,
4744 };
4745 assert_eq!(
4746 route.to_string(),
4747 format!("applications/{APPLICATION_ID}/entitlements/{ENTITLEMENT_ID}/consume")
4748 );
4749 assert_eq!(Method::Post, route.method());
4750 }
4751
4752 #[test]
4753 fn get_sku_subscriptions() {
4754 let route = Route::GetSKUSubscriptions {
4755 after: Some(18),
4756 before: Some(20),
4757 limit: Some(100),
4758 sku_id: SKU_ID,
4759 user_id: Some(USER_ID),
4760 };
4761 assert_eq!(
4762 route.to_string(),
4763 format!("skus/{SKU_ID}/subscriptions?after=18&before=20&limit=100&user_id={USER_ID}")
4764 );
4765 }
4766
4767 #[test]
4768 fn get_sku_subscription() {
4769 let route = Route::GetSKUSubscription {
4770 sku_id: SKU_ID,
4771 subscription_id: SUBSCRIPTION_ID,
4772 };
4773 assert_eq!(
4774 route.to_string(),
4775 format!("skus/{SKU_ID}/subscriptions/{SUBSCRIPTION_ID}")
4776 );
4777 }
4778}