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
use crate::{
gateway::opcode::OpCode,
id::{ChannelId, GuildId},
};
use serde::{Deserialize, Serialize};
#[derive(Clone, Debug, Deserialize, Eq, Hash, PartialEq, Serialize)]
pub struct UpdateVoiceState {
pub d: UpdateVoiceStateInfo,
pub op: OpCode,
}
impl UpdateVoiceState {
pub fn new(
guild_id: impl Into<GuildId>,
channel_id: impl Into<Option<ChannelId>>,
self_deaf: bool,
self_mute: bool,
) -> Self {
Self {
d: UpdateVoiceStateInfo::new(guild_id, channel_id, self_deaf, self_mute),
op: OpCode::VoiceStateUpdate,
}
}
}
#[derive(Clone, Debug, Deserialize, Eq, Hash, PartialEq, Serialize)]
pub struct UpdateVoiceStateInfo {
pub channel_id: Option<ChannelId>,
pub guild_id: GuildId,
pub self_deaf: bool,
pub self_mute: bool,
}
impl UpdateVoiceStateInfo {
pub fn new(
guild_id: impl Into<GuildId>,
channel_id: impl Into<Option<ChannelId>>,
self_deaf: bool,
self_mute: bool,
) -> Self {
Self::_new(guild_id.into(), channel_id.into(), self_deaf, self_mute)
}
const fn _new(
guild_id: GuildId,
channel_id: Option<ChannelId>,
self_deaf: bool,
self_mute: bool,
) -> Self {
Self {
channel_id,
guild_id,
self_deaf,
self_mute,
}
}
}