diff --git a/src/builder/edit_role.rs b/src/builder/edit_role.rs index bbd8845026a..84e4be4ea0f 100644 --- a/src/builder/edit_role.rs +++ b/src/builder/edit_role.rs @@ -172,7 +172,9 @@ impl<'a> EditRole<'a> { }; if let Some(position) = self.position { - guild_id.edit_role_position(http, role.id, position, self.audit_log_reason).await?; + guild_id + .edit_role_positions(http, [(role.id, position)], self.audit_log_reason) + .await?; } Ok(role) } diff --git a/src/http/client.rs b/src/http/client.rs index 248b9b11fd1..2a010cb8efa 100644 --- a/src/http/client.rs +++ b/src/http/client.rs @@ -2007,7 +2007,7 @@ impl Http { } /// Changes the position of a role in a guild. - pub async fn edit_role_position( + pub async fn edit_role_positions( &self, guild_id: GuildId, map: &impl serde::Serialize, diff --git a/src/model/guild/guild_id.rs b/src/model/guild/guild_id.rs index ead66460fc8..229d73a11a8 100644 --- a/src/model/guild/guild_id.rs +++ b/src/model/guild/guild_id.rs @@ -810,11 +810,10 @@ impl GuildId { /// Returns an [`Error::Http`] if the current user lacks permission. /// /// [Manage Roles]: Permissions::MANAGE_ROLES - pub async fn edit_role_position( + pub async fn edit_role_positions( self, http: &Http, - role_id: RoleId, - position: i16, + roles: impl IntoIterator, reason: Option<&str>, ) -> Result> { #[derive(serde::Serialize)] @@ -827,12 +826,15 @@ impl GuildId { Maximum::AuditLogReason.check_overflow(reason.len())?; } - let map = EditRole { - id: role_id, - position, - }; + let map = roles + .into_iter() + .map(|(id, position)| EditRole { + id, + position, + }) + .collect::>(); - http.edit_role_position(self, &map, reason).await + http.edit_role_positions(self, &map, reason).await } /// Edits the guild's welcome screen. diff --git a/src/model/guild/mod.rs b/src/model/guild/mod.rs index 26c9d3e2dc8..e85b0acdd81 100644 --- a/src/model/guild/mod.rs +++ b/src/model/guild/mod.rs @@ -1100,14 +1100,13 @@ impl Guild { /// Returns [`Error::Http`] if the current user lacks permission. /// /// [Manage Roles]: Permissions::MANAGE_ROLES - pub async fn edit_role_position( + pub async fn edit_role_positions( &self, http: &Http, - role_id: RoleId, - position: i16, + roles: impl IntoIterator, audit_log_reason: Option<&str>, ) -> Result> { - self.id.edit_role_position(http, role_id, position, audit_log_reason).await + self.id.edit_role_positions(http, roles, audit_log_reason).await } /// Modifies a scheduled event in the guild with the data set, if any. diff --git a/src/model/guild/partial_guild.rs b/src/model/guild/partial_guild.rs index 937a0943c58..df3788b68b7 100644 --- a/src/model/guild/partial_guild.rs +++ b/src/model/guild/partial_guild.rs @@ -825,14 +825,13 @@ impl PartialGuild { /// Returns [`Error::Http`] if the current user lacks permission. /// /// [Manage Roles]: Permissions::MANAGE_ROLES - pub async fn edit_role_position( + pub async fn edit_role_positions( &self, http: &Http, - role_id: RoleId, - position: i16, + roles: impl IntoIterator, audit_log_reason: Option<&str>, ) -> Result> { - self.id.edit_role_position(http, role_id, position, audit_log_reason).await + self.id.edit_role_positions(http, roles, audit_log_reason).await } /// Edits a sticker.