1 module dcord.types.voice;
2 
3 import std.stdio;
4 
5 import dcord.types,
6        dcord.client;
7 
8 
9 alias VoiceStateMap = ModelMap!(string, VoiceState);
10 
11 class VoiceState : IModel {
12   mixin Model;
13 
14   Snowflake  guildID;
15   Snowflake  channelID;
16   Snowflake  userID;
17   string     sessionID;
18   bool       deaf;
19   bool       mute;
20   bool       selfDeaf;
21   bool       selfMute;
22   bool       suppress;
23 
24   /*
25   override void load(JSONDecoder obj) {
26     obj.keySwitch!(
27       "guild_id", "channel_id", "user_id", "session_id",
28       "deaf", "mute", "self_deaf", "self_mute", "suppress"
29     )(
30       { this.guildID = readSnowflake(obj); },
31       { this.channelID = readSnowflake(obj); },
32       { this.userID = readSnowflake(obj); },
33       { this.sessionID = obj.read!string; },
34       { this.deaf = obj.read!bool; },
35       { this.mute = obj.read!bool; },
36       { this.selfDeaf = obj.read!bool; },
37       { this.selfMute = obj.read!bool; },
38       { this.suppress = obj.read!bool; },
39     );
40   }
41   */
42 
43   override string toString() {
44     return format("<VoiceState %s (%s / %s /%s)>",
45       this.sessionID,
46       this.guildID,
47       this.channelID,
48       this.userID);
49   }
50 
51   @property Guild guild() {
52     return this.client.state.guilds[this.guildID];
53   }
54 
55   @property Channel channel() {
56     return this.client.state.channels[this.channelID];
57   }
58 }