### Install @discordjs/voice Source: https://discord.js.org/docs/packages/voice/0.19.0 Install the @discordjs/voice package using your preferred package manager. Node.js 22.12.0 or newer is required. ```bash npm install @discordjs/voice ``` ```bash yarn add @discordjs/voice ``` ```bash pnpm add @discordjs/voice ``` ```bash bun add @discordjs/voice ``` -------------------------------- ### SpeakingMap 'start' Event - TypeScript Source: https://discord.js.org/docs/packages/voice/0.19.0/SpeakingMap%3AClass Emitted when a user starts speaking. The event listener receives the userId of the user who started speaking. ```typescript on( event: 'start' listener: (userId: string) => void ) : this ``` -------------------------------- ### Play Audio Resource Source: https://discord.js.org/docs/packages/voice/0.19.0/AudioPlayer%3AClass Starts playing a new audio resource. If a resource is already playing, it will be destroyed and replaced. The generic type 'Metadata' allows for custom metadata associated with the resource. ```typescript play( resource: AudioResource ) : void ``` -------------------------------- ### AudioPlayerIdleState Interface Source: https://discord.js.org/docs/packages/voice/0.19.0/AudioPlayerIdleState%3AInterface Represents the state of an AudioPlayer when it has no resource to play. This is the starting state. ```APIDOC ## Interface: AudioPlayerIdleState ### Description The state that an AudioPlayer is in when it has no resource to play. This is the starting state. ### Properties - **status** (AudioPlayerStatus.Idle) - The status property will always be AudioPlayerStatus.Idle when in this state. ``` -------------------------------- ### SSRCMap.get Source: https://discord.js.org/docs/packages/voice/0.19.0/SSRCMap%3AClass Gets the stored voice data of a user. ```APIDOC ## get(target: number | string): VoiceUserData | undefined Gets the stored voice data of a user. ``` -------------------------------- ### getVerificationCode Source: https://discord.js.org/docs/packages/voice/0.19.0/VoiceConnection%3AClass Gets the verification code for a user in the session. ```APIDOC ## getVerificationCode(userId: string) Gets the verification code for a user in the session. ### Parameters - **userId** (string) - The ID of the user. ### Returns - `Promise` ``` -------------------------------- ### getVerificationCode Source: https://discord.js.org/docs/packages/voice/0.19.0/DAVESession%3AClass Gets the verification code for a user in the session. ```APIDOC ## getVerificationCode(userId: string) : Promise Gets the verification code for a user in the session. ``` -------------------------------- ### AudioPlayerIdleState Interface Definition Source: https://discord.js.org/docs/packages/voice/0.19.0/AudioPlayerIdleState%3AInterface Defines the interface for an AudioPlayer that is in an idle state, meaning it has no resource to play. This is the default starting state. ```typescript export interface AudioPlayerIdleState ``` -------------------------------- ### Get all voice connections Source: https://discord.js.org/docs/packages/voice/0.19.0/getVoiceConnections%3AFunction Retrieves all voice connections under the 'default' group. This is useful for managing or inspecting active connections. ```typescript export declare function getVoiceConnections(group?: 'default'): Map; ``` -------------------------------- ### Get @discordjs/voice Version Source: https://discord.js.org/docs/packages/voice/0.19.0/version%3AVariable Access the `version` variable to retrieve the current version string of the @discordjs/voice package. ```typescript import { version } from "@discordjs/voice"; console.log(version); ``` -------------------------------- ### Generate Dependency Report for @discordjs/voice Source: https://discord.js.org/docs/packages/voice/0.19.0/generateDependencyReport%3AFunction Call this function to get a string report of the dependencies used by the @discordjs/voice module. This is helpful for diagnosing issues. ```typescript export declare function generateDependencyReport(): string; ``` -------------------------------- ### AudioPlayerStatus: Buffering State Source: https://discord.js.org/docs/packages/voice/0.19.0/AudioPlayerStatus%3AEnum The 'buffering' state signifies that the player is waiting for an audio resource to become readable before it can start playing. This is a transitional state. ```typescript Buffering = "buffering" ``` -------------------------------- ### Get All Voice Connection Groups Source: https://discord.js.org/docs/packages/voice/0.19.0/getGroups%3AFunction Retrieves the map of group names to maps of voice connections. All voice connections are created under the 'default' group by default. ```typescript export declare function getGroups(): Map>; ``` -------------------------------- ### constructor Source: https://discord.js.org/docs/packages/voice/0.19.0/VoiceUDPSocket%3AClass Creates a new VoiceUDPSocket instance. ```APIDOC ## constructor(remote: SocketConfig) Creates a new VoiceUDPSocket. ### Parameters #### Path Parameters - **remote** (SocketConfig) - Description of the remote socket configuration. ``` -------------------------------- ### prepareEpoch Source: https://discord.js.org/docs/packages/voice/0.19.0/DAVESession%3AClass Prepare for a new epoch. ```APIDOC ## prepareEpoch(data: VoiceDavePrepareEpochData) : void Prepare for a new epoch. ``` -------------------------------- ### prepareTransition Source: https://discord.js.org/docs/packages/voice/0.19.0/DAVESession%3AClass Prepare for a transition. ```APIDOC ## prepareTransition(data: VoiceDavePrepareTransitionData) : boolean Prepare for a transition. Returns: Whether we should signal to the voice server that we are ready ``` -------------------------------- ### Networking Constructor Source: https://discord.js.org/docs/packages/voice/0.19.0/Networking%3AClass Creates a new Networking instance. ```APIDOC ## constructor(connectionOptions: ConnectionOptions, options: NetworkingOptions) Creates a new Networking instance. ``` -------------------------------- ### SSRCMap.on Source: https://discord.js.org/docs/packages/voice/0.19.0/SSRCMap%3AClass Listens for the 'create' event, which is triggered when new voice user data is added. ```APIDOC ## on(event: 'create', listener: (newData: VoiceUserData) => void): this Listens for the 'create' event. ``` -------------------------------- ### prepareAudioPacket(opusPacket: Buffer) Source: https://discord.js.org/docs/packages/voice/0.19.0/Networking%3AClass Prepares an Opus packet for playback. This includes attaching metadata to it and encrypting it. It will be stored within the instance, and can be played by dispatchAudio(). Returns: The audio packet that was prepared. ```APIDOC ## prepareAudioPacket( opusPacket: Buffer ) : Buffer | undefined Prepares an Opus packet for playback. This includes attaching metadata to it and encrypting it. It will be stored within the instance, and can be played by dispatchAudio() Returns: The audio packet that was prepared ``` -------------------------------- ### AudioPlayer Constructor Source: https://discord.js.org/docs/packages/voice/0.19.0/AudioPlayer%3AClass Creates a new AudioPlayer instance. Options can be provided to configure the player. ```APIDOC ## constructor(options?: CreateAudioPlayerOptions) Creates a new AudioPlayer. ### Parameters * **options** (CreateAudioPlayerOptions) - Optional - Configuration options for the AudioPlayer. ``` -------------------------------- ### Get Verification Code - VoiceConnection Source: https://discord.js.org/docs/packages/voice/0.19.0/VoiceConnection%3AClass Retrieves the verification code for a user within the current voice session. ```typescript getVerificationCode(userId: string) : Promise ``` -------------------------------- ### playOpusPacket Source: https://discord.js.org/docs/packages/voice/0.19.0/VoiceConnection%3AClass Prepares an audio packet and dispatches it immediately. ```APIDOC ## playOpusPacket(buffer: Buffer) Prepares an audio packet and dispatches it immediately. ### Parameters - **buffer** (Buffer) - The Opus packet buffer. ### Returns - `boolean | undefined` ``` -------------------------------- ### processWelcome Source: https://discord.js.org/docs/packages/voice/0.19.0/DAVESession%3AClass Processes a welcome from the MLS group. ```APIDOC ## processWelcome(payload: Buffer) : TransitionResult Processes a welcome from the MLS group. Returns: The transaction id and whether it was successful ``` -------------------------------- ### prepareAudioPacket Source: https://discord.js.org/docs/packages/voice/0.19.0/VoiceConnection%3AClass Prepares an audio packet for dispatch. ```APIDOC ## prepareAudioPacket(buffer: Buffer) Prepares an audio packet for dispatch. ### Parameters - **buffer** (Buffer) - The audio packet buffer. ### Returns - `Buffer | undefined` ``` -------------------------------- ### Get Voice User Data Source: https://discord.js.org/docs/packages/voice/0.19.0/SSRCMap%3AClass Retrieves voice data for a given SSRC from the SSRCMap. Returns the data if found, otherwise undefined. ```typescript get(target: number | string): VoiceUserData | undefined ``` -------------------------------- ### Create AudioPlayer Instance Source: https://discord.js.org/docs/packages/voice/0.19.0/AudioPlayer%3AClass Instantiates a new AudioPlayer. Options can be provided during creation. ```typescript constructor(options?: CreateAudioPlayerOptions) ``` -------------------------------- ### configureNetworking Source: https://discord.js.org/docs/packages/voice/0.19.0/VoiceConnection%3AClass Attempts to configure a networking instance for this voice connection using received packets. Both packets are required, and any existing networking instance will be destroyed. ```APIDOC ## configureNetworking() Attempts to configure a networking instance for this voice connection using the received packets. Both packets are required, and any existing networking instance will be destroyed. ### Returns - `void` ``` -------------------------------- ### createAudioResource Source: https://discord.js.org/docs/packages/voice/0.19.0/createAudioResource%3AFunction Creates an audio resource that can be played by audio players. ```APIDOC ## function createAudioResource Creates an audio resource that can be played by audio players. ### Parameters * **input**: Readable | string - The resource to play * **options**: CreateAudioResourceOptions & Pick : Required>, 'metadata'> - Configurable options for creating the resource ### Metadata The type for the metadata (if any) of the audio resource. ``` -------------------------------- ### PlayerSubscription Constructor Source: https://discord.js.org/docs/packages/voice/0.19.0/PlayerSubscription%3AClass Initializes a new PlayerSubscription instance. It requires a VoiceConnection and an AudioPlayer to establish the subscription. ```typescript constructor( connection: VoiceConnection player: AudioPlayer ) ``` -------------------------------- ### AudioResource Properties Source: https://discord.js.org/docs/packages/voice/0.19.0/AudioResource%3AClass Properties of the AudioResource class, including its edges, encoder, ended status, metadata, playback duration, play stream, readability, silence padding, and started status. ```APIDOC ### Properties - **edges** (readonly Edge[]): The pipeline used to convert the input stream into a playable format. - **encoder?** (prism.opus.Encoder): If using an Opus encoder, this will be a prism-media opus.Encoder. - **ended** (boolean): Whether this resource has ended or not. - **metadata** (Metadata): Optional metadata that can be used to identify the resource. - **playbackDuration** (number): The playback duration of this audio resource, given in milliseconds. - **playStream** (Readable): An object-mode Readable stream that emits Opus packets. - **readable** (boolean): Whether this resource is readable. - **silencePaddingFrames** (number): The number of silence frames to append to the end of the resource's audio stream. - **silenceRemaining** (number): The number of remaining silence frames to play. - **started** (boolean): Whether or not the stream for this resource has started. - **volume?** (prism.VolumeTransformer): If the resource was created with inline volume transformation enabled, this will be a prism-media VolumeTransformer. ``` -------------------------------- ### VoiceWebSocket Constructor Source: https://discord.js.org/docs/packages/voice/0.19.0/VoiceWebSocket%3AClass Initializes a new VoiceWebSocket instance. Requires the server address and a debug flag. ```typescript constructor( address: string, debug: boolean ) ``` -------------------------------- ### CreateAudioResourceOptions Interface Source: https://discord.js.org/docs/packages/voice/0.19.0/CreateAudioResourceOptions%3AInterface Defines the structure for options when creating a new audio resource. Use this to configure playback settings like volume, input type, and metadata. ```typescript export interface CreateAudioResourceOptions ``` -------------------------------- ### Get Voice Connection by Guild ID Source: https://discord.js.org/docs/packages/voice/0.19.0/getVoiceConnection%3AFunction Finds a voice connection using the guild ID. If no group is specified, it defaults to 'default'. Returns the connection if found, otherwise undefined. ```typescript export declare function getVoiceConnection(guildId: string, group?: string): VoiceConnection | undefined; ``` -------------------------------- ### PlayerSubscription Constructor Source: https://discord.js.org/docs/packages/voice/0.19.0/PlayerSubscription%3AClass Constructs a new instance of the PlayerSubscription class, linking a VoiceConnection with an AudioPlayer. ```APIDOC ## constructor(connection: VoiceConnection, player: AudioPlayer) ### Description Constructs a new instance of the `PlayerSubscription` class. ### Parameters - **connection** (VoiceConnection) - Required - The voice connection to subscribe to. - **player** (AudioPlayer) - Required - The audio player to subscribe. ``` -------------------------------- ### SpeakingMap users Property - TypeScript Source: https://discord.js.org/docs/packages/voice/0.19.0/SpeakingMap%3AClass This readonly property holds a Map of currently speaking users. The keys are user IDs (strings), and the values are the milliseconds since the UNIX epoch when they started speaking (numbers). ```typescript readonly users : Map ``` -------------------------------- ### subscribe Method Source: https://discord.js.org/docs/packages/voice/0.19.0/VoiceReceiver%3AClass Creates a subscription for receiving audio packets from a specific user. ```APIDOC ## subscribe(target: string, options?: Partial): AudioReceiveStream ### Description Creates a subscription for the given user id. ### Parameters #### Path Parameters - **target** (string) - Required - The user id to subscribe to. - **options** (Partial) - Optional - Options for the audio receive stream. ### Returns - **AudioReceiveStream**: A readable stream of Opus packets received from the target. ``` -------------------------------- ### Create an AudioPlayer Source: https://discord.js.org/docs/packages/voice/0.19.0/createAudioPlayer%3AFunction Use this function to create a new AudioPlayer instance. Options can be provided to configure the player upon creation. ```typescript export declare function createAudioPlayer(options?: CreateAudioPlayerOptions): AudioPlayer; ``` -------------------------------- ### createAudioPlayer Source: https://discord.js.org/docs/packages/voice/0.19.0/createAudioPlayer%3AFunction Creates a new AudioPlayer to be used. ```APIDOC ## createAudioPlayer ### Description Creates a new AudioPlayer to be used. ### Signature ```typescript createAudioPlayer(options?: CreateAudioPlayerOptions): AudioPlayer; ``` ### Parameters #### options - `options` (CreateAudioPlayerOptions) - Optional - Configuration options for the AudioPlayer. ``` -------------------------------- ### executeTransition Source: https://discord.js.org/docs/packages/voice/0.19.0/DAVESession%3AClass Execute a transition. ```APIDOC ## executeTransition(transitionId: number) : boolean | undefined Execute a transition. ``` -------------------------------- ### DAVESession ProcessWelcome Method Source: https://discord.js.org/docs/packages/voice/0.19.0/DAVESession%3AClass Processes a welcome payload from the MLS group. Returns the transaction ID and success status. ```typescript processWelcome( payload: Buffer ) : TransitionResult ``` -------------------------------- ### on Source: https://discord.js.org/docs/packages/voice/0.19.0/DAVESession%3AClass Listens for events on the DAVESession. ```APIDOC ## on(event: 'error', listener: (error: Error) => void) : this Listens for the 'error' event on the DAVESession. ``` -------------------------------- ### DAVESession PrepareTransition Method Source: https://discord.js.org/docs/packages/voice/0.19.0/DAVESession%3AClass Prepares for a session transition. Returns a boolean indicating whether to signal readiness to the voice server. ```typescript prepareTransition( data: VoiceDavePrepareTransitionData ) : boolean ``` -------------------------------- ### Networking Constructor Source: https://discord.js.org/docs/packages/voice/0.19.0/Networking%3AClass Initializes a new Networking instance with connection and networking options. Ensure connectionOptions and networkingOptions are properly configured before instantiation. ```typescript constructor( connectionOptions: ConnectionOptions, options: NetworkingOptions ) ``` -------------------------------- ### Prepare Audio Packet - VoiceConnection Source: https://discord.js.org/docs/packages/voice/0.19.0/VoiceConnection%3AClass Prepares an audio packet for subsequent dispatch. Returns the prepared packet buffer or undefined if preparation fails. ```typescript prepareAudioPacket(buffer: Buffer) : Buffer | undefined ``` -------------------------------- ### VoiceConnection Constructor Source: https://discord.js.org/docs/packages/voice/0.19.0/VoiceConnection%3AClass Creates a new voice connection instance. Requires join configuration and optional creation options. ```APIDOC ## constructor(joinConfig: JoinConfig, options: CreateVoiceConnectionOptions) Creates a new voice connection. ### Parameters - **joinConfig** (JoinConfig) - Configuration for joining the voice channel. - **options** (CreateVoiceConnectionOptions) - Optional settings for creating the voice connection. ``` -------------------------------- ### NetworkingOpeningWsState Interface Source: https://discord.js.org/docs/packages/voice/0.19.0/NetworkingOpeningWsState%3AInterface The initial Networking state. Instances will be in this state when a WebSocket connection to a Discord voice gateway is being opened. ```APIDOC ## Interface NetworkingOpeningWsState ```typescript export interface NetworkingOpeningWsState ``` ### Description The initial Networking state. Instances will be in this state when a WebSocket connection to a Discord voice gateway is being opened. ### Properties - **code**: NetworkingStatusCode.OpeningWs - **connectionOptions**: ConnectionOptions - **ws**: VoiceWebSocket ``` -------------------------------- ### VoiceWebSocket Constructor Source: https://discord.js.org/docs/packages/voice/0.19.0/VoiceWebSocket%3AClass Creates a new VoiceWebSocket instance. This constructor is used to establish a connection to the Discord Voice gateway. ```APIDOC ## constructor(address: string, debug: boolean) Creates a new VoiceWebSocket. ### Parameters * **address** (string) - The address of the Discord Voice gateway. * **debug** (boolean) - Whether to enable debug logging. ``` -------------------------------- ### on('debug', listener) Source: https://discord.js.org/docs/packages/voice/0.19.0/Networking%3AClass Debug event for Networking. ```APIDOC ## on( event: 'debug' listener: (message: string) => void ) : this Debug event for Networking. ``` -------------------------------- ### Create Audio Resource - TypeScript Source: https://discord.js.org/docs/packages/voice/0.19.0/createAudioResource%3AFunction Creates an audio resource from a readable stream or string. The metadata type is inferred from the options. ```typescript export declare function createAudioResource(input: Readable | string, options: CreateAudioResourceOptions & Pick : Required>, 'metadata'>): AudioResource; ``` -------------------------------- ### CreateAudioPlayerOptions Interface Source: https://discord.js.org/docs/packages/voice/0.19.0/CreateAudioPlayerOptions%3AInterface Defines the structure for options when creating an audio player. Allows configuration of behaviors like max missed frames and no subscriber actions, as well as enabling debug logging. ```typescript export interface CreateAudioPlayerOptions ``` -------------------------------- ### dispatchAudio Source: https://discord.js.org/docs/packages/voice/0.19.0/VoiceConnection%3AClass Dispatches the previously prepared audio packet (if any). ```APIDOC ## dispatchAudio() Dispatches the previously prepared audio packet (if any). ### Returns - `boolean | undefined` ``` -------------------------------- ### AudioResource Constructor Source: https://discord.js.org/docs/packages/voice/0.19.0/AudioResource%3AClass Constructs a new instance of the AudioResource class. It takes edges, streams, metadata, and silence padding frames as arguments. ```APIDOC ## constructor(edges: readonly Edge[], streams: readonly Readable[], metadata: Metadata, silencePaddingFrames: number) ### Description Constructs a new instance of the `AudioResource` class. ### Parameters #### Path Parameters - **edges** (readonly Edge[]) - Required - The pipeline used to convert the input stream into a playable format. - **streams** (readonly Readable[]) - Required - An object-mode Readable stream that emits Opus packets. - **metadata** (Metadata) - Optional - Optional metadata that can be used to identify the resource. - **silencePaddingFrames** (number) - Required - The number of silence frames to append to the end of the resource's audio stream. ``` -------------------------------- ### dispatchAudio() Source: https://discord.js.org/docs/packages/voice/0.19.0/Networking%3AClass Dispatches the audio packet previously prepared by prepareAudioPacket(opusPacket). The audio packet is consumed and cannot be dispatched again. ```APIDOC ## dispatchAudio() : boolean Dispatches the audio packet previously prepared by prepareAudioPacket(opusPacket). The audio packet is consumed and cannot be dispatched again. ``` -------------------------------- ### VoiceUDPSocket performIPDiscovery() Method Source: https://discord.js.org/docs/packages/voice/0.19.0/VoiceUDPSocket%3AClass Initiates IP discovery to determine the local address and port for the voice connection. Returns a Promise that resolves with the discovered SocketConfig. ```typescript performIPDiscovery( ssrc: number ) : Promise ``` -------------------------------- ### SSRCMap Constructor Source: https://discord.js.org/docs/packages/voice/0.19.0/SSRCMap%3AClass Initializes a new instance of the SSRCMap class. This class manages audio SSRCs and associated voice user data. ```typescript constructor() ``` -------------------------------- ### CreateAudioResourceOptions Interface Source: https://discord.js.org/docs/packages/voice/0.19.0/CreateAudioResourceOptions%3AInterface Options that are set when creating a new audio resource. ```APIDOC ## Interface: CreateAudioResourceOptions ### Description Options that are set when creating a new audio resource. ### Properties #### inlineVolume? : boolean Optional. Whether or not inline volume should be enabled. If enabled, you will be able to change the volume of the stream on-the-fly. However, this also increases the performance cost of playback. Defaults to `false`. #### inputType? : StreamType Optional. The type of the input stream. Defaults to `StreamType.Arbitrary`. #### metadata? : Metadata Optional. Optional metadata that can be attached to the resource (e.g. track title, random id). This is useful for identification purposes when the resource is passed around in events. See metadata. #### silencePaddingFrames? : number Optional. The number of silence frames to append to the end of the resource's audio stream, to prevent interpolation glitches. Defaults to 5. ``` -------------------------------- ### CreateVoiceConnectionOptions Interface Definition Source: https://discord.js.org/docs/packages/voice/0.19.0/CreateVoiceConnectionOptions%3AInterface Defines the structure for options when creating a voice connection. Includes optional parameters for adapter creation, DAVE encryption, debugging, and decryption failure tolerance. ```typescript export interface CreateVoiceConnectionOptions ``` -------------------------------- ### NetworkingReadyState Interface Source: https://discord.js.org/docs/packages/voice/0.19.0/NetworkingReadyState%3AInterface The state of a Networking instance when it has a fully established connection to a Discord voice server. ```APIDOC ## Interface: NetworkingReadyState ### Description The state that a Networking instance will be in when it has a fully established connection to a Discord voice server. ### Properties - **code** (NetworkingStatusCode.Ready) - The networking status code, indicating readiness. - **connectionData** (ConnectionData) - Data related to the established connection. - **connectionOptions** (ConnectionOptions) - Options used for the connection. - **dave**? (DAVESession | undefined) - Optional DAVE session information. - **preparedPacket**? (Buffer | undefined) - Optional prepared packet data. - **udp** (VoiceUDPSocket) - The UDP socket for voice communication. - **ws** (VoiceWebSocket) - The WebSocket connection for voice communication. ``` -------------------------------- ### DAVESession PrepareEpoch Method Source: https://discord.js.org/docs/packages/voice/0.19.0/DAVESession%3AClass Prepares the session for a new epoch with the provided data. ```typescript prepareEpoch( data: VoiceDavePrepareEpochData ) : void ``` -------------------------------- ### NetworkingSelectingProtocolState Interface Source: https://discord.js.org/docs/packages/voice/0.19.0/NetworkingSelectingProtocolState%3AInterface This interface defines the properties available in the NetworkingSelectingProtocolState, which is used during the audio protocol selection phase. ```APIDOC ## Interface: NetworkingSelectingProtocolState ### Description The state that a Networking instance will be in when selecting an encryption protocol for audio packets. ### Properties - **code** (NetworkingStatusCode.SelectingProtocol): The current networking status code, indicating the protocol selection phase. - **connectionData** (Pick): Contains data related to connected clients and the SSRC. - **connectionOptions** (ConnectionOptions): Options related to the network connection. - **udp** (VoiceUDPSocket): The UDP socket used for audio transmission. - **ws** (VoiceWebSocket): The WebSocket connection used for control messages. ``` -------------------------------- ### JoinConfig Interface Source: https://discord.js.org/docs/packages/voice/0.19.0/JoinConfig%3AInterface Defines the structure for joining a voice channel, including channel ID, group, guild ID, and self-mute/deaf status. ```APIDOC ## Interface: JoinConfig ### Description Represents the configuration object used when joining a voice channel. ### Properties - **channelId** (string | null): The ID of the voice channel to join. Can be null if not specified. - **group** (string): The group identifier for the voice channel. - **guildId** (string): The ID of the guild the voice channel belongs to. - **selfDeaf** (boolean): Whether the user should be self-deafened upon joining. - **selfMute** (boolean): Whether the user should be self-muted upon joining. ``` -------------------------------- ### Create Default Audio Receive Stream Options Source: https://discord.js.org/docs/packages/voice/0.19.0/createDefaultAudioReceiveStreamOptions%3AFunction This function creates default options for audio receiving streams. It is a utility function for setting up audio playback. ```typescript export declare function createDefaultAudioReceiveStreamOptions(): AudioReceiveStreamOptions; ``` -------------------------------- ### CreateAudioPlayerOptions Interface Source: https://discord.js.org/docs/packages/voice/0.19.0/CreateAudioPlayerOptions%3AInterface Options that can be passed when creating an audio player, used to specify its behavior. ```APIDOC ## Interface: CreateAudioPlayerOptions ### Description Options that can be passed when creating an audio player, used to specify its behavior. ### Properties #### behaviors? (object) Optional. Specifies the behavior of the audio player. - **maxMissedFrames** (number) - Optional. The maximum number of missed frames before the player stops. - **noSubscriber** (NoSubscriberBehavior) - Optional. The behavior when there is no subscriber. #### debug? (boolean) Optional. Enables debug logging for the audio player. ``` -------------------------------- ### CreateVoiceConnectionOptions Source: https://discord.js.org/docs/packages/voice/0.19.0/CreateVoiceConnectionOptions%3AInterface Options that can be provided when creating a voice connection. ```APIDOC ## Interface: CreateVoiceConnectionOptions ### Description The options that can be given when creating a voice connection. ### Properties #### adapterCreator : DiscordGatewayAdapterCreator #### daveEncryption? : boolean | undefined Optional. Whether to use the DAVE protocol for end-to-end encryption. Defaults to true. #### debug? : boolean | undefined Optional. If true, debug messages will be enabled for the voice connection and its related components. Defaults to false. #### decryptionFailureTolerance? : number | undefined Optional. The amount of consecutive decryption failures needed to try to re-initialize the end-to-end encrypted session to recover. Defaults to 24. ``` -------------------------------- ### Implement destroy() Method Source: https://discord.js.org/docs/packages/voice/0.19.0/DiscordGatewayAdapterImplementerMethods%3AInterface Implement this method to handle the safe destruction of the adapter when it's no longer needed by @discordjs/voice. ```typescript destroy(): void ``` -------------------------------- ### SSRCMap Constructor Source: https://discord.js.org/docs/packages/voice/0.19.0/SSRCMap%3AClass Constructs a new instance of the SSRCMap class. ```APIDOC ## constructor() Constructs a new instance of the `SSRCMap` class ``` -------------------------------- ### NetworkingOpeningWsState Interface Definition Source: https://discord.js.org/docs/packages/voice/0.19.0/NetworkingOpeningWsState%3AInterface Defines the initial state for WebSocket connections to Discord voice gateways. Instances are in this state during the opening phase of the connection. ```typescript export interface NetworkingOpeningWsState ``` -------------------------------- ### rejoin Source: https://discord.js.org/docs/packages/voice/0.19.0/VoiceConnection%3AClass Attempts to rejoin the voice channel. ```APIDOC ## rejoin(joinConfig?: Omit) Attempts to rejoin the voice channel. ### Parameters - **joinConfig** (Omit) - Optional. Configuration for rejoining, excluding group and guildId. ### Returns - `boolean` ``` -------------------------------- ### joinVoiceChannel Source: https://discord.js.org/docs/packages/voice/0.19.0/joinVoiceChannel%3AFunction Creates a VoiceConnection to a Discord voice channel. ```APIDOC ## joinVoiceChannel ### Description Creates a VoiceConnection to a Discord voice channel. ### Signature ```typescript export declare function joinVoiceChannel(options: CreateVoiceConnectionOptions & JoinVoiceChannelOptions): import("./VoiceConnection").VoiceConnection; ``` ### Parameters #### options - **options** (CreateVoiceConnectionOptions & JoinVoiceChannelOptions) - Required - The options for joining the voice channel. ``` -------------------------------- ### DiscordGatewayAdapterCreator Source: https://discord.js.org/docs/packages/voice/0.19.0/DiscordGatewayAdapterCreator%3ATypeAlias A function used to build adapters. It accepts a methods parameter that contains functions that can be called by the implementer when new data is received on its gateway connection. In return, the implementer will return some methods that the library can call - e.g. to send messages on the gateway, or to signal that the adapter can be removed. ```APIDOC ## Type Alias: DiscordGatewayAdapterCreator ### Description A function used to build adapters for the Discord gateway. It receives a set of methods from the library that can be invoked by the adapter's implementation when new data arrives on the gateway connection. In return, the implementer provides methods that the library can use, such as sending messages over the gateway or indicating that the adapter can be removed. ### Signature ```typescript (methods: DiscordGatewayAdapterLibraryMethods) => DiscordGatewayAdapterImplementerMethods ``` ### Parameters #### methods (DiscordGatewayAdapterLibraryMethods) - Description: Functions provided by the library that the implementer can call to interact with the gateway or signal events. ### Returns #### DiscordGatewayAdapterImplementerMethods - Description: Methods that the library can call to control the adapter, send data, or manage its lifecycle. ``` -------------------------------- ### ConnectionOptions Interface Source: https://discord.js.org/docs/packages/voice/0.19.0/ConnectionOptions%3AInterface Interface defining the properties required for Discord voice gateway connection. ```APIDOC ## Interface: ConnectionOptions Details required to connect to the Discord voice gateway. These details are first received on the main bot gateway, in the form of VOICE_SERVER_UPDATE and VOICE_STATE_UPDATE packets. ### Properties - **channelId** (string): The ID of the voice channel. - **endpoint** (string): The endpoint URL for the voice server. - **serverId** (string): The ID of the server. - **sessionId** (string): The session ID for the voice connection. - **token** (string): The authentication token for the voice connection. - **userId** (string): The ID of the user. ``` -------------------------------- ### Check if Audio Resource is Playable Source: https://discord.js.org/docs/packages/voice/0.19.0/AudioPlayer%3AClass Verifies if the currently loaded audio resource is readable and can be played. Returns true if playable, false otherwise. ```typescript checkPlayable() : boolean ``` -------------------------------- ### on Source: https://discord.js.org/docs/packages/voice/0.19.0/VoiceUDPSocket%3AClass Listens for specific events on the VoiceUDPSocket, such as errors. ```APIDOC ## on(event: 'error', listener: (error: Error) => void) Listens for the 'error' event. ### Parameters #### Path Parameters - **event** ('error') - The name of the event to listen for. - **listener** ((error: Error) => void) - The callback function to execute when the event is triggered. ### Returns - **this**: Returns the VoiceUDPSocket instance for chaining. ``` -------------------------------- ### Subscribe to Audio Player - VoiceConnection Source: https://discord.js.org/docs/packages/voice/0.19.0/VoiceConnection%3AClass Subscribes an AudioPlayer to this voice connection, enabling it to play audio. Returns the created subscription or undefined if subscription fails. ```typescript subscribe(player: AudioPlayer) : PlayerSubscription | undefined ``` -------------------------------- ### Configure Networking - VoiceConnection Source: https://discord.js.org/docs/packages/voice/0.19.0/VoiceConnection%3AClass Attempts to configure a networking instance for the voice connection. This method requires both packets to be present and will destroy any existing networking instance. ```typescript configureNetworking() : void ``` -------------------------------- ### AudioReceiveStream Constructor Source: https://discord.js.org/docs/packages/voice/0.19.0/AudioReceiveStream%3AClass Constructs a new instance of the AudioReceiveStream class. ```APIDOC ## constructor(options: AudioReceiveStreamOptions) ### Description Constructs a new instance of the `AudioReceiveStream` class. ### Parameters #### Path Parameters - **options** (AudioReceiveStreamOptions) - Required - Options for the AudioReceiveStream. ``` -------------------------------- ### Implement sendPayload() Method Source: https://discord.js.org/docs/packages/voice/0.19.0/DiscordGatewayAdapterImplementerMethods%3AInterface Implement this method to send payloads to the main Discord gateway connection. Returning false indicates the payload failed to send, which will cause the voice connection to disconnect. ```typescript sendPayload( payload: any ): boolean ``` -------------------------------- ### AudioPlayer.play Source: https://discord.js.org/docs/packages/voice/0.19.0/AudioPlayer%3AClass Plays a new audio resource on the player. If a resource is already playing, it will be destroyed and replaced. ```APIDOC ## play(resource: AudioResource) : void Plays a new resource on the player. If the player is already playing a resource, the existing resource is destroyed (it cannot be reused, even in another player) and is replaced with the new resource. ### Parameters * **resource** (AudioResource) - The audio resource to play. ``` -------------------------------- ### Inline Volume Option Source: https://discord.js.org/docs/packages/voice/0.19.0/CreateAudioResourceOptions%3AInterface Enables on-the-fly volume changes for audio streams. Note that enabling this increases performance costs. ```typescript inlineVolume? : boolean ``` -------------------------------- ### createDefaultAudioReceiveStreamOptions Source: https://discord.js.org/docs/packages/voice/0.19.0/createDefaultAudioReceiveStreamOptions%3AFunction Creates a default set of options for an audio receive stream. This is useful for initializing stream configurations with standard values. ```APIDOC ## Function: createDefaultAudioReceiveStreamOptions ### Description Generates default configuration options for an audio receive stream. ### Signature ```typescript export declare function createDefaultAudioReceiveStreamOptions(): AudioReceiveStreamOptions; ``` ### Returns - `AudioReceiveStreamOptions`: An object containing the default options for an audio receive stream. ``` -------------------------------- ### Networking State Source: https://discord.js.org/docs/packages/voice/0.19.0/Networking%3AClass The current state of the networking instance. ```APIDOC ## state : NetworkingState The current state of the networking instance. ``` -------------------------------- ### entersState Function Source: https://discord.js.org/docs/packages/voice/0.19.0/entersState%3AFunction Allows a voice connection a specified amount of time to enter a given state, otherwise rejects with an error. ```APIDOC ## entersState ### Description Allows a voice connection a specified amount of time to enter a given state, otherwise rejects with an error. ### Signature ```typescript export declare function entersState(target: VoiceConnection, status: VoiceConnectionStatus, timeoutOrSignal: AbortSignal | number): Promise; ``` ### Parameters #### target - **target** (VoiceConnection) - Required - The voice connection that we want to observe the state change for. #### status - **status** (VoiceConnectionStatus) - Required - The status that the voice connection should be in. #### timeoutOrSignal - **timeoutOrSignal** (AbortSignal | number) - Required - The maximum time we are allowing for this to occur, or a signal that will abort the operation. ``` -------------------------------- ### performIPDiscovery Source: https://discord.js.org/docs/packages/voice/0.19.0/VoiceUDPSocket%3AClass Performs IP discovery to determine the local address and port for the voice connection. ```APIDOC ## performIPDiscovery(ssrc: number) Performs IP discovery to discover the local address and port to be used for the voice connection. ### Parameters #### Path Parameters - **ssrc** (number) - The source synchronization identifier. ### Returns - **Promise**: A promise that resolves with the discovered socket configuration. ``` -------------------------------- ### VoiceReceiver Constructor Source: https://discord.js.org/docs/packages/voice/0.19.0/VoiceReceiver%3AClass Constructs a new instance of the VoiceReceiver class, attaching it to a given VoiceConnection. ```APIDOC ## constructor(voiceConnection: VoiceConnection) ### Description Constructs a new instance of the `VoiceReceiver` class. ### Parameters #### Path Parameters - **voiceConnection** (VoiceConnection) - Required - The VoiceConnection to attach to. ``` -------------------------------- ### Listen for SSRCMap Create Event Source: https://discord.js.org/docs/packages/voice/0.19.0/SSRCMap%3AClass Subscribes to the 'create' event emitted by the SSRCMap. This event fires when new voice user data is added to the map. ```typescript on('create', listener: (newData: VoiceUserData) => void): this ``` -------------------------------- ### destroy() Source: https://discord.js.org/docs/packages/voice/0.19.0/Networking%3AClass Destroys the Networking instance, transitioning it into the Closed state. ```APIDOC ## destroy() : void Destroys the Networking instance, transitioning it into the Closed state. ``` -------------------------------- ### ProbeInfo Interface Source: https://discord.js.org/docs/packages/voice/0.19.0/ProbeInfo%3AInterface This interface represents the information returned after probing an audio stream. It includes the readable audio stream and the recommended stream type. ```APIDOC ## Interface: ProbeInfo ### Description The resulting information after probing an audio stream. ### Properties - **stream** (Readable) - Required - The readable audio stream to use. You should use this rather than the input stream, as the probing function can sometimes read the input stream to its end and cause the stream to close. - **type** (StreamType) - Required - The recommended stream type for this audio stream. ``` -------------------------------- ### recoverFromInvalidTransition Source: https://discord.js.org/docs/packages/voice/0.19.0/DAVESession%3AClass Recover from an invalid transition by re-initializing. ```APIDOC ## recoverFromInvalidTransition(transitionId: number) : void Recover from an invalid transition by re-initializing. ``` -------------------------------- ### reinit Source: https://discord.js.org/docs/packages/voice/0.19.0/DAVESession%3AClass Re-initializes (or initializes) the underlying session. ```APIDOC ## reinit() : void Re-initializes (or initializes) the underlying session. ``` -------------------------------- ### AudioReceiveStream Methods Source: https://discord.js.org/docs/packages/voice/0.19.0/AudioReceiveStream%3AClass Methods available on the AudioReceiveStream class. ```APIDOC ## Methods ### _read() ### Description Internal method to read data from the stream. ### Returns - void ### push(buffer: Buffer | null) ### Description Pushes a buffer of audio data into the stream. ### Parameters #### Path Parameters - **buffer** (Buffer | null) - Required - The buffer to push. ### Returns - boolean - True if the buffer was accepted, false otherwise. ``` -------------------------------- ### VoiceUDPSocket Constructor Source: https://discord.js.org/docs/packages/voice/0.19.0/VoiceUDPSocket%3AClass Creates a new VoiceUDPSocket instance. Requires SocketConfig for the remote endpoint. ```typescript constructor( remote: SocketConfig ) ``` -------------------------------- ### JoinVoiceChannelOptions Interface Source: https://discord.js.org/docs/packages/voice/0.19.0/JoinVoiceChannelOptions%3AInterface Defines the structure for options when joining a voice channel. ```APIDOC ## Interface: JoinVoiceChannelOptions ### Description The options that can be given when joining a voice channel. ### Properties - **channelId** (string) - Required - The id of the Discord voice channel to join. - **group** (string) - Optional - An optional group identifier for the voice connection. - **guildId** (string) - Required - The id of the guild that the voice channel belongs to. - **selfDeaf** (boolean) - Optional - Whether to join the channel deafened (defaults to true). - **selfMute** (boolean) - Optional - Whether to join the channel muted (defaults to true). ``` -------------------------------- ### AudioPlayer.checkPlayable Source: https://discord.js.org/docs/packages/voice/0.19.0/AudioPlayer%3AClass Checks whether the underlying audio resource is currently playable (readable). ```APIDOC ## checkPlayable() : boolean Checks whether the underlying resource (if any) is playable (readable) ### Returns * `true` if the resource is playable, otherwise `false` ``` -------------------------------- ### JoinConfig Interface Definition Source: https://discord.js.org/docs/packages/voice/0.19.0/JoinConfig%3AInterface Defines the structure for voice channel join configurations. ```typescript export interface JoinConfig ``` -------------------------------- ### ConnectionOptions Interface Definition Source: https://discord.js.org/docs/packages/voice/0.19.0/ConnectionOptions%3AInterface Defines the structure for connection options required to connect to the Discord voice gateway. These options include channel ID, endpoint, server ID, session ID, token, and user ID. ```typescript export interface ConnectionOptions ``` -------------------------------- ### getGroups Source: https://discord.js.org/docs/packages/voice/0.19.0/getGroups%3AFunction Retrieves the map of group names to maps of voice connections. By default, all voice connections are created under the 'default' group. ```APIDOC ## getGroups ### Description Retrieves the map of group names to maps of voice connections. By default, all voice connections are created under the 'default' group. ### Returns The group map ### Code ```typescript export declare function getGroups(): Map>; ``` ``` -------------------------------- ### Version Variable Source: https://discord.js.org/docs/packages/voice/0.19.0/version%3AVariable The 'version' variable provides the current version of the @discordjs/voice package as a string. ```APIDOC ## Version Variable ### Description The `@discordjs/voice` version that you are currently using. ### Type `string` ### Example ```javascript import { version } from 'discord.js'; console.log(version); ``` ``` -------------------------------- ### VoiceConnectionStatus: Ready Source: https://discord.js.org/docs/packages/voice/0.19.0/VoiceConnectionStatus%3AEnum Indicates that a voice connection has been successfully established and is ready for use. ```typescript Ready = "ready" ``` -------------------------------- ### DAVESession ProcessProposals Method Source: https://discord.js.org/docs/packages/voice/0.19.0/DAVESession%3AClass Processes proposal payloads from the MLS group. Returns a payload to send back to the voice server, if any. ```typescript processProposals( payload: Buffer, connectedClients: Set ) : Buffer | undefined ``` -------------------------------- ### AudioPlayerError Constructor Source: https://discord.js.org/docs/packages/voice/0.19.0/AudioPlayerError%3AClass Constructs a new instance of the AudioPlayerError class. This error is emitted by an AudioPlayer and contains an attached resource to aid with debugging and identifying where the error came from. ```APIDOC ## constructor(error: Error, resource: AudioResource) ### Description Constructs a new instance of the `AudioPlayerError` class. ### Parameters - **error** (Error) - The original error that was thrown. - **resource** (AudioResource) - The audio resource associated with the player when the error occurred. ### Properties - **readonly resource** (AudioResource) - The resource associated with the audio player at the time the error was thrown. ``` -------------------------------- ### demuxProbe Source: https://discord.js.org/docs/packages/voice/0.19.0/demuxProbe%3AFunction Attempts to probe a readable stream to figure out whether it can be demuxed using an Ogg or WebM Opus demuxer. ```APIDOC ## function demuxProbe ### Description Attempts to probe a readable stream to figure out whether it can be demuxed using an Ogg or WebM Opus demuxer. ### Parameters #### Path Parameters - **stream** (Readable) - Required - The readable stream to probe - **probeSize** (number) - Optional - The number of bytes to attempt to read before giving up on the probe - **validator** (typeof validateDiscordOpusHead) - Optional - The Opus Head validator function ### Returns - **Promise** - A promise that resolves with probe information. ``` -------------------------------- ### DAVESession Constructor Source: https://discord.js.org/docs/packages/voice/0.19.0/DAVESession%3AClass Constructs a new instance of the DAVESession class. ```APIDOC ## constructor(protocolVersion: number, userId: string, channelId: string, options: DAVESessionOptions) Constructs a new instance of the `DAVESession` class. ``` -------------------------------- ### Networking Prepare Audio Packet Source: https://discord.js.org/docs/packages/voice/0.19.0/Networking%3AClass Prepares an Opus audio packet for transmission. This process involves adding metadata and encrypting the packet. The prepared packet is stored internally and can be dispatched later using dispatchAudio(). ```typescript prepareAudioPacket( opusPacket: Buffer ) : Buffer | undefined ``` -------------------------------- ### Dispatch Audio Packet - VoiceConnection Source: https://discord.js.org/docs/packages/voice/0.19.0/VoiceConnection%3AClass Dispatches the previously prepared audio packet, if one exists. ```typescript dispatchAudio() : boolean | undefined ``` -------------------------------- ### JoinVoiceChannelOptions Interface Definition Source: https://discord.js.org/docs/packages/voice/0.19.0/JoinVoiceChannelOptions%3AInterface Defines the structure for options when joining a voice channel. Includes channel ID, group, guild ID, and self-mute/deafen settings. ```typescript export interface JoinVoiceChannelOptions ``` -------------------------------- ### PlayerSubscription Properties Source: https://discord.js.org/docs/packages/voice/0.19.0/PlayerSubscription%3AClass Provides access to the properties of an existing PlayerSubscription instance. ```APIDOC ## Properties ### `connection` - **Type**: `VoiceConnection` - **Description**: The voice connection of this subscription. ### `player` - **Type**: `AudioPlayer` - **Description**: The audio player of this subscription. ``` -------------------------------- ### setSpeaking(speaking: boolean) Source: https://discord.js.org/docs/packages/voice/0.19.0/Networking%3AClass Sends a packet to the voice gateway indicating that the client has start/stopped sending audio. ```APIDOC ## setSpeaking( speaking: boolean ) : void Sends a packet to the voice gateway indicating that the client has start/stopped sending audio. ``` -------------------------------- ### AudioReceiveStreamOptions Interface Source: https://discord.js.org/docs/packages/voice/0.19.0/AudioReceiveStreamOptions%3AInterface The AudioReceiveStreamOptions interface extends the standard ReadableOptions, providing additional configuration for audio receiving streams. ```APIDOC ## Interface: AudioReceiveStreamOptions ### Description This interface extends `ReadableOptions` and is used for configuring audio receiving streams. ### Extends - `ReadableOptions` ### Properties This interface does not define any additional properties beyond those inherited from `ReadableOptions`. ### End Behavior #### Enum: EndBehavior This enum likely defines the behavior when an audio stream ends. Specific values are not detailed in the source. - `EndBehavior` (enum) ``` -------------------------------- ### VoiceWebSocket Methods Source: https://discord.js.org/docs/packages/voice/0.19.0/VoiceWebSocket%3AClass Methods available on the VoiceWebSocket class for managing the connection and sending data. ```APIDOC ## destroy() Destroys the VoiceWebSocket. The heartbeat interval is cleared, and the connection is closed. ### Returns * void ## onMessage(event: MessageEvent) Handles message events on the WebSocket. Attempts to JSON parse the messages and emit them as packets. Binary messages will be parsed and emitted. ### Parameters * **event** (MessageEvent) - The message event object. ### Returns * void ## sendBinaryMessage(opcode: VoiceOpcodes, payload: Buffer) Sends a binary message over the WebSocket. ### Parameters * **opcode** (VoiceOpcodes) - The opcode for the binary message. * **payload** (Buffer) - The binary payload to send. ### Returns * void ## sendPacket(packet: VoiceSendPayload) Sends a JSON-stringifiable packet over the WebSocket. ### Parameters * **packet** (VoiceSendPayload) - The packet to send. ### Returns * void ## setHeartbeatInterval(ms: number) Sets/clears an interval to send heartbeats over the WebSocket. ### Parameters * **ms** (number) - The interval in milliseconds. If 0, the interval is cleared. ### Returns * void ## on(event: 'error', listener: (error: Error) => void) Listens for the 'error' event on the VoiceWebSocket. ### Parameters * **event** ('error') - The name of the event to listen for. * **listener** ((error: Error) => void) - The callback function to execute when the error event is triggered. ### Returns * this ``` -------------------------------- ### subscribe Source: https://discord.js.org/docs/packages/voice/0.19.0/VoiceConnection%3AClass Subscribes to an audio player, allowing the player to play audio on this voice connection. ```APIDOC ## subscribe(player: AudioPlayer) Subscribes to an audio player, allowing the player to play audio on this voice connection. ### Parameters - **player** (AudioPlayer) - The audio player to subscribe. ### Returns - `PlayerSubscription | undefined` - The created subscription. ``` -------------------------------- ### AudioPlayerBufferingState Interface Source: https://discord.js.org/docs/packages/voice/0.19.0/AudioPlayerBufferingState%3AInterface Represents the state of an AudioPlayer when it is waiting for a resource to become readable. Once the resource is available, the AudioPlayer transitions to the Playing state. If the resource ends or errors before becoming readable, it reverts to the Idle state. ```APIDOC ## Interface: AudioPlayerBufferingState ### Description The state that an AudioPlayer is in when it is waiting for a resource to become readable. Once this happens, the AudioPlayer will enter the Playing state. If the resource ends/errors before this, then it will re-enter the Idle state. ### Properties - **onFailureCallback** : `() => void` A callback function to be executed if the buffering process fails. - **onReadableCallback** : `() => void` A callback function to be executed when the resource becomes readable. - **onStreamError** : `(error: Error) => void` A callback function to be executed if an error occurs during the stream processing. - **resource** : `AudioResource` The resource that the AudioPlayer is waiting for. - **status** : `AudioPlayerStatus.Buffering` Indicates that the AudioPlayer is currently in the buffering state. ``` -------------------------------- ### NetworkingReadyState Interface Definition Source: https://discord.js.org/docs/packages/voice/0.19.0/NetworkingReadyState%3AInterface Defines the structure of the NetworkingReadyState, indicating a successful connection to a Discord voice server. ```typescript export interface NetworkingReadyState ``` -------------------------------- ### destroy Source: https://discord.js.org/docs/packages/voice/0.19.0/DiscordGatewayAdapterLibraryMethods%3AInterface Call this when the adapter can no longer be used (e.g., due to a disconnect from the main gateway). ```APIDOC ## destroy() ### Description Call this when the adapter can no longer be used (e.g. due to a disconnect from the main gateway) ### Method void ### Parameters None ``` -------------------------------- ### Export DiscordGatewayAdapterImplementerMethods Interface Source: https://discord.js.org/docs/packages/voice/0.19.0/DiscordGatewayAdapterImplementerMethods%3AInterface This interface must be implemented by any class acting as a Discord gateway adapter. It defines the contract for interacting with the Discord gateway. ```typescript export interface DiscordGatewayAdapterImplementerMethods ``` -------------------------------- ### NoSubscriberBehavior: Stop Source: https://discord.js.org/docs/packages/voice/0.19.0/NoSubscriberBehavior%3AEnum Opt for 'stop' to immediately cease audio playback and transition the player to an 'Idle' state when no voice connections are detected. This ensures resources are released promptly. ```typescript Stop = "stop" ``` -------------------------------- ### Metadata Option Source: https://discord.js.org/docs/packages/voice/0.19.0/CreateAudioResourceOptions%3AInterface Attaches optional metadata to the audio resource for identification purposes in events. The type of metadata is generic and defined by the resource. ```typescript metadata? : Metadata ``` -------------------------------- ### DAVESession RecoverFromInvalidTransition Method Source: https://discord.js.org/docs/packages/voice/0.19.0/DAVESession%3AClass Recovers from an invalid transition by re-initializing the session. ```typescript recoverFromInvalidTransition( transitionId: number ) : void ``` -------------------------------- ### DAVESession Constructor Source: https://discord.js.org/docs/packages/voice/0.19.0/DAVESession%3AClass Constructs a new instance of the DAVESession class. Requires protocol version, user ID, channel ID, and session options. ```typescript constructor( protocolVersion: number, userId: string, channelId: string, options: DAVESessionOptions ) ``` -------------------------------- ### DiscordGatewayAdapterLibraryMethods Interface Definition Source: https://discord.js.org/docs/packages/voice/0.19.0/DiscordGatewayAdapterLibraryMethods%3AInterface Defines the structure for library methods provided to Discord gateway adapters. ```typescript export interface DiscordGatewayAdapterLibraryMethods ``` -------------------------------- ### Define ProbeInfo Interface Source: https://discord.js.org/docs/packages/voice/0.19.0/ProbeInfo%3AInterface Defines the ProbeInfo interface used for audio stream probing. It includes the audio stream and its recommended type. ```typescript export interface ProbeInfo ``` -------------------------------- ### onVoiceServerUpdate Source: https://discord.js.org/docs/packages/voice/0.19.0/DiscordGatewayAdapterLibraryMethods%3AInterface Call this when you receive a VOICE_SERVER_UPDATE payload that is relevant to the adapter. ```APIDOC ## onVoiceServerUpdate(data: GatewayVoiceServerUpdateDispatchData) ### Description Call this when you receive a VOICE_SERVER_UPDATE payload that is relevant to the adapter. ### Method void ### Parameters #### Request Body - **data** (GatewayVoiceServerUpdateDispatchData) - Required - The VOICE_SERVER_UPDATE payload data. ``` -------------------------------- ### SpeakingMap Class Source: https://discord.js.org/docs/packages/voice/0.19.0/SpeakingMap%3AClass Tracks the speaking states of users in a voice channel. ```APIDOC ## class SpeakingMap ### extends EventEmitter ``` export declare class SpeakingMap extends EventEmitter ``` ## constructor() Constructs a new instance of the `SpeakingMap` class ### static readonly DELAY : number The delay after a packet is received from a user until they're marked as not speaking anymore. ### readonly users : Map The currently speaking users, mapped to the milliseconds since UNIX epoch at which they started speaking. ### onPacket(userId: string) : void ### on(event: 'start', listener: (userId: string) => void) : this Emitted when a user starts speaking. ``` -------------------------------- ### AudioPlayer.on('error') Source: https://discord.js.org/docs/packages/voice/0.19.0/AudioPlayer%3AClass Emitted when an error occurs with the audio resource being played by the audio player. ```APIDOC ## on(event: 'error', listener: (error: AudioPlayerError) => void) : this Emitted when there is an error emitted from the audio resource played by the audio player ### Parameters * **event** ('error') - The event name. * **listener** ((error: AudioPlayerError) => void) - The callback function to execute when the error event is emitted. ``` -------------------------------- ### send Source: https://discord.js.org/docs/packages/voice/0.19.0/VoiceUDPSocket%3AClass Sends a Buffer to Discord over the UDP socket. ```APIDOC ## send(buffer: Buffer) Sends a buffer to Discord. ### Parameters #### Path Parameters - **buffer** (Buffer) - The buffer to send. ### Returns - **void**: This method does not return a value. ```