2021-04-04 09:29:56 +00:00
|
|
|
import type { Client } from '../client/mod.ts'
|
2021-03-30 17:18:24 +00:00
|
|
|
import { BaseChildManager } from './baseChild.ts'
|
2021-04-04 09:29:56 +00:00
|
|
|
import type { VoiceStatePayload } from '../types/voice.ts'
|
2021-03-30 17:18:24 +00:00
|
|
|
import { VoiceState } from '../structures/voiceState.ts'
|
|
|
|
import { GuildVoiceStatesManager } from './guildVoiceStates.ts'
|
2021-04-04 09:29:56 +00:00
|
|
|
import type { VoiceChannel } from '../structures/guildVoiceChannel.ts'
|
2021-03-30 17:18:24 +00:00
|
|
|
|
|
|
|
export class GuildChannelVoiceStatesManager extends BaseChildManager<
|
|
|
|
VoiceStatePayload,
|
|
|
|
VoiceState
|
|
|
|
> {
|
|
|
|
channel: VoiceChannel
|
|
|
|
|
|
|
|
constructor(
|
|
|
|
client: Client,
|
|
|
|
parent: GuildVoiceStatesManager,
|
|
|
|
channel: VoiceChannel
|
|
|
|
) {
|
|
|
|
super(client, parent as any)
|
|
|
|
this.channel = channel
|
|
|
|
}
|
|
|
|
|
|
|
|
async get(id: string): Promise<VoiceState | undefined> {
|
|
|
|
const res = await this.parent.get(id)
|
|
|
|
if (res !== undefined && res.channel?.id === this.channel.id) return res
|
|
|
|
else return undefined
|
|
|
|
}
|
|
|
|
|
|
|
|
async array(): Promise<VoiceState[]> {
|
|
|
|
const arr = (await this.parent.array()) as VoiceState[]
|
|
|
|
return arr.filter((c: any) => c.channel?.id === this.channel.id) as any
|
|
|
|
}
|
|
|
|
|
|
|
|
async fromPayload(d: VoiceStatePayload[]): Promise<void> {
|
|
|
|
for (const data of d) {
|
|
|
|
await this.set(data.user_id, data)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|