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