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