diff --git a/src/http/client.rs b/src/http/client.rs index ba4b33bc5d5..7da8ed4e274 100644 --- a/src/http/client.rs +++ b/src/http/client.rs @@ -2767,16 +2767,23 @@ impl Http { /// /// let guild_id = GuildId(81384788765712384); /// - /// let guilds = http.get_guilds(&GuildPagination::After(guild_id), 10).await?; + /// let guilds = http.get_guilds(Some(&GuildPagination::After(guild_id)), Some(10)).await?; /// # Ok(()) /// # } /// ``` /// /// [docs]: https://discord.com/developers/docs/resources/user#get-current-user-guilds - pub async fn get_guilds(&self, target: &GuildPagination, limit: u64) -> Result> { - let (after, before) = match *target { - GuildPagination::After(id) => (Some(id.0), None), - GuildPagination::Before(id) => (None, Some(id.0)), + pub async fn get_guilds( + &self, + target: Option<&GuildPagination>, + limit: Option, + ) -> Result> { + let (after, before) = match target { + None => (None, None), + Some(gp) => match gp { + GuildPagination::After(id) => (Some(id.0), None), + GuildPagination::Before(id) => (None, Some(id.0)), + }, }; self.fire(Request { diff --git a/src/http/routing.rs b/src/http/routing.rs index 9a88bd1f1c3..d5b7dc17ac2 100644 --- a/src/http/routing.rs +++ b/src/http/routing.rs @@ -872,9 +872,14 @@ impl Route { target: D, after: Option, before: Option, - limit: u64, + limit: Option, ) -> String { - let mut s = format!(api!("/users/{}/guilds?limit={}&"), target, limit); + let mut s = format!(api!("/users/{}/guilds?"), target); + + if let Some(limit) = limit { + #[allow(clippy::let_underscore_must_use)] + let _ = write!(s, "&limit={}", limit); + } if let Some(after) = after { let _ = write!(s, "&after={}", after); @@ -1442,7 +1447,7 @@ pub enum RouteInfo<'a> { GetGuilds { after: Option, before: Option, - limit: u64, + limit: Option, }, GetInvite { code: &'a str, diff --git a/src/model/user.rs b/src/model/user.rs index 28649370422..28d152db7c7 100644 --- a/src/model/user.rs +++ b/src/model/user.rs @@ -199,8 +199,10 @@ impl CurrentUser { let mut pagination = http .as_ref() .get_guilds( - &GuildPagination::After(guilds.last().map_or(GuildId(1), |g: &GuildInfo| g.id)), - 100, + Some(&GuildPagination::After( + guilds.last().map_or(GuildId(1), |g: &GuildInfo| g.id), + )), + Some(100), ) .await?; let len = pagination.len();