commit
561c790eb7
|
@ -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 <https://discord-userdoccers.vercel.app/resources/channel#modify-guild-channel-positions>
|
||||
pub async fn modify_positions(
|
||||
schema: Vec<ModifyChannelPositionsSchema>,
|
||||
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
|
||||
}
|
||||
}
|
||||
|
|
|
@ -148,3 +148,12 @@ pub struct AddChannelRecipientSchema {
|
|||
pub access_token: Option<String>,
|
||||
pub nick: Option<String>,
|
||||
}
|
||||
|
||||
/// See <https://discord-userdoccers.vercel.app/resources/channel#add-channel-recipient>
|
||||
#[derive(Debug, Deserialize, Serialize, Clone, Default, PartialOrd, Ord, PartialEq, Eq)]
|
||||
pub struct ModifyChannelPositionsSchema {
|
||||
pub id: Snowflake,
|
||||
pub position: Option<u32>,
|
||||
pub lock_permissions: Option<bool>,
|
||||
pub parent_id: Option<Snowflake>,
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue