Skip to content

Commit

Permalink
Fix setting role positions (#609)
Browse files Browse the repository at this point in the history
  • Loading branch information
icewind1991 authored and arqunis committed Jun 10, 2019
1 parent 62e19a7 commit c14ca32
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/http/raw.rs
Expand Up @@ -724,15 +724,15 @@ impl Http {

/// Changes the position of a role in a guild.
pub fn edit_role_position(&self, guild_id: u64, role_id: u64, position: u64) -> Result<Vec<Role>> {
let body = serde_json::to_vec(&json!({
let body = serde_json::to_vec(&json!([{
"id": role_id,
"position": position,
}))?;
}]))?;

self.fire(Request {
body: Some(&body),
headers: None,
route: RouteInfo::EditRole { guild_id, role_id },
route: RouteInfo::EditRolePosition { guild_id },
})
}

Expand Down
8 changes: 8 additions & 0 deletions src/http/routing.rs
Expand Up @@ -753,6 +753,9 @@ pub enum RouteInfo<'a> {
guild_id: u64,
role_id: u64,
},
EditRolePosition {
guild_id: u64,
},
EditWebhook {
webhook_id: u64,
},
Expand Down Expand Up @@ -1138,6 +1141,11 @@ impl<'a> RouteInfo<'a> {
Route::GuildsIdRolesId(guild_id),
Cow::from(Route::guild_role(guild_id, role_id)),
),
RouteInfo::EditRolePosition { guild_id } => (
LightMethod::Patch,
Route::GuildsIdRolesId(guild_id),
Cow::from(Route::guild_roles(guild_id)),
),
RouteInfo::EditWebhook { webhook_id } => (
LightMethod::Patch,
Route::WebhooksId(webhook_id),
Expand Down

0 comments on commit c14ca32

Please sign in to comment.