✨ Add disconnection functions to voice channel
This commit is contained in:
parent
51b1d71e9a
commit
96b273ed04
1 changed files with 23 additions and 0 deletions
|
@ -11,6 +11,8 @@ import { GuildChannel } from './channel.ts'
|
|||
import { Guild } from './guild.ts'
|
||||
import { VoiceState } from './voiceState.ts'
|
||||
import { GuildChannelVoiceStatesManager } from '../managers/guildChannelVoiceStates.ts'
|
||||
import { User } from './user.ts'
|
||||
import { Member } from './member.ts'
|
||||
|
||||
export interface VoiceServerData extends VoiceServerUpdateData {
|
||||
sessionID: string
|
||||
|
@ -113,4 +115,25 @@ export class VoiceChannel extends GuildChannel {
|
|||
|
||||
return new VoiceChannel(this.client, resp, this.guild)
|
||||
}
|
||||
|
||||
async disconnectMember(
|
||||
member: User | Member | string
|
||||
): Promise<Member | undefined> {
|
||||
const memberID = typeof member === 'string' ? member : member.id
|
||||
const memberVoiceState = await this.voiceStates.get(memberID)
|
||||
|
||||
return memberVoiceState?.disconnect()
|
||||
}
|
||||
|
||||
async disconnectAll(): Promise<Member[]> {
|
||||
const members: Member[] = []
|
||||
for await (const memberVoiceState of this.voiceStates) {
|
||||
const member = await memberVoiceState.disconnect()
|
||||
if (member !== undefined) {
|
||||
members.push(member)
|
||||
}
|
||||
}
|
||||
|
||||
return members
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue