1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
use super::UpdateChannelPermissionConfigured;
use crate::request::prelude::*;
use twilight_model::{
guild::Permissions,
id::{ChannelId, RoleId, UserId},
};
pub struct UpdateChannelPermission<'a> {
allow: Permissions,
channel_id: ChannelId,
deny: Permissions,
http: &'a Client,
}
impl<'a> UpdateChannelPermission<'a> {
pub(crate) fn new(
http: &'a Client,
channel_id: ChannelId,
allow: Permissions,
deny: Permissions,
) -> Self {
Self {
allow,
channel_id,
deny,
http,
}
}
pub fn member(self, user_id: impl Into<UserId>) -> UpdateChannelPermissionConfigured<'a> {
self.configure("member", user_id.into().0)
}
pub fn role(self, role_id: impl Into<RoleId>) -> UpdateChannelPermissionConfigured<'a> {
self.configure("role", role_id.into().0)
}
fn configure(
self,
kind: impl Into<String>,
target_id: u64,
) -> UpdateChannelPermissionConfigured<'a> {
UpdateChannelPermissionConfigured::new(
self.http,
self.channel_id,
self.allow,
self.deny,
kind,
target_id,
)
}
}