Skip to main content

neptunium_http/endpoints/guild/channels/
update_channel_positions.rs

1use bon::Builder;
2use neptunium_model::id::{
3    Id,
4    marker::{ChannelMarker, GuildMarker},
5};
6use reqwest::Method;
7use serde::Serialize;
8
9use crate::{endpoints::Endpoint, request::Request};
10
11#[derive(Serialize, Builder, Copy, Clone, Debug)]
12pub struct UpdateGuildChannelPositionsEntry {
13    pub id: Id<ChannelMarker>,
14    #[serde(skip_serializing_if = "Option::is_none")]
15    pub position: Option<u64>,
16    /// New parent category id.
17    #[serde(skip_serializing_if = "Option::is_none")]
18    pub parent_id: Option<Id<ChannelMarker>>,
19    /// ID of the sibling channel that should directly precede this channel after reordering.
20    #[serde(skip_serializing_if = "Option::is_none")]
21    pub preceding_sibling_id: Option<Id<ChannelMarker>>,
22    /// Whether to sync permissions with the new parent.
23    #[serde(rename = "lock_permissions", skip_serializing_if = "Option::is_none")]
24    pub sync_permissions: Option<bool>,
25}
26
27#[derive(Builder, Clone, Debug)]
28pub struct UpdateGuildChannelPositions {
29    pub guild_id: Id<GuildMarker>,
30    pub body: Vec<UpdateGuildChannelPositionsEntry>,
31}
32
33impl Endpoint for UpdateGuildChannelPositions {
34    type Response = ();
35
36    fn into_request(self) -> crate::request::Request {
37        Request::builder()
38            .method(Method::PATCH)
39            .body(serde_json::to_string(&self.body).unwrap())
40            .path(format!("/guilds/{}/channels", self.guild_id))
41            .build()
42    }
43}