mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-13 10:03:31 +01:00
refactor(ClientVoiceManager): make public, remove Client#voiceConnections (#3186)
* docs: make voice public * typings: Update typings to match the docs * typings: ClientVoiceManager is nullable in Client Co-Authored-By: vladfrangu <kingdgrizzle@gmail.com> * typings: Mark client as readonly Co-Authored-By: vladfrangu <kingdgrizzle@gmail.com> * src: Make the client readonly * src: Remove Client#voiceConnections getter in favor of ClientVoiceManager#connections
This commit is contained in:
@@ -86,7 +86,6 @@ class Client extends BaseClient {
|
|||||||
/**
|
/**
|
||||||
* The voice manager of the client (`null` in browsers)
|
* The voice manager of the client (`null` in browsers)
|
||||||
* @type {?ClientVoiceManager}
|
* @type {?ClientVoiceManager}
|
||||||
* @private
|
|
||||||
*/
|
*/
|
||||||
this.voice = !browser ? new ClientVoiceManager(this) : null;
|
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<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
|
* All custom emojis that the client has access to, mapped by their IDs
|
||||||
* @type {GuildEmojiStore<Snowflake, GuildEmoji>}
|
* @type {GuildEmojiStore<Snowflake, GuildEmoji>}
|
||||||
|
|||||||
@@ -14,8 +14,10 @@ class ClientVoiceManager {
|
|||||||
/**
|
/**
|
||||||
* The client that instantiated this voice manager
|
* The client that instantiated this voice manager
|
||||||
* @type {Client}
|
* @type {Client}
|
||||||
|
* @readonly
|
||||||
|
* @name ClientVoiceManager#client
|
||||||
*/
|
*/
|
||||||
this.client = client;
|
Object.defineProperty(this, 'client', { value: client });
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A collection mapping connection IDs to the Connection objects
|
* A collection mapping connection IDs to the Connection objects
|
||||||
|
|||||||
20
typings/index.d.ts
vendored
20
typings/index.d.ts
vendored
@@ -131,11 +131,9 @@ declare module 'discord.js' {
|
|||||||
export class Client extends BaseClient {
|
export class Client extends BaseClient {
|
||||||
constructor(options?: ClientOptions);
|
constructor(options?: ClientOptions);
|
||||||
private actions: object;
|
private actions: object;
|
||||||
private voice: object;
|
|
||||||
private _eval(script: string): any;
|
private _eval(script: string): any;
|
||||||
private _validateOptions(options?: ClientOptions): void;
|
private _validateOptions(options?: ClientOptions): void;
|
||||||
|
|
||||||
public broadcasts: VoiceBroadcast[];
|
|
||||||
public channels: ChannelStore;
|
public channels: ChannelStore;
|
||||||
public readonly emojis: GuildEmojiStore;
|
public readonly emojis: GuildEmojiStore;
|
||||||
public guilds: GuildStore;
|
public guilds: GuildStore;
|
||||||
@@ -146,9 +144,8 @@ declare module 'discord.js' {
|
|||||||
public readonly uptime: number;
|
public readonly uptime: number;
|
||||||
public user: ClientUser | null;
|
public user: ClientUser | null;
|
||||||
public users: UserStore;
|
public users: UserStore;
|
||||||
public readonly voiceConnections: Collection<Snowflake, VoiceConnection>;
|
public voice: ClientVoiceManager | null;
|
||||||
public ws: WebSocketManager;
|
public ws: WebSocketManager;
|
||||||
public createVoiceBroadcast(): VoiceBroadcast;
|
|
||||||
public destroy(): void;
|
public destroy(): void;
|
||||||
public fetchApplication(): Promise<ClientApplication>;
|
public fetchApplication(): Promise<ClientApplication>;
|
||||||
public fetchInvite(invite: InviteResolvable): Promise<Invite>;
|
public fetchInvite(invite: InviteResolvable): Promise<Invite>;
|
||||||
@@ -234,6 +231,15 @@ declare module 'discord.js' {
|
|||||||
public once(event: string, listener: Function): this;
|
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 {
|
export class ClientApplication extends Base {
|
||||||
constructor(client: Client, data: object);
|
constructor(client: Client, data: object);
|
||||||
public botPublic?: boolean;
|
public botPublic?: boolean;
|
||||||
@@ -1114,6 +1120,7 @@ declare module 'discord.js' {
|
|||||||
class VoiceBroadcast extends EventEmitter {
|
class VoiceBroadcast extends EventEmitter {
|
||||||
constructor(client: Client);
|
constructor(client: Client);
|
||||||
public client: Client;
|
public client: Client;
|
||||||
|
public dispatchers: StreamDispatcher[];
|
||||||
public readonly dispatcher: BroadcastDispatcher;
|
public readonly dispatcher: BroadcastDispatcher;
|
||||||
public play(input: string | Readable, options?: StreamOptions): BroadcastDispatcher;
|
public play(input: string | Readable, options?: StreamOptions): BroadcastDispatcher;
|
||||||
|
|
||||||
@@ -1148,10 +1155,11 @@ declare module 'discord.js' {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class VoiceConnection extends EventEmitter {
|
class VoiceConnection extends EventEmitter {
|
||||||
constructor(voiceManager: object, channel: VoiceChannel);
|
constructor(voiceManager: ClientVoiceManager, channel: VoiceChannel);
|
||||||
private authentication: object;
|
private authentication: object;
|
||||||
private sockets: object;
|
private sockets: object;
|
||||||
private ssrcMap: Map<number, boolean>;
|
private ssrcMap: Map<number, boolean>;
|
||||||
|
private _speaking: Map<Snowflake, Readonly<Speaking>>;
|
||||||
private _disconnect(): void;
|
private _disconnect(): void;
|
||||||
private authenticate(): void;
|
private authenticate(): void;
|
||||||
private authenticateFailed(reason: string): void;
|
private authenticateFailed(reason: string): void;
|
||||||
@@ -1175,7 +1183,7 @@ declare module 'discord.js' {
|
|||||||
public receiver: VoiceReceiver;
|
public receiver: VoiceReceiver;
|
||||||
public speaking: Readonly<Speaking>;
|
public speaking: Readonly<Speaking>;
|
||||||
public status: VoiceStatus;
|
public status: VoiceStatus;
|
||||||
public voiceManager: object;
|
public voiceManager: ClientVoiceManager;
|
||||||
public disconnect(): void;
|
public disconnect(): void;
|
||||||
public play(input: VoiceBroadcast | Readable | string, options?: StreamOptions): StreamDispatcher;
|
public play(input: VoiceBroadcast | Readable | string, options?: StreamOptions): StreamDispatcher;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user