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
|
use model::{ChannelId, RoleId};
use internal::prelude::*;
/// A builder which edits the properties of a [`Member`], to be used in
/// conjunction with [`Member::edit`].
///
/// [`Member`]: ../model/struct.Member.html
/// [`Member::edit`]: ../model/struct.Member.html#method.edit
#[derive(Clone, Debug, Default)]
pub struct EditMember(pub JsonMap);
impl EditMember {
/// Whether to deafen the member.
///
/// Requires the [Deafen Members] permission.
///
/// [Deafen Members]: ../model/permissions/constant.DEAFEN_MEMBERS.html
pub fn deafen(mut self, deafen: bool) -> Self {
self.0.insert("deaf".to_owned(), Value::Bool(deafen));
self
}
/// Whether to mute the member.
///
/// Requires the [Mute Members] permission.
///
/// [Mute Members]: ../model/permissions/constant.MUTE_MEMBERS.html
pub fn mute(mut self, mute: bool) -> Self {
self.0.insert("mute".to_owned(), Value::Bool(mute));
self
}
/// Changes the member's nickname. Pass an empty string to reset the
/// nickname.
///
/// Requires the [Manage Nicknames] permission.
///
/// [Manage Nicknames]: ../model/permissions/constant.MANAGE_NICKNAMES.html
pub fn nickname(mut self, nickname: &str) -> Self {
self.0
.insert("nick".to_owned(), Value::String(nickname.to_owned()));
self
}
/// Set the list of roles that the member should have.
///
/// Requires the [Manage Roles] permission to modify.
///
/// [Manage Roles]: ../model/permissions/constant.MANAGE_ROLES.html
pub fn roles(mut self, roles: &[RoleId]) -> Self {
let role_ids = roles
.iter()
.map(|x| Value::Number(Number::from(x.0)))
.collect();
self.0.insert("roles".to_owned(), Value::Array(role_ids));
self
}
/// The Id of the voice channel to move the member to.
///
/// Requires the [Move Members] permission.
///
/// [Move Members]: ../model/permissions/constant.MOVE_MEMBERS.html
pub fn voice_channel<C: Into<ChannelId>>(mut self, channel_id: C) -> Self {
self.0.insert(
"channel_id".to_owned(),
Value::Number(Number::from(channel_id.into().0)),
);
self
}
}
|