diff options
| author | Zeyla Hellyer <[email protected]> | 2018-01-27 19:19:14 -0800 |
|---|---|---|
| committer | Zeyla Hellyer <[email protected]> | 2018-01-27 19:19:14 -0800 |
| commit | 5a0b8a68c133c3093260a5aeb08b02eb3595c18d (patch) | |
| tree | 9856dcef74a71b5fcb15e4ef0d85395f1dfc4feb /src | |
| parent | Add functions to reorder a guild's channels (diff) | |
| download | serenity-5a0b8a68c133c3093260a5aeb08b02eb3595c18d.tar.xz serenity-5a0b8a68c133c3093260a5aeb08b02eb3595c18d.zip | |
Correctly set role's position on new roles
When creating a new role, correctly set its position if a position was
specified. This is because the "Create Role" endpoint no longer accepts
a `position` key.
Diffstat (limited to 'src')
| -rw-r--r-- | src/model/guild/guild_id.rs | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/src/model/guild/guild_id.rs b/src/model/guild/guild_id.rs index 3cce275..adfac05 100644 --- a/src/model/guild/guild_id.rs +++ b/src/model/guild/guild_id.rs @@ -178,7 +178,13 @@ impl GuildId { pub fn create_role<F: FnOnce(EditRole) -> EditRole>(&self, f: F) -> Result<Role> { let map = utils::vecmap_to_json_map(f(EditRole::default()).0); - http::create_role(self.0, &map) + let role = http::create_role(self.0, &map)?; + + if let Some(position) = map.get("position").and_then(Value::as_u64) { + self.edit_role_position(role.id, position)?; + } + + Ok(role) } /// Deletes the current guild if the current account is the owner of the |