rive_http/channels/
channel_permissions.rs

1use crate::prelude::*;
2use rive_models::{
3    channel::Channel,
4    data::{SetDefaultPermissionData, SetRolePermissionData},
5};
6
7impl Client {
8    /// Sets permissions for the specified role in this channel.
9    ///
10    /// Channel must be a [Channel::TextChannel] or [Channel::VoiceChannel].
11    pub async fn set_role_channel_permissions(
12        &self,
13        channel_id: impl Into<String>,
14        role_id: impl Into<String>,
15        data: SetRolePermissionData,
16    ) -> Result<Channel> {
17        Ok(self
18            .client
19            .put(ep!(
20                self,
21                "/channels/{}/permissions/{}",
22                channel_id.into(),
23                role_id.into()
24            ))
25            .auth(&self.authentication)
26            .json(&data)
27            .send()
28            .await?
29            .process_error()
30            .await?
31            .json()
32            .await?)
33    }
34
35    /// Sets permissions for the specified role in this channel.
36    ///
37    /// Channel must be a [Channel::Group], [Channel::TextChannel] or [Channel::VoiceChannel].
38    pub async fn set_default_channel_permissions(
39        &self,
40        channel_id: impl Into<String>,
41        data: SetDefaultPermissionData,
42    ) -> Result<Channel> {
43        Ok(self
44            .client
45            .put(ep!(
46                self,
47                "/channels/{}/permissions/default",
48                channel_id.into(),
49            ))
50            .auth(&self.authentication)
51            .json(&data)
52            .send()
53            .await?
54            .process_error()
55            .await?
56            .json()
57            .await?)
58    }
59}