@discordjs/voice 0.18.1-dev.1732320741-0374079c6 → 0.19.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -8,8 +8,9 @@
8
8
  <a href="https://discord.gg/djs"><img src="https://img.shields.io/discord/222078108977594368?color=5865F2&logo=discord&logoColor=white" alt="Discord server" /></a>
9
9
  <a href="https://www.npmjs.com/package/@discordjs/voice"><img src="https://img.shields.io/npm/v/@discordjs/voice.svg?maxAge=3600" alt="npm version" /></a>
10
10
  <a href="https://www.npmjs.com/package/@discordjs/voice"><img src="https://img.shields.io/npm/dt/@discordjs/voice.svg?maxAge=3600" alt="npm downloads" /></a>
11
- <a href="https://github.com/discordjs/discord.js/actions"><img src="https://github.com/discordjs/discord.js/actions/workflows/test.yml/badge.svg" alt="Build status" /></a>
12
- <a href="https://codecov.io/gh/discordjs/discord.js" ><img src="https://codecov.io/gh/discordjs/discord.js/branch/main/graph/badge.svg?precision=2&flag=voice" alt="Code coverage" /></a>
11
+ <a href="https://github.com/discordjs/discord.js/actions"><img src="https://github.com/discordjs/discord.js/actions/workflows/tests.yml/badge.svg" alt="Build status" /></a>
12
+ <a href="https://github.com/discordjs/discord.js/commits/main/packages/voice"><img alt="Last commit." src="https://img.shields.io/github/last-commit/discordjs/discord.js?logo=github&logoColor=ffffff&path=packages%2Fvoice" /></a>
13
+ <a href="https://codecov.io/gh/discordjs/discord.js"><img src="https://codecov.io/gh/discordjs/discord.js/branch/main/graph/badge.svg?precision=2&flag=voice" alt="Code coverage" /></a>
13
14
  </p>
14
15
  <p>
15
16
  <a href="https://vercel.com/?utm_source=discordjs&utm_campaign=oss"><img src="https://raw.githubusercontent.com/discordjs/discord.js/main/.github/powered-by-vercel.svg" alt="Vercel" /></a>
@@ -24,7 +25,7 @@
24
25
  **Features:**
25
26
 
26
27
  - Send and receive\* audio in Discord voice-based channels
