diff options
| author | Ken Swenson <[email protected]> | 2017-10-19 08:27:40 -0400 |
|---|---|---|
| committer | alex <[email protected]> | 2017-10-19 14:27:40 +0200 |
| commit | f47a0c831efe5842ca38cb1067de361ae42f6edc (patch) | |
| tree | 95c43f077546596e8afea6964be4372ce25b7055 /src/http | |
| parent | Add a missing break (diff) | |
| download | serenity-f47a0c831efe5842ca38cb1067de361ae42f6edc.tar.xz serenity-f47a0c831efe5842ca38cb1067de361ae42f6edc.zip | |
Implement changing a role's position (#201)
Diffstat (limited to 'src/http')
| -rw-r--r-- | src/http/mod.rs | 18 |
1 files changed, 18 insertions, 0 deletions
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<Role> { .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<Vec<Role>> { + 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::<HyperResponse, Vec<Role>>(response) + .map_err(From::from) +} + /// Edits a the webhook with the given data. /// /// The Value is a map with optional values of: |