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
81
82
83
84
85
86
87
88
89
90
91
use crate::internal::prelude::*;
use crate::model::id::{ChannelId, RoleId};
use std::collections::HashMap;
#[derive(Clone, Debug, Default)]
pub struct EditMember(pub HashMap<&'static str, Value>);
impl EditMember {
pub fn deafen(&mut self, deafen: bool) -> &mut Self {
self.0.insert("deaf", Value::Bool(deafen));
self
}
pub fn mute(&mut self, mute: bool) -> &mut Self {
self.0.insert("mute", Value::Bool(mute));
self
}
pub fn nickname<S: ToString>(&mut self, nickname: S) -> &mut Self {
self.0.insert("nick", Value::String(nickname.to_string()));
self
}
pub fn roles<T: AsRef<RoleId>, It: IntoIterator<Item=T>>(&mut self, roles: It) -> &mut Self {
let role_ids = roles
.into_iter()
.map(|x| Value::Number(Number::from(x.as_ref().0)))
.collect();
self._roles(role_ids);
self
}
fn _roles(&mut self, roles: Vec<Value>) {
self.0.insert("roles", Value::Array(roles));
}
#[inline]
pub fn voice_channel<C: Into<ChannelId>>(&mut self, channel_id: C) -> &mut Self {
self._voice_channel(channel_id.into());
self
}
fn _voice_channel(&mut self, channel_id: ChannelId) {
let num = Value::Number(Number::from(channel_id.0));
self.0.insert("channel_id", num);
}
pub fn disconnect_member(&mut self) -> &mut Self {
self.0.insert("channel_id", Value::Null);
self
}
}