diff --git a/src/api/channels/channels.rs b/src/api/channels/channels.rs index 14c295a..518de59 100644 --- a/src/api/channels/channels.rs +++ b/src/api/channels/channels.rs @@ -1,7 +1,7 @@ use reqwest::Client; use serde_json::to_string; -use crate::types::AddChannelRecipientSchema; +use crate::types::{AddChannelRecipientSchema, ModifyChannelPositionsSchema}; use crate::{ api::LimitType, errors::{ChorusError, ChorusResult}, @@ -167,4 +167,30 @@ impl Channel { .handle_request_as_result(user) .await } + + /// Modifies the positions of a set of channel objects for the guild. Requires the `MANAGE_CHANNELS` permission. + /// Only channels to be modified are required. + /// + /// # Reference: + /// See + pub async fn modify_positions( + schema: Vec, + guild_id: Snowflake, + user: &mut UserMeta, + ) -> ChorusResult<()> { + let request = Client::new() + .patch(format!( + "{}/guilds/{}/channels", + user.belongs_to.borrow().urls.api, + guild_id + )) + .header("Authorization", user.token()) + .body(to_string(&schema).unwrap()); + ChorusRequest { + request, + limit_type: LimitType::Guild(guild_id), + } + .handle_request_as_result(user) + .await + } } diff --git a/src/types/schema/channel.rs b/src/types/schema/channel.rs index 27c78ee..dd62f88 100644 --- a/src/types/schema/channel.rs +++ b/src/types/schema/channel.rs @@ -148,3 +148,12 @@ pub struct AddChannelRecipientSchema { pub access_token: Option, pub nick: Option, } + +/// See +#[derive(Debug, Deserialize, Serialize, Clone, Default, PartialOrd, Ord, PartialEq, Eq)] +pub struct ModifyChannelPositionsSchema { + pub id: Snowflake, + pub position: Option, + pub lock_permissions: Option, + pub parent_id: Option, +}