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