27
- - A strong focus on reliability and predictable behaviour
28
+ - A strong focus on reliability and predictable behavior
28
29
  - Horizontal scalability and libraries other than [discord.js](https://discord.js.org/) are supported with custom adapters
29
30
  - A robust audio processing system that can handle a wide range of audio sources
30
31
 
@@ -32,7 +33,7 @@
32
33
 
33
34
  ## Installation
34
35
 
35
- **Node.js 18 or newer is required.**
36
+ **Node.js 22.12.0 or newer is required.**
36
37
 
37
38
  ```sh
38
39
  npm install @discordjs/voice
@@ -81,7 +82,7 @@ The [voice-examples][voice-examples] repository contains examples on how to use
81
82
  - [Guide][guide] ([source][guide-source])
82
83
  Also see the v13 to v14 [Update Guide][guide-update], which includes updated and removed items from the library.
83
84
  - [discord.js Discord server][discord]
84
- - [Discord API Discord server][discord-api]
85
+ - [Discord Developers Discord server][discord-developers]
85
86
  - [GitHub][source]
86
87
  - [npm][npm]
87
88
  - [Related libraries][related-libs]
@@ -103,7 +104,7 @@ If you don't understand something in the documentation, you are experiencing pro
103
104
  [guide-source]: https://github.com/discordjs/guide
104
105
  [guide-update]: https://discordjs.guide/additional-info/changes-in-v14.html
105
106
  [discord]: https://discord.gg/djs
106
- [discord-api]: https://discord.gg/discord-api
107
+ [discord-developers]: https://discord.gg/discord-developers
107
108
  [source]: https://github.com/discordjs/discord.js/tree/main/packages/voice
108
109
  [npm]: https://www.npmjs.com/package/@discordjs/voice
109
110
  [related-libs]: https://discord.com/developers/docs/topics/community-resources#libraries
package/dist/index.d.mts CHANGED
@@ -2,6 +2,7 @@ import { Buffer } from 'node:buffer';
2
2
  import { EventEmitter } from 'node:events';
3
3
  import { Readable, ReadableOptions } from 'node:stream';
4
4
  import prism from 'prism-media';
5
+ import { VoiceDavePrepareTransitionData, VoiceDavePrepareEpochData, VoiceOpcodes, VoiceSendPayload, VoiceReceivePayload } from 'discord-api-types/voice/v8';
5
6
  import WebSocket, { MessageEvent } from 'ws';
6
7
  import { GatewayVoiceServerUpdateDispatchData, GatewayVoiceStateUpdateDispatchData } from 'discord-api-types/v10';
7
8
 
@@ -442,11 +443,11 @@ declare class AudioPlayer extends EventEmitter {
442
443
  private unsubscribe;
443
444
  /**
444
445
  * The state that the player is in.
446
+ *
447
+ * @remarks
448
+ * The setter will perform clean-up operations where necessary.
445
449
  */
446
450
  get state(): AudioPlayerState;
447
- /**
448
- * Sets a new state for the player, performing clean-up operations where necessary.
449
- */
450
451
  set state(newState: AudioPlayerState);
451
452
  /**
452
453
  * Plays a new resource on the player. If the player is already playing a resource, the existing resource is destroyed
@@ -556,6 +557,174 @@ declare function getVoiceConnections(group: string): Map<string, VoiceConnection
556
557
  */
557
558
  declare function getVoiceConnection(guildId: string, group?: string): VoiceConnection | undefined;
558
559
 
560
+ interface SessionMethods {
561
+ canPassthrough(userId: string): boolean;
562
+ decrypt(userId: string, mediaType: 0 | 1, packet: Buffer): Buffer;
563
+ encryptOpus(packet: Buffer): Buffer;
564
+ getSerializedKeyPackage(): Buffer;
565
+ getVerificationCode(userId: string): Promise<string>;
566
+ processCommit(commit: Buffer): void;
567
+ processProposals(optype: 0 | 1, proposals: Buffer, recognizedUserIds?: string[]): ProposalsResult;
568
+ processWelcome(welcome: Buffer): void;
569
+ ready: boolean;
570
+ reinit(protocolVersion: number, userId: string, channelId: string): void;
571
+ reset(): void;
572
+ setExternalSender(externalSender: Buffer): void;
573
+ setPassthroughMode(passthrough: boolean, expiry: number): void;
574
+ voicePrivacyCode: string;
575
+ }
576
+ interface ProposalsResult {
577
+ commit?: Buffer;
578
+ welcome?: Buffer;
579
+ }
580
+ interface TransitionResult {
581
+ success: boolean;
582
+ transitionId: number;
583
+ }
584
+ /**
585
+ * Options that dictate the session behavior.
586
+ */
587
+ interface DAVESessionOptions {
588
+ decryptionFailureTolerance?: number | undefined;
589
+ }
590
+ interface DAVESession extends EventEmitter {
591
+ on(event: 'error', listener: (error: Error) => void): this;
592
+ on(event: 'debug', listener: (message: string) => void): this;
593
+ on(event: 'keyPackage', listener: (message: Buffer) => void): this;
594
+ on(event: 'invalidateTransition', listener: (transitionId: number) => void): this;
595
+ }
596
+ /**
597
+ * Manages the DAVE protocol group session.
598
+ */
599
+ declare class DAVESession extends EventEmitter {
600
+ /**
601
+ * The channel id represented by this session.
602
+ */
603
+ channelId: string;
604
+ /**
605
+ * The user id represented by this session.
606
+ */
607
+ userId: string;
608
+ /**
609
+ * The protocol version being used.
610
+ */
611
+ protocolVersion: number;
612
+ /**
613
+ * The last transition id executed.
614
+ */
615
+ lastTransitionId?: number | undefined;
616
+ /**
617
+ * The pending transition.
618
+ */
619
+ private pendingTransition?;
620
+ /**
621
+ * Whether this session was downgraded previously.
622
+ */
623
+ private downgraded;
624
+ /**
625
+ * The amount of consecutive failures encountered when decrypting.
626
+ */
627
+ private consecutiveFailures;
628
+ /**
629
+ * The amount of consecutive failures needed to attempt to recover.
630
+ */
631
+ private readonly failureTolerance;
632
+ /**
633
+ * Whether this session is currently re-initializing due to an invalid transition.
634
+ */
635
+ reinitializing: boolean;
636
+ /**
637
+ * The underlying DAVE Session of this wrapper.
638
+ */
639
+ session: SessionMethods | undefined;
640
+ constructor(protocolVersion: number, userId: string, channelId: string, options: DAVESessionOptions);
641
+ /**
642
+ * The current voice privacy code of the session. Will be `null` if there is no session.
643
+ */
644
+ get voicePrivacyCode(): string | null;
645
+ /**
646
+ * Gets the verification code for a user in the session.
647
+ *
648
+ * @throws Will throw if there is not an active session or the user id provided is invalid or not in the session.
649
+ */
650
+ getVerificationCode(userId: string): Promise<string>;
651
+ /**
652
+ * Re-initializes (or initializes) the underlying session.
653
+ */
654
+ reinit(): void;
655
+ /**
656
+ * Set the external sender for this session.
657
+ *
658
+ * @param externalSender - The external sender
659
+ */
660
+ setExternalSender(externalSender: Buffer): void;
661
+ /**
662
+ * Prepare for a transition.
663
+ *
664
+ * @param data - The transition data
665
+ * @returns Whether we should signal to the voice server that we are ready
666
+ */
667
+ prepareTransition(data: VoiceDavePrepareTransitionData): boolean;
668
+ /**
669
+ * Execute a transition.
670
+ *
671
+ * @param transitionId - The transition id to execute on
672
+ */
673
+ executeTransition(transitionId: number): boolean | undefined;
674
+ /**
675
+ * Prepare for a new epoch.
676
+ *
677
+ * @param data - The epoch data
678
+ */
679
+ prepareEpoch(data: VoiceDavePrepareEpochData): void;
680
+ /**
681
+ * Recover from an invalid transition by re-initializing.
682
+ *
683
+ * @param transitionId - The transition id to invalidate
684
+ */
685
+ recoverFromInvalidTransition(transitionId: number): void;
686
+ /**
687
+ * Processes proposals from the MLS group.
688
+ *
689
+ * @param payload - The binary message payload
690
+ * @param connectedClients - The set of connected client IDs
691
+ * @returns The payload to send back to the voice server, if there is one
692
+ */
693
+ processProposals(payload: Buffer, connectedClients: Set<string>): Buffer | undefined;
694
+ /**
695
+ * Processes a commit from the MLS group.
696
+ *
697
+ * @param payload - The payload
698
+ * @returns The transaction id and whether it was successful
699
+ */
700
+ processCommit(payload: Buffer): TransitionResult;
701
+ /**
702
+ * Processes a welcome from the MLS group.
703
+ *
704
+ * @param payload - The payload
705
+ * @returns The transaction id and whether it was successful
706
+ */
707
+ processWelcome(payload: Buffer): TransitionResult;
708
+ /**
709
+ * Encrypt a packet using end-to-end encryption.
710
+ *
711
+ * @param packet - The packet to encrypt
712
+ */
713
+ encrypt(packet: Buffer): Buffer;
714
+ /**
715
+ * Decrypt a packet using end-to-end encryption.
716
+ *
717
+ * @param packet - The packet to decrypt
718
+ * @param userId - The user id that sent the packet
719
+ * @returns The decrypted packet, or `null` if the decryption failed but should be ignored
720
+ */
721
+ decrypt(packet: Buffer, userId: string): Buffer | null;
722
+ /**
723
+ * Resets the session.
724
+ */
725
+ destroy(): void;
726
+ }
727
+
559
728
  /**
560
729
  * Stores an IP address and port. Used to store socket details for the local client as well as
561
730
  * for Discord.
@@ -634,6 +803,14 @@ declare class VoiceUDPSocket extends EventEmitter {
634
803
  performIPDiscovery(ssrc: number): Promise<SocketConfig>;
635
804
  }
636
805
 
806
+ /**
807
+ * A binary WebSocket message.
808
+ */
809
+ interface BinaryWebSocketMessage {
810
+ op: VoiceOpcodes;
811
+ payload: Buffer;
812
+ seq: number;
813
+ }
637
814
  interface VoiceWebSocket extends EventEmitter {
638
815
  on(event: 'error', listener: (error: Error) => void): this;
639
816
  on(event: 'open', listener: (event: WebSocket.Event) => void): this;
@@ -650,6 +827,12 @@ interface VoiceWebSocket extends EventEmitter {
650
827
  * @eventProperty
651
828
  */
652
829
  on(event: 'packet', listener: (packet: any) => void): this;
830
+ /**
831
+ * Binary message event.
832
+ *
833
+ * @eventProperty
834
+ */
835
+ on(event: 'binary', listener: (message: BinaryWebSocketMessage) => void): this;
653
836
  }
654
837
  /**
655
838
  * An extension of the WebSocket class to provide helper functionality when interacting
@@ -678,6 +861,10 @@ declare class VoiceWebSocket extends EventEmitter {
678
861
  * The last recorded ping.
679
862
  */
680
863
  ping?: number;
864
+ /**
865
+ * The last sequence number acknowledged from Discord. Will be `-1` if no sequence numbered messages have been received.
866
+ */
867
+ sequence: number;
681
868
  /**
682
869
  * The debug logger function, if debugging is enabled.
683
870
  */
@@ -698,7 +885,7 @@ declare class VoiceWebSocket extends EventEmitter {
698
885
  destroy(): void;
699
886
  /**
700
887
  * Handles message events on the WebSocket. Attempts to JSON parse the messages and emit them
701
- * as packets.
888
+ * as packets. Binary messages will be parsed and emitted.
702
889
  *
703
890
  * @param event - The message event
704
891
  */
@@ -708,7 +895,14 @@ declare class VoiceWebSocket extends EventEmitter {
708
895
  *
709
896
  * @param packet - The packet to send
710
897
  */
711
- sendPacket(packet: any): void;
898
+ sendPacket(packet: VoiceSendPayload): void;
899
+ /**
900
+ * Sends a binary message over the WebSocket.
901
+ *
902
+ * @param opcode - The opcode to use
903
+ * @param payload - The payload to send
904
+ */
905
+ sendBinaryMessage(opcode: VoiceOpcodes, payload: Buffer): void;
712
906
  /**
713
907
  * Sends a heartbeat over the WebSocket.
714
908
  */
@@ -758,7 +952,7 @@ interface NetworkingIdentifyingState {
758
952
  */
759
953
  interface NetworkingUdpHandshakingState {
760
954
  code: NetworkingStatusCode.UdpHandshaking;
761
- connectionData: Pick<ConnectionData, 'ssrc'>;
955
+ connectionData: Pick<ConnectionData, 'connectedClients' | 'ssrc'>;
762
956
  connectionOptions: ConnectionOptions;
763
957
  udp: VoiceUDPSocket;
764
958
  ws: VoiceWebSocket;
@@ -768,7 +962,7 @@ interface NetworkingUdpHandshakingState {
768
962
  */
769
963
  interface NetworkingSelectingProtocolState {
770
964
  code: NetworkingStatusCode.SelectingProtocol;
771
- connectionData: Pick<ConnectionData, 'ssrc'>;
965
+ connectionData: Pick<ConnectionData, 'connectedClients' | 'ssrc'>;
772
966
  connectionOptions: ConnectionOptions;
773
967
  udp: VoiceUDPSocket;
774
968
  ws: VoiceWebSocket;
@@ -781,6 +975,7 @@ interface NetworkingReadyState {
781
975
  code: NetworkingStatusCode.Ready;
782
976
  connectionData: ConnectionData;
783
977
  connectionOptions: ConnectionOptions;
978
+ dave?: DAVESession | undefined;
784
979
  preparedPacket?: Buffer | undefined;
785
980
  udp: VoiceUDPSocket;
786
981
  ws: VoiceWebSocket;
@@ -793,6 +988,7 @@ interface NetworkingResumingState {
793
988
  code: NetworkingStatusCode.Resuming;
794
989
  connectionData: ConnectionData;
795
990
  connectionOptions: ConnectionOptions;
991
+ dave?: DAVESession | undefined;
796
992
  preparedPacket?: Buffer | undefined;
797
993
  udp: VoiceUDPSocket;
798
994
  ws: VoiceWebSocket;
@@ -814,6 +1010,7 @@ type NetworkingState = NetworkingClosedState | NetworkingIdentifyingState | Netw
814
1010
  * and VOICE_STATE_UPDATE packets.
815
1011
  */
816
1012
  interface ConnectionOptions {
1013
+ channelId: string;
817
1014
  endpoint: string;
818
1015
  serverId: string;
819
1016
  sessionId: string;
@@ -825,6 +1022,7 @@ interface ConnectionOptions {
825
1022
  * the connection, timing information for playback of streams.
826
1023
  */
827
1024
  interface ConnectionData {
1025
+ connectedClients: Set<string>;
828
1026
  encryptionMode: string;
829
1027
  nonce: number;
830
1028
  nonceBuffer: Buffer;
@@ -835,6 +1033,14 @@ interface ConnectionData {
835
1033
  ssrc: number;
836
1034
  timestamp: number;
837
1035
  }
1036
+ /**
1037
+ * Options for networking that dictate behavior.
1038
+ */
1039
+ interface NetworkingOptions {
1040
+ daveEncryption?: boolean | undefined;
1041
+ debug?: boolean | undefined;
1042
+ decryptionFailureTolerance?: number | undefined;
1043
+ }
838
1044
  interface Networking extends EventEmitter {
839
1045
  /**
840
1046
  * Debug event for Networking.
@@ -845,6 +1051,7 @@ interface Networking extends EventEmitter {
845
1051
  on(event: 'error', listener: (error: Error) => void): this;
846
1052
  on(event: 'stateChange', listener: (oldState: NetworkingState, newState: NetworkingState) => void): this;
847
1053
  on(event: 'close', listener: (code: number) => void): this;
1054
+ on(event: 'transitioned', listener: (transitionId: number) => void): this;
848
1055
  }
849
1056
  /**
850
1057
  * Manages the networking required to maintain a voice connection and dispatch audio packets
@@ -855,30 +1062,41 @@ declare class Networking extends EventEmitter {
855
1062
  * The debug logger function, if debugging is enabled.
856
1063
  */
857
1064
  private readonly debug;
1065
+ /**
1066
+ * The options used to create this Networking instance.
1067
+ */
1068
+ private readonly options;
858
1069
  /**
859
1070
  * Creates a new Networking instance.
860
1071
  */
861
- constructor(options: ConnectionOptions, debug: boolean);
1072
+ constructor(connectionOptions: ConnectionOptions, options: NetworkingOptions);
862
1073
  /**
863
1074
  * Destroys the Networking instance, transitioning it into the Closed state.
864
1075
  */
865
1076
  destroy(): void;
866
1077
  /**
867
1078
  * The current state of the networking instance.
1079
+ *
1080
+ * @remarks
1081
+ * The setter will perform clean-up operations where necessary.
868
1082
  */
869
1083
  get state(): NetworkingState;
870
- /**
871
- * Sets a new state for the networking instance, performing clean-up operations where necessary.
872
- */
873
1084
  set state(newState: NetworkingState);
874
1085
  /**
875
1086
  * Creates a new WebSocket to a Discord Voice gateway.
876
1087
  *
877
1088
  * @param endpoint - The endpoint to connect to
1089
+ * @param lastSequence - The last sequence to set for this WebSocket
878
1090
  */
879
1091
  private createWebSocket;
880
1092
  /**
881
- * Propagates errors from the children VoiceWebSocket and VoiceUDPSocket.
1093
+ * Creates a new DAVE session for this voice connection if we can create one.
1094
+ *
1095
+ * @param protocolVersion - The protocol version to use
1096
+ */
1097
+ private createDaveSession;
1098
+ /**
1099
+ * Propagates errors from the children VoiceWebSocket, VoiceUDPSocket and DAVESession.
882
1100
  *
883
1101
  * @param error - The error that was emitted by a child
884
1102
  */
@@ -906,6 +1124,24 @@ declare class Networking extends EventEmitter {
906
1124
  * @param packet - The received packet
907
1125
  */
908
1126
  private onWsPacket;
1127
+ /**
1128
+ * Called when a binary message is received on the connection's WebSocket.
1129
+ *
1130
+ * @param message - The received message
1131
+ */
1132
+ private onWsBinary;
1133
+ /**
1134
+ * Called when a new key package is ready to be sent to the voice server.
1135
+ *
1136
+ * @param keyPackage - The new key package
1137
+ */
1138
+ private onDaveKeyPackage;
1139
+ /**
1140
+ * Called when the DAVE session wants to invalidate their transition and re-initialize.
1141
+ *
1142
+ * @param transitionId - The transition to invalidate
1143
+ */
1144
+ private onDaveInvalidateTransition;
909
1145
  /**
910
1146
  * Propagates debug messages from the child WebSocket.
911
1147
  *
@@ -918,6 +1154,12 @@ declare class Networking extends EventEmitter {
918
1154
  * @param message - The emitted debug message
919
1155
  */
920
1156
  private onUdpDebug;
1157
+ /**
1158
+ * Propagates debug messages from the child DAVESession.
1159
+ *
1160
+ * @param message - The emitted debug message
1161
+ */
1162
+ private onDaveDebug;
921
1163
  /**
922
1164
  * Prepares an Opus packet for playback. This includes attaching metadata to it and encrypting it.
923
1165
  * It will be stored within the instance, and can be played by dispatchAudio()
@@ -953,6 +1195,7 @@ declare class Networking extends EventEmitter {
953
1195
  *
954
1196
  * @param opusPacket - The Opus packet to prepare
955
1197
  * @param connectionData - The current connection data of the instance
1198
+ * @param daveSession - The DAVE session to use for encryption
956
1199
  */
957
1200
  private createAudioPacket;
958
1201
  /**
@@ -960,6 +1203,7 @@ declare class Networking extends EventEmitter {
960
1203
  *
961
1204
  * @param opusPacket - The Opus packet to encrypt
962
1205
  * @param connectionData - The current connection data of the instance
1206
+ * @param daveSession - The DAVE session to use for encryption
963
1207
  */
964
1208
  private encryptOpusPacket;
965
1209
  }
@@ -1001,7 +1245,7 @@ declare class AudioReceiveStream extends Readable {
1001
1245
  */
1002
1246
  readonly end: EndBehavior;
1003
1247
  private endTimeout?;
1004
- constructor({ end, ...options }: AudioReceiveStreamOptions);
1248
+ constructor(options: AudioReceiveStreamOptions);
1005
1249
  push(buffer: Buffer | null): boolean;
1006
1250
  private renewEndTimeout;
1007
1251
  _read(): void;
@@ -1128,7 +1372,7 @@ declare class VoiceReceiver {
1128
1372
  * @param packet - The received packet
1129
1373
  * @internal
1130
1374
  */
1131
- onWsPacket(packet: any): void;
1375
+ onWsPacket(packet: VoiceReceivePayload): void;
1132
1376
  private decrypt;
1133
1377
  /**
1134
1378
  * Parses an audio packet, decrypting it to yield an Opus packet.
@@ -1137,6 +1381,7 @@ declare class VoiceReceiver {
1137
1381
  * @param mode - The encryption mode
1138
1382
  * @param nonce - The nonce buffer used by the connection for encryption
1139
1383
  * @param secretKey - The secret key used by the connection for encryption
1384
+ * @param userId - The user id that sent the packet
1140
1385
  * @returns The parsed Opus packet
1141
1386
  */
1142
1387
  private parsePacket;
@@ -1341,6 +1586,12 @@ interface VoiceConnection extends EventEmitter {
1341
1586
  * @eventProperty
1342
1587
  */
1343
1588
  on(event: 'stateChange', listener: (oldState: VoiceConnectionState, newState: VoiceConnectionState) => void): this;
1589
+ /**
1590
+ * Emitted when the end-to-end encrypted session has transitioned
1591
+ *
1592
+ * @eventProperty
1593
+ */
1594
+ on(event: 'transitioned', listener: (transitionId: number) => void): this;
1344
1595
  /**
1345
1596
  * Emitted when the state of the voice connection changes to a specific status
1346
1597
  *
@@ -1383,6 +1634,10 @@ declare class VoiceConnection extends EventEmitter {
1383
1634
  * The debug logger function, if debugging is enabled.
1384
1635
  */
1385
1636
  private readonly debug;
1637
+ /**
1638
+ * The options used to create this voice connection.
1639
+ */
1640
+ private readonly options;
1386
1641
  /**
1387
1642
  * Creates a new voice connection.
1388
1643
  *
@@ -1392,11 +1647,11 @@ declare class VoiceConnection extends EventEmitter {
1392
1647
  constructor(joinConfig: JoinConfig, options: CreateVoiceConnectionOptions);
1393
1648
  /**
1394
1649
  * The current state of the voice connection.
1650
+ *
1651
+ * @remarks
1652
+ * The setter will perform clean-up operations where necessary.
1395
1653
  */
1396
1654
  get state(): VoiceConnectionState;
1397
- /**
1398
- * Updates the state of the voice connection, performing clean-up operations where necessary.
1399
- */
1400
1655
  set state(newState: VoiceConnectionState);
1401
1656
  /**
1402
1657
  * Registers a `VOICE_SERVER_UPDATE` packet to the voice connection. This will cause it to reconnect using the
@@ -1463,6 +1718,12 @@ declare class VoiceConnection extends EventEmitter {
1463
1718
  * @param message - The debug message to propagate
1464
1719
  */
1465
1720
  private onNetworkingDebug;
1721
+ /**
1722
+ * Propagates transitions from the underlying network instance.
1723
+ *
1724
+ * @param transitionId - The transition id
1725
+ */
1726
+ private onNetworkingTransitioned;
1466
1727
  /**
1467
1728
  * Prepares an audio packet for dispatch.
1468
1729
  *
@@ -1530,6 +1791,20 @@ declare class VoiceConnection extends EventEmitter {
1530
1791
  ws: number | undefined;
1531
1792
  udp: number | undefined;
1532
1793
  };
1794
+ /**
1795
+ * The current voice privacy code of the encrypted session.
1796
+ *
1797
+ * @remarks
1798
+ * For this data to be available, the VoiceConnection must be in the Ready state,
1799
+ * and the connection would have to be end-to-end encrypted.
1800
+ */
1801
+ get voicePrivacyCode(): string | undefined;
1802
+ /**
1803
+ * Gets the verification code for a user in the session.
1804
+ *
1805
+ * @throws Will throw if end-to-end encryption is not on or if the user id provided is not in the session.
1806
+ */
1807
+ getVerificationCode(userId: string): Promise<string>;
1533
1808
  /**
1534
1809
  * Called when a subscription of this voice connection to an audio player is removed.
1535
1810
  *
@@ -1543,11 +1818,20 @@ declare class VoiceConnection extends EventEmitter {
1543
1818
  */
1544
1819
  interface CreateVoiceConnectionOptions {
1545
1820
  adapterCreator: DiscordGatewayAdapterCreator;
1821
+ /**
1822
+ * Whether to use the DAVE protocol for end-to-end encryption. Defaults to true.
1823
+ */
1824
+ daveEncryption?: boolean | undefined;
1546
1825
  /**
1547
1826
  * If true, debug messages will be enabled for the voice connection and its
1548
1827
  * related components. Defaults to false.
1549
1828
  */
1550
1829
  debug?: boolean | undefined;
1830
+ /**
1831
+ * The amount of consecutive decryption failures needed to try to
1832
+ * re-initialize the end-to-end encrypted session to recover. Defaults to 24.
1833
+ */
1834
+ decryptionFailureTolerance?: number | undefined;
1551
1835
  }
1552
1836
  /**
1553
1837
  * The options that can be given when joining a voice channel.
@@ -1641,4 +1925,4 @@ declare function demuxProbe(stream: Readable, probeSize?: number, validator?: ty
1641
1925
  */
1642
1926
  declare const version: string;
1643
1927
 
1644
- export { AudioPlayer, type AudioPlayerBufferingState, AudioPlayerError, type AudioPlayerIdleState, type AudioPlayerPausedState, type AudioPlayerPlayingState, type AudioPlayerState, AudioPlayerStatus, AudioReceiveStream, type AudioReceiveStreamOptions, AudioResource, type CreateAudioPlayerOptions, type CreateAudioResourceOptions, type CreateVoiceConnectionOptions, type DiscordGatewayAdapterCreator, type DiscordGatewayAdapterImplementerMethods, type DiscordGatewayAdapterLibraryMethods, type EndBehavior, EndBehaviorType, type JoinConfig, type JoinVoiceChannelOptions, NoSubscriberBehavior, PlayerSubscription, type ProbeInfo, SSRCMap, SpeakingMap, StreamType, VoiceConnection, type VoiceConnectionConnectingState, type VoiceConnectionDestroyedState, VoiceConnectionDisconnectReason, type VoiceConnectionDisconnectedBaseState, type VoiceConnectionDisconnectedOtherState, type VoiceConnectionDisconnectedState, type VoiceConnectionDisconnectedWebSocketState, type VoiceConnectionReadyState, type VoiceConnectionSignallingState, type VoiceConnectionState, VoiceConnectionStatus, VoiceReceiver, type VoiceUserData, createAudioPlayer, createAudioResource, createDefaultAudioReceiveStreamOptions, demuxProbe, entersState, generateDependencyReport, getGroups, getVoiceConnection, getVoiceConnections, joinVoiceChannel, validateDiscordOpusHead, version };
1928
+ export { AudioPlayer, type AudioPlayerBufferingState, AudioPlayerError, type AudioPlayerIdleState, type AudioPlayerPausedState, type AudioPlayerPlayingState, type AudioPlayerState, AudioPlayerStatus, AudioReceiveStream, type AudioReceiveStreamOptions, AudioResource, type ConnectionData, type ConnectionOptions, type CreateAudioPlayerOptions, type CreateAudioResourceOptions, type CreateVoiceConnectionOptions, DAVESession, type DiscordGatewayAdapterCreator, type DiscordGatewayAdapterImplementerMethods, type DiscordGatewayAdapterLibraryMethods, type Edge, type EndBehavior, EndBehaviorType, type JoinConfig, type JoinVoiceChannelOptions, Networking, type NetworkingClosedState, type NetworkingIdentifyingState, type NetworkingOpeningWsState, type NetworkingReadyState, type NetworkingResumingState, type NetworkingSelectingProtocolState, type NetworkingState, NetworkingStatusCode, type NetworkingUdpHandshakingState, NoSubscriberBehavior, Node, PlayerSubscription, type ProbeInfo, SSRCMap, type SocketConfig, SpeakingMap, StreamType, TransformerType, VoiceConnection, type VoiceConnectionConnectingState, type VoiceConnectionDestroyedState, VoiceConnectionDisconnectReason, type VoiceConnectionDisconnectedBaseState, type VoiceConnectionDisconnectedOtherState, type VoiceConnectionDisconnectedState, type VoiceConnectionDisconnectedWebSocketState, type VoiceConnectionReadyState, type VoiceConnectionSignallingState, type VoiceConnectionState, VoiceConnectionStatus, VoiceReceiver, VoiceUDPSocket, type VoiceUserData, VoiceWebSocket, createAudioPlayer, createAudioResource, createDefaultAudioReceiveStreamOptions, demuxProbe, entersState, generateDependencyReport, getGroups, getVoiceConnection, getVoiceConnections, joinVoiceChannel, validateDiscordOpusHead, version };