diff --git a/src/client/Client.js b/src/client/Client.js index b9a20659d..bdbc442cc 100644 --- a/src/client/Client.js +++ b/src/client/Client.js @@ -86,7 +86,6 @@ class Client extends BaseClient { /** * The voice manager of the client (`null` in browsers) * @type {?ClientVoiceManager} - * @private */ this.voice = !browser ? new ClientVoiceManager(this) : null; @@ -157,16 +156,6 @@ class Client extends BaseClient { } } - /** - * All active voice connections that have been established, mapped by guild ID - * @type {Collection} - * @readonly - */ - get voiceConnections() { - if (browser) return new Collection(); - return this.voice.connections; - } - /** * All custom emojis that the client has access to, mapped by their IDs * @type {GuildEmojiStore} diff --git a/src/client/voice/ClientVoiceManager.js b/src/client/voice/ClientVoiceManager.js index fa3513643..6986c34a6 100644 --- a/src/client/voice/ClientVoiceManager.js +++ b/src/client/voice/ClientVoiceManager.js @@ -14,8 +14,10 @@ class ClientVoiceManager { /** * The client that instantiated this voice manager * @type {Client} + * @readonly + * @name ClientVoiceManager#client */ - this.client = client; + Object.defineProperty(this, 'client', { value: client }); /** * A collection mapping connection IDs to the Connection objects diff --git a/typings/index.d.ts b/typings/index.d.ts index 53857b338..4af8827c3 100644 --- a/typings/index.d.ts +++ b/typings/index.d.ts @@ -131,11 +131,9 @@ declare module 'discord.js' { export class Client extends BaseClient { constructor(options?: ClientOptions); private actions: object; - private voice: object; private _eval(script: string): any; private _validateOptions(options?: ClientOptions): void; - public broadcasts: VoiceBroadcast[]; public channels: ChannelStore; public readonly emojis: GuildEmojiStore; public guilds: GuildStore; @@ -146,9 +144,8 @@ declare module 'discord.js' { public readonly uptime: number; public user: ClientUser | null; public users: UserStore; - public readonly voiceConnections: Collection; + public voice: ClientVoiceManager | null; public ws: WebSocketManager; - public createVoiceBroadcast(): VoiceBroadcast; public destroy(): void; public fetchApplication(): Promise; public fetchInvite(invite: InviteResolvable): Promise; @@ -234,6 +231,15 @@ declare module 'discord.js' { public once(event: string, listener: Function): this; } + export class ClientVoiceManager { + constructor(client: Client); + public readonly client: Client; + public connections: Collection; + public broadcasts: VoiceBroadcast[]; + + public createBroadcast(): VoiceBroadcast; + } + export class ClientApplication extends Base { constructor(client: Client, data: object); public botPublic?: boolean; @@ -1114,6 +1120,7 @@ declare module 'discord.js' { class VoiceBroadcast extends EventEmitter { constructor(client: Client); public client: Client; + public dispatchers: StreamDispatcher[]; public readonly dispatcher: BroadcastDispatcher; public play(input: string | Readable, options?: StreamOptions): BroadcastDispatcher; @@ -1148,10 +1155,11 @@ declare module 'discord.js' { } class VoiceConnection extends EventEmitter { - constructor(voiceManager: object, channel: VoiceChannel); + constructor(voiceManager: ClientVoiceManager, channel: VoiceChannel); private authentication: object; private sockets: object; private ssrcMap: Map; + private _speaking: Map>; private _disconnect(): void; private authenticate(): void; private authenticateFailed(reason: string): void; @@ -1175,7 +1183,7 @@ declare module 'discord.js' { public receiver: VoiceReceiver; public speaking: Readonly; public status: VoiceStatus; - public voiceManager: object; + public voiceManager: ClientVoiceManager; public disconnect(): void; public play(input: VoiceBroadcast | Readable | string, options?: StreamOptions): StreamDispatcher;