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
80
use super::UpdateChannelPermissionConfigured;
use crate::client::Client;
use twilight_model::{
channel::permission_overwrite::PermissionOverwriteType,
guild::Permissions,
id::{ChannelId, RoleId, UserId},
};
#[must_use = "requests must be configured and executed"]
pub struct UpdateChannelPermission<'a> {
allow: Permissions,
channel_id: ChannelId,
deny: Permissions,
http: &'a Client,
}
impl<'a> UpdateChannelPermission<'a> {
pub(crate) const fn new(
http: &'a Client,
channel_id: ChannelId,
allow: Permissions,
deny: Permissions,
) -> Self {
Self {
allow,
channel_id,
deny,
http,
}
}
pub const fn member(self, user_id: UserId) -> UpdateChannelPermissionConfigured<'a> {
self.configure(PermissionOverwriteType::Member(user_id))
}
pub const fn role(self, role_id: RoleId) -> UpdateChannelPermissionConfigured<'a> {
self.configure(PermissionOverwriteType::Role(role_id))
}
const fn configure(
self,
target: PermissionOverwriteType,
) -> UpdateChannelPermissionConfigured<'a> {
UpdateChannelPermissionConfigured::new(
self.http,
self.channel_id,
self.allow,
self.deny,
target,
)
}
}