mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-14 10:33:30 +01:00
feat(docgen): proper event parsing for typescript
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
/* eslint-disable @typescript-eslint/prefer-ts-expect-error */
|
||||
import { EventEmitter } from 'node:events';
|
||||
import type { GatewayVoiceServerUpdateDispatchData, GatewayVoiceStateUpdateDispatchData } from 'discord-api-types/v10';
|
||||
import { TypedEmitter } from 'tiny-typed-emitter';
|
||||
import type { CreateVoiceConnectionOptions } from '.';
|
||||
import {
|
||||
getVoiceConnection,
|
||||
@@ -15,7 +14,7 @@ import type { VoiceWebSocket, VoiceUDPSocket } from './networking';
|
||||
import { Networking, NetworkingState, NetworkingStatusCode } from './networking/Networking';
|
||||
import { VoiceReceiver } from './receive';
|
||||
import type { DiscordGatewayAdapterImplementerMethods } from './util/adapter';
|
||||
import { Awaited, noop } from './util/util';
|
||||
import { noop } from './util/util';
|
||||
|
||||
/**
|
||||
* The various status codes a voice connection can hold at any one time.
|
||||
@@ -162,21 +161,10 @@ export type VoiceConnectionState =
|
||||
| VoiceConnectionReadyState
|
||||
| VoiceConnectionDestroyedState;
|
||||
|
||||
export type VoiceConnectionEvents = {
|
||||
error: (error: Error) => Awaited<void>;
|
||||
debug: (message: string) => Awaited<void>;
|
||||
stateChange: (oldState: VoiceConnectionState, newState: VoiceConnectionState) => Awaited<void>;
|
||||
} & {
|
||||
[status in VoiceConnectionStatus]: (
|
||||
oldState: VoiceConnectionState,
|
||||
newState: VoiceConnectionState & { status: status },
|
||||
) => Awaited<void>;
|
||||
};
|
||||
|
||||
/**
|
||||
* A connection to the voice server of a Guild, can be used to play audio in voice channels.
|
||||
*/
|
||||
export class VoiceConnection extends TypedEmitter<VoiceConnectionEvents> {
|
||||
export class VoiceConnection extends EventEmitter {
|
||||
/**
|
||||
* The number of consecutive rejoin attempts. Initially 0, and increments for each rejoin.
|
||||
* When a connection is successfully established, it resets to 0.
|
||||
@@ -673,7 +661,6 @@ export class VoiceConnection extends TypedEmitter<VoiceConnectionEvents> {
|
||||
*
|
||||
* @param subscription - The removed subscription
|
||||
*/
|
||||
// @ts-ignore
|
||||
private onSubscriptionRemoved(subscription: PlayerSubscription) {
|
||||
if (this.state.status !== VoiceConnectionStatus.Destroyed && this.state.subscription === subscription) {
|
||||
this.state = {
|
||||
|
||||
Reference in New Issue
Block a user