types(voice): bring back typed events (#8109)

This commit is contained in:
Skick
2022-06-23 17:39:36 +07:00
committed by GitHub
parent af04992ed3
commit 70b42bb64a
6 changed files with 77 additions and 5 deletions

View File

@@ -1,3 +1,4 @@
/* eslint-disable @typescript-eslint/method-signature-style */
import { EventEmitter } from 'node:events';
import type { GatewayVoiceServerUpdateDispatchData, GatewayVoiceStateUpdateDispatchData } from 'discord-api-types/v10';
import type { CreateVoiceConnectionOptions } from '.';
@@ -161,6 +162,32 @@ export type VoiceConnectionState =
| VoiceConnectionReadyState
| VoiceConnectionDestroyedState;
export interface VoiceConnection extends EventEmitter {
/**
* Emitted when there is an error emitted from the voice connection
* @event
*/
on(event: 'error', listener: (error: Error) => void): this;
/**
* Emitted debugging information about the voice connection
* @event
*/
on(event: 'debug', listener: (message: string) => void): this;
/**
* Emitted when the state of the voice connection changes
* @event
*/
on(event: 'stateChange', listener: (oldState: VoiceConnectionState, newState: VoiceConnectionState) => void): this;
/**
* Emitted when the state of the voice connection changes to a specific status
* @event
*/
on<T extends VoiceConnectionStatus>(
event: T,
listener: (oldState: VoiceConnectionState, newState: VoiceConnectionState & { status: T }) => void,
): this;
}
/**
* A connection to the voice server of a Guild, can be used to play audio in voice channels.
*/