forked from andersfylling/disgord
-
Notifications
You must be signed in to change notification settings - Fork 0
/
struct_voice.go
137 lines (102 loc) · 3.23 KB
/
struct_voice.go
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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
package disgord
import "sync"
// VoiceState Voice State structure
// https://discordapp.com/developers/docs/resources/voice#voice-state-object
type VoiceState struct {
sync.RWMutex `json:"-"`
// GuildID the guild id this voice state is for
GuildID Snowflake `json:"guild_id,omitempty"` // ? |
// ChannelID the channel id this user is connected to
ChannelID Snowflake `json:"channel_id"` // |
// UserID the user id this voice state is for
UserID Snowflake `json:"user_id"` // |
// SessionID the session id for this voice state
SessionID string `json:"session_id"` // |
// Deaf whether this user is deafened by the server
Deaf bool `json:"deaf"` // |
// Mute whether this user is muted by the server
Mute bool `json:"mute"` // |
// SelfDeaf whether this user is locally deafened
SelfDeaf bool `json:"self_deaf"` // |
// SelfMute whether this user is locally muted
SelfMute bool `json:"self_mute"` // |
// Suppress whether this user is muted by the current user
Suppress bool `json:"suppress"` // |
}
//func (vst *VoiceState) Clear() {
//
//}
func (v *VoiceState) DeepCopy() (copy interface{}) {
copy = &VoiceState{}
v.CopyOverTo(copy)
return
}
func (v *VoiceState) CopyOverTo(other interface{}) (err error) {
var ok bool
var voiceState *VoiceState
if voiceState, ok = other.(*VoiceState); !ok {
err = NewErrorUnsupportedType("given interface{} was not of type *VoiceState")
return
}
v.RLock()
voiceState.Lock()
voiceState.GuildID = v.GuildID
voiceState.ChannelID = v.ChannelID
voiceState.UserID = v.UserID
voiceState.SessionID = v.SessionID
voiceState.Deaf = v.Deaf
voiceState.Mute = v.Mute
voiceState.SelfDeaf = v.SelfDeaf
voiceState.SelfMute = v.SelfMute
voiceState.Suppress = v.Suppress
v.RUnlock()
voiceState.Unlock()
return
}
// VoiceRegion voice region structure
// https://discordapp.com/developers/docs/resources/voice#voice-region
type VoiceRegion struct {
sync.RWMutex `json:"-"`
// Snowflake unique Snowflake for the region
ID string `json:"id"`
// Name name of the region
Name string `json:"name"`
// SampleHostname an example hostname for the region
SampleHostname string `json:"sample_hostname"`
// SamplePort an example port for the region
SamplePort uint `json:"sample_port"`
// VIP true if this is a vip-only server
VIP bool `json:"vip"`
// Optimal true for a single server that is closest to the current user's client
Optimal bool `json:"optimal"`
// Deprecated whether this is a deprecated voice region (avoid switching to these)
Deprecated bool `json:"deprecated"`
// Custom whether this is a custom voice region (used for events/etc)
Custom bool `json:"custom"`
}
func (v *VoiceRegion) DeepCopy() (copy interface{}) {
copy = &VoiceRegion{}
v.CopyOverTo(copy)
return
}
func (v *VoiceRegion) CopyOverTo(other interface{}) (err error) {
var ok bool
var voice *VoiceRegion
if voice, ok = other.(*VoiceRegion); !ok {
err = NewErrorUnsupportedType("given interface{} was not of type *VoiceRegion")
return
}
v.RLock()
voice.Lock()
voice.ID = v.ID
voice.Name = v.Name
voice.SampleHostname = v.SampleHostname
voice.SamplePort = v.SamplePort
voice.VIP = v.VIP
voice.Optimal = v.Optimal
voice.Deprecated = v.Deprecated
voice.Custom = v.Custom
v.RUnlock()
voice.Unlock()
return
}