From f47a0c831efe5842ca38cb1067de361ae42f6edc Mon Sep 17 00:00:00 2001 From: Ken Swenson Date: Thu, 19 Oct 2017 08:27:40 -0400 Subject: Implement changing a role's position (#201) --- src/http/mod.rs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'src/http') diff --git a/src/http/mod.rs b/src/http/mod.rs index 0abed02..099a33c 100644 --- a/src/http/mod.rs +++ b/src/http/mod.rs @@ -814,6 +814,24 @@ pub fn edit_role(guild_id: u64, role_id: u64, map: &JsonMap) -> Result { .map_err(From::from) } +/// Changes the position of a role in a guild. +pub fn edit_role_position(guild_id: u64, role_id: u64, position: u64) -> Result> { + let body = serde_json::to_string(&json!({ + "id": role_id, + "position": position, + }))?; + let response = request!( + Route::GuildsIdRolesId(guild_id), + patch(body), + "/guilds/{}/roles/{}", + guild_id, + role_id + ); + + serde_json::from_reader::>(response) + .map_err(From::from) +} + /// Edits a the webhook with the given data. /// /// The Value is a map with optional values of: -- cgit v1.2.3