2020-10-23 16:11:00 +00:00
|
|
|
import { Client } from '../models/client.ts'
|
2020-10-31 12:33:34 +00:00
|
|
|
import { MemberPayload } from '../types/guild.ts'
|
|
|
|
import { VoiceStatePayload } from '../types/voice.ts'
|
2020-10-23 16:11:00 +00:00
|
|
|
import { Base } from './base.ts'
|
2020-10-23 03:19:40 +00:00
|
|
|
|
2020-10-23 16:11:00 +00:00
|
|
|
export class VoiceState extends Base {
|
|
|
|
guildID?: string
|
|
|
|
channelID?: string
|
|
|
|
userID: string
|
|
|
|
member?: MemberPayload
|
|
|
|
sessionID: string
|
|
|
|
deaf: boolean
|
|
|
|
mute: boolean
|
|
|
|
selfDeaf: boolean
|
|
|
|
selfMute: boolean
|
|
|
|
selfStream?: boolean
|
|
|
|
selfVideo: boolean
|
|
|
|
suppress: boolean
|
2020-10-23 03:19:40 +00:00
|
|
|
|
2020-10-23 16:11:00 +00:00
|
|
|
constructor (client: Client, data: VoiceStatePayload) {
|
2020-10-25 06:50:32 +00:00
|
|
|
super(client, data)
|
2020-10-23 16:11:00 +00:00
|
|
|
this.channelID = data.channel_id
|
|
|
|
this.sessionID = data.session_id
|
|
|
|
this.userID = data.user_id
|
|
|
|
this.deaf = data.deaf
|
|
|
|
this.mute = data.mute
|
|
|
|
this.selfDeaf = data.self_deaf
|
|
|
|
this.selfMute = data.self_mute
|
|
|
|
this.selfStream = data.self_stream
|
|
|
|
this.selfVideo = data.self_video
|
|
|
|
this.suppress = data.suppress
|
2020-11-01 11:22:09 +00:00
|
|
|
// TODO: Cache in Gateway Event Code
|
|
|
|
// cache.set('voiceState', `${this.guildID}:${this.userID}`, this)
|
2020-10-29 14:43:27 +00:00
|
|
|
}
|
|
|
|
|
2020-10-30 14:51:40 +00:00
|
|
|
protected readFromData (data: VoiceStatePayload): void {
|
2020-10-29 14:43:27 +00:00
|
|
|
super.readFromData(data)
|
|
|
|
this.channelID = data.channel_id ?? this.channelID
|
|
|
|
this.sessionID = data.session_id ?? this.sessionID
|
|
|
|
this.userID = data.user_id ?? this.userID
|
|
|
|
this.deaf = data.deaf ?? this.deaf
|
|
|
|
this.mute = data.mute ?? this.mute
|
|
|
|
this.selfDeaf = data.self_deaf ?? this.selfDeaf
|
|
|
|
this.selfMute = data.self_mute ?? this.selfMute
|
|
|
|
this.selfStream = data.self_stream ?? this.selfStream
|
|
|
|
this.selfVideo = data.self_video ?? this.selfVideo
|
|
|
|
this.suppress = data.suppress ?? this.suppress
|
2020-10-23 16:11:00 +00:00
|
|
|
}
|
|
|
|
}
|