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