diff options
Diffstat (limited to 'src/http')
| -rw-r--r-- | src/http/mod.rs | 19 | ||||
| -rw-r--r-- | src/http/ratelimiting.rs | 6 |
2 files changed, 25 insertions, 0 deletions
diff --git a/src/http/mod.rs b/src/http/mod.rs index 6b56abd..e40b3c6 100644 --- a/src/http/mod.rs +++ b/src/http/mod.rs @@ -1241,6 +1241,25 @@ pub fn get_guild_invites(guild_id: u64) -> Result<Vec<RichInvite>> { .map_err(From::from) } +/// Gets a guild's vanity URL if it has one. +pub fn get_guild_vanity_url(guild_id: u64) -> Result<String> { + #[derive(Deserialize)] + struct GuildVanityUrl { + code: String, + } + + let response = request!( + Route::GuildsIdVanityUrl(guild_id), + get, + "/guilds/{}/vanity-url", + guild_id + ); + + serde_json::from_reader::<HyperResponse, GuildVanityUrl>(response) + .map(|x| x.code) + .map_err(From::from) +} + /// Gets the members of a guild. Optionally pass a `limit` and the Id of the /// user to offset the result by. pub fn get_guild_members(guild_id: u64, diff --git a/src/http/ratelimiting.rs b/src/http/ratelimiting.rs index ca269e3..d46d196 100644 --- a/src/http/ratelimiting.rs +++ b/src/http/ratelimiting.rs @@ -316,6 +316,12 @@ pub enum Route { /// /// [`GuildId`]: struct.GuildId.html GuildsIdRolesId(u64), + /// Route for the `/guilds/:guild_id/vanity-url` path. + /// + /// The data is the relevant [`GuildId`]. + /// + /// [`GuildId`]: struct.GuildId.html + GuildsIdVanityUrl(u64), /// Route for the `/guilds/:guild_id/webhooks` path. /// /// The data is the relevant [`GuildId`]. |