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