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