@discordjs/voice 1.0.0-dev.1748650419-ef2c1bfa7 → 1.0.0-dev.1748909640-d40ceedad

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/dist/index.d.mts CHANGED
@@ -678,6 +678,10 @@ declare class VoiceWebSocket extends EventEmitter {
678
678
  * The last recorded ping.
679
679
  */
680
680
  ping?: number;
681
+ /**
682
+ * The last sequence number acknowledged from Discord. Will be `-1` if no sequence numbered messages have been received.
683
+ */
684
+ sequence: number;
681
685
  /**
682
686
  * The debug logger function, if debugging is enabled.
683
687
  */
@@ -875,6 +879,7 @@ declare class Networking extends EventEmitter {
875
879
  * Creates a new WebSocket to a Discord Voice gateway.
876
880
  *
877
881
  * @param endpoint - The endpoint to connect to
882
+ * @param lastSequence - The last sequence to set for this WebSocket
878
883
  */
879
884
  private createWebSocket;
880
885
  /**
@@ -1001,7 +1006,7 @@ declare class AudioReceiveStream extends Readable {
1001
1006
  */
1002
1007
  readonly end: EndBehavior;
1003
1008
  private endTimeout?;
1004
- constructor({ end, ...options }: AudioReceiveStreamOptions);
1009
+ constructor(options: AudioReceiveStreamOptions);
1005
1010
  push(buffer: Buffer | null): boolean;
1006
1011
  private renewEndTimeout;
1007
1012
  _read(): void;
package/dist/index.d.ts CHANGED
@@ -678,6 +678,10 @@ declare class VoiceWebSocket extends EventEmitter {
678
678
  * The last recorded ping.
679
679
  */
680
680
  ping?: number;
681
+ /**
682
+ * The last sequence number acknowledged from Discord. Will be `-1` if no sequence numbered messages have been received.
683
+ */
684
+ sequence: number;
681
685
  /**
682
686
  * The debug logger function, if debugging is enabled.
683
687
  */
@@ -875,6 +879,7 @@ declare class Networking extends EventEmitter {
875
879
  * Creates a new WebSocket to a Discord Voice gateway.
876
880
  *
877
881
  * @param endpoint - The endpoint to connect to
882
+ * @param lastSequence - The last sequence to set for this WebSocket
878
883
  */
879
884
  private createWebSocket;
880
885
  /**
@@ -1001,7 +1006,7 @@ declare class AudioReceiveStream extends Readable {
1001
1006
  */
1002
1007
  readonly end: EndBehavior;
1003
1008
  private endTimeout?;
1004
- constructor({ end, ...options }: AudioReceiveStreamOptions);
1009
+ constructor(options: AudioReceiveStreamOptions);
1005
1010
  push(buffer: Buffer | null): boolean;
1006
1011
  private renewEndTimeout;
1007
1012
  _read(): void;
package/dist/index.js CHANGED
@@ -408,6 +408,10 @@ var VoiceWebSocket = class extends import_node_events2.EventEmitter {
408
408
  * The last recorded ping.
409
409
  */
410
410
  ping;
411
+ /**
412
+ * The last sequence number acknowledged from Discord. Will be `-1` if no sequence numbered messages have been received.
413
+ */
414
+ sequence = -1;
411
415
  /**
412
416
  * The debug logger function, if debugging is enabled.
413
417
  */
@@ -462,6 +466,9 @@ var VoiceWebSocket = class extends import_node_events2.EventEmitter {
462
466
  this.emit("error", err);
463
467
  return;
464
468
  }
469
+ if (packet.seq) {
470
+ this.sequence = packet.seq;
471
+ }
465
472
  if (packet.op === import_v4.VoiceOpcodes.HeartbeatAck) {
466
473
  this.lastHeartbeatAck = Date.now();
467
474
  this.missedHeartbeats = 0;
@@ -494,7 +501,11 @@ var VoiceWebSocket = class extends import_node_events2.EventEmitter {
494
501
  this.sendPacket({
495
502
  op: import_v4.VoiceOpcodes.Heartbeat,
496
503
  // eslint-disable-next-line id-length
497
- d: nonce2
504
+ d: {
505
+ // eslint-disable-next-line id-length
506
+ t: nonce2,
507
+ seq_ack: this.sequence
508
+ }
498
509
  });
499
510
  }
500
511
  /**
@@ -632,9 +643,13 @@ to ${stringifyState(newState)}`);
632
643
  * Creates a new WebSocket to a Discord Voice gateway.
633
644
  *
634
645
  * @param endpoint - The endpoint to connect to
646
+ * @param lastSequence - The last sequence to set for this WebSocket
635
647
  */
636
- createWebSocket(endpoint) {
637
- const ws = new VoiceWebSocket(`wss://${endpoint}?v=4`, Boolean(this.debug));
648
+ createWebSocket(endpoint, lastSequence) {
649
+ const ws = new VoiceWebSocket(`wss://${endpoint}?v=8`, Boolean(this.debug));
650
+ if (lastSequence !== void 0) {
651
+ ws.sequence = lastSequence;
652
+ }
638
653
  ws.on("error", this.onChildError);
639
654
  ws.once("open", this.onWsOpen);
640
655
  ws.on("packet", this.onWsPacket);
@@ -676,7 +691,8 @@ to ${stringifyState(newState)}`);
676
691
  d: {
677
692
  server_id: this.state.connectionOptions.serverId,
678
693
  session_id: this.state.connectionOptions.sessionId,
679
- token: this.state.connectionOptions.token
694
+ token: this.state.connectionOptions.token,
695
+ seq_ack: this.state.ws.sequence
680
696
  }
681
697
  };
682
698
  this.state.ws.sendPacket(packet);
@@ -692,10 +708,11 @@ to ${stringifyState(newState)}`);
692
708
  onWsClose({ code }) {
693
709
  const canResume = code === 4015 || code < 4e3;
694
710
  if (canResume && this.state.code === 4 /* Ready */) {
711
+ const lastSequence = this.state.ws.sequence;
695
712
  this.state = {
696
713
  ...this.state,
697
714
  code: 5 /* Resuming */,
698
- ws: this.createWebSocket(this.state.connectionOptions.endpoint)
715
+ ws: this.createWebSocket(this.state.connectionOptions.endpoint, lastSequence)
699
716
  };
700
717
  } else if (this.state.code !== 6 /* Closed */) {
701
718
  this.destroy();
@@ -707,10 +724,11 @@ to ${stringifyState(newState)}`);
707
724
  */
708
725
  onUdpClose() {
709
726
  if (this.state.code === 4 /* Ready */) {
727
+ const lastSequence = this.state.ws.sequence;
710
728
  this.state = {
711
729
  ...this.state,
712
730
  code: 5 /* Resuming */,
713
- ws: this.createWebSocket(this.state.connectionOptions.endpoint)
731
+ ws: this.createWebSocket(this.state.connectionOptions.endpoint, lastSequence)
714
732
  };
715
733
  }
716
734
  }
@@ -1373,9 +1391,10 @@ var AudioReceiveStream = class extends import_node_stream.Readable {
1373
1391
  */
1374
1392
  end;
1375
1393
  endTimeout;
1376
- constructor({ end, ...options }) {
1394
+ constructor(options) {
1395
+ const { end, ...rest } = options;
1377
1396
  super({
1378
- ...options,
1397
+ ...rest,
1379
1398
  objectMode: true
1380
1399
  });
1381
1400
  this.end = end;
@@ -2511,7 +2530,7 @@ __name(findPackageJSON, "findPackageJSON");
2511
2530
  function version(name) {
2512
2531
  try {
2513
2532
  if (name === "@discordjs/voice") {
2514
- return "1.0.0-dev.1748650419-ef2c1bfa7";
2533
+ return "1.0.0-dev.1748909640-d40ceedad";
2515
2534
  }
2516
2535
  const pkg = findPackageJSON((0, import_node_path.dirname)(require.resolve(name)), name, 3);
2517
2536
  return pkg?.version ?? "not found";
@@ -2656,7 +2675,7 @@ async function demuxProbe(stream, probeSize = 1024, validator = validateDiscordO
2656
2675
  __name(demuxProbe, "demuxProbe");
2657
2676
 
2658
2677
  // src/index.ts
2659
- var version2 = "1.0.0-dev.1748650419-ef2c1bfa7";
2678
+ var version2 = "1.0.0-dev.1748909640-d40ceedad";
2660
2679
  // Annotate the CommonJS export names for ESM import in node:
2661
2680
  0 && (module.exports = {
2662
2681
  AudioPlayer,