Skip to content

Commit

Permalink
Revert "refactor(ClientVoiceManager): make public, remove Client#voic…
Browse files Browse the repository at this point in the history
…eConnections (discordjs#3186)"

This reverts commit 489dec7.
  • Loading branch information
samsamson33 committed Feb 27, 2020
1 parent 1b4755e commit 019a160
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 17 deletions.
11 changes: 11 additions & 0 deletions src/client/Client.js
Expand Up @@ -86,6 +86,7 @@ class Client extends BaseClient {
/**
* The voice manager of the client (`null` in browsers)
* @type {?ClientVoiceManager}
* @private
*/
this.voice = !browser ? new ClientVoiceManager(this) : null;

Expand Down Expand Up @@ -156,6 +157,16 @@ class Client extends BaseClient {
}
}

/**
* All active voice connections that have been established, mapped by guild ID
* @type {Collection<Snowflake, VoiceConnection>}
* @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<Snowflake, GuildEmoji>}
Expand Down
4 changes: 1 addition & 3 deletions src/client/voice/ClientVoiceManager.js
Expand Up @@ -14,10 +14,8 @@ class ClientVoiceManager {
/**
* The client that instantiated this voice manager
* @type {Client}
* @readonly
* @name ClientVoiceManager#client
*/
Object.defineProperty(this, 'client', { value: client });
this.client = client;

/**
* A collection mapping connection IDs to the Connection objects
Expand Down
20 changes: 6 additions & 14 deletions typings/index.d.ts
Expand Up @@ -131,9 +131,11 @@ 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;
Expand All @@ -144,8 +146,9 @@ declare module 'discord.js' {
public readonly uptime: number;
public user: ClientUser | null;
public users: UserStore;
public voice: ClientVoiceManager | null;
public readonly voiceConnections: Collection<Snowflake, VoiceConnection>;
public ws: WebSocketManager;
public createVoiceBroadcast(): VoiceBroadcast;
public destroy(): void;
public fetchApplication(): Promise<ClientApplication>;
public fetchInvite(invite: InviteResolvable): Promise<Invite>;
Expand Down Expand Up @@ -231,15 +234,6 @@ declare module 'discord.js' {
public once(event: string, listener: Function): this;
}

export class ClientVoiceManager {
constructor(client: Client);
public readonly client: Client;
public connections: Collection<Snowflake, VoiceConnection>;
public broadcasts: VoiceBroadcast[];

public createBroadcast(): VoiceBroadcast;
}

export class ClientApplication extends Base {
constructor(client: Client, data: object);
public botPublic?: boolean;
Expand Down Expand Up @@ -1120,7 +1114,6 @@ 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;

Expand Down Expand Up @@ -1155,11 +1148,10 @@ declare module 'discord.js' {
}

class VoiceConnection extends EventEmitter {
constructor(voiceManager: ClientVoiceManager, channel: VoiceChannel);
constructor(voiceManager: object, channel: VoiceChannel);
private authentication: object;
private sockets: object;
private ssrcMap: Map<number, boolean>;
private _speaking: Map<Snowflake, Readonly<Speaking>>;
private _disconnect(): void;
private authenticate(): void;
private authenticateFailed(reason: string): void;
Expand All @@ -1183,7 +1175,7 @@ declare module 'discord.js' {
public receiver: VoiceReceiver;
public speaking: Readonly<Speaking>;
public status: VoiceStatus;
public voiceManager: ClientVoiceManager;
public voiceManager: object;
public disconnect(): void;
public play(input: VoiceBroadcast | Readable | string, options?: StreamOptions): StreamDispatcher;

Expand Down

0 comments on commit 019a160

Please sign in to comment.