@discordjs/voice 0.6.0 → 0.7.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.
Files changed (60) hide show
  1. package/LICENSE +190 -21
  2. package/README.md +41 -18
  3. package/dist/index.d.ts +155 -89
  4. package/dist/index.js +10 -26
  5. package/dist/index.js.map +7 -1
  6. package/dist/index.mjs +10 -0
  7. package/dist/index.mjs.map +7 -0
  8. package/package.json +67 -96
  9. package/dist/DataStore.js +0 -151
  10. package/dist/DataStore.js.map +0 -1
  11. package/dist/VoiceConnection.js +0 -529
  12. package/dist/VoiceConnection.js.map +0 -1
  13. package/dist/audio/AudioPlayer.js +0 -449
  14. package/dist/audio/AudioPlayer.js.map +0 -1
  15. package/dist/audio/AudioPlayerError.js +0 -17
  16. package/dist/audio/AudioPlayerError.js.map +0 -1
  17. package/dist/audio/AudioResource.js +0 -162
  18. package/dist/audio/AudioResource.js.map +0 -1
  19. package/dist/audio/PlayerSubscription.js +0 -23
  20. package/dist/audio/PlayerSubscription.js.map +0 -1
  21. package/dist/audio/TransformerGraph.js +0 -233
  22. package/dist/audio/TransformerGraph.js.map +0 -1
  23. package/dist/audio/index.js +0 -18
  24. package/dist/audio/index.js.map +0 -1
  25. package/dist/joinVoiceChannel.js +0 -24
  26. package/dist/joinVoiceChannel.js.map +0 -1
  27. package/dist/networking/Networking.js +0 -457
  28. package/dist/networking/Networking.js.map +0 -1
  29. package/dist/networking/VoiceUDPSocket.js +0 -145
  30. package/dist/networking/VoiceUDPSocket.js.map +0 -1
  31. package/dist/networking/VoiceWebSocket.js +0 -129
  32. package/dist/networking/VoiceWebSocket.js.map +0 -1
  33. package/dist/networking/index.js +0 -16
  34. package/dist/networking/index.js.map +0 -1
  35. package/dist/receive/AudioReceiveStream.js +0 -64
  36. package/dist/receive/AudioReceiveStream.js.map +0 -1
  37. package/dist/receive/SSRCMap.js +0 -69
  38. package/dist/receive/SSRCMap.js.map +0 -1
  39. package/dist/receive/SpeakingMap.js +0 -38
  40. package/dist/receive/SpeakingMap.js.map +0 -1
  41. package/dist/receive/VoiceReceiver.js +0 -149
  42. package/dist/receive/VoiceReceiver.js.map +0 -1
  43. package/dist/receive/index.js +0 -16
  44. package/dist/receive/index.js.map +0 -1
  45. package/dist/util/Secretbox.js +0 -50
  46. package/dist/util/Secretbox.js.map +0 -1
  47. package/dist/util/abortAfter.js +0 -15
  48. package/dist/util/abortAfter.js.map +0 -1
  49. package/dist/util/adapter.js +0 -3
  50. package/dist/util/adapter.js.map +0 -1
  51. package/dist/util/demuxProbe.js +0 -90
  52. package/dist/util/demuxProbe.js.map +0 -1
  53. package/dist/util/entersState.js +0 -26
  54. package/dist/util/entersState.js.map +0 -1
  55. package/dist/util/generateDependencyReport.js +0 -82
  56. package/dist/util/generateDependencyReport.js.map +0 -1
  57. package/dist/util/index.js +0 -17
  58. package/dist/util/index.js.map +0 -1
  59. package/dist/util/util.js +0 -7
  60. package/dist/util/util.js.map +0 -1
package/dist/index.d.ts CHANGED
@@ -1,5 +1,4 @@
1
- /// <reference types="node" />
2
- import { Readable, ReadableOptions } from 'stream';
1
+ import { Readable, ReadableOptions } from 'node:stream';
3
2
  import { VolumeTransformer, opus } from 'prism-media';
4
3
  import { TypedEmitter } from 'tiny-typed-emitter';
5
4
  import { GatewayVoiceServerUpdateDispatchData, GatewayVoiceStateUpdateDispatchData } from 'discord-api-types/v9';
@@ -8,17 +7,13 @@ import WebSocket, { MessageEvent } from 'ws';
8
7
  declare type Awaited<T> = T | Promise<T>;
9
8
 
10
9
  /**
11
- * The different types of stream that can exist within the pipeline
10
+ * The different types of stream that can exist within the pipeline.
12
11
  *
13
12
  * @remarks
14
13
  * - `Arbitrary` - the type of the stream at this point is unknown.
15
- *
16
14
  * - `Raw` - the stream at this point is s16le PCM.
17
- *
18
15
  * - `OggOpus` - the stream at this point is Opus audio encoded in an Ogg wrapper.
19
- *
20
16
  * - `WebmOpus` - the stream at this point is Opus audio encoded in a WebM wrapper.
21
- *
22
17
  * - `Opus` - the stream at this point is Opus audio, and the stream is in object-mode. This is ready to play.
23
18
  */
24
19
  declare enum StreamType {
@@ -29,7 +24,7 @@ declare enum StreamType {
29
24
  Opus = "opus"
30
25
  }
31
26
  /**
32
- * The different types of transformers that can exist within the pipeline
27
+ * The different types of transformers that can exist within the pipeline.
33
28
  */
34
29
  declare enum TransformerType {
35
30
  FFmpegPCM = "ffmpeg pcm",
@@ -41,7 +36,7 @@ declare enum TransformerType {
41
36
  InlineVolume = "volume transformer"
42
37
  }
43
38
  /**
44
- * Represents a pathway from one stream type to another using a transformer
39
+ * Represents a pathway from one stream type to another using a transformer.
45
40
  */
46
41
  interface Edge {
47
42
  from: Node;
@@ -55,16 +50,16 @@ interface Edge {
55
50
  */
56
51
  declare class Node {
57
52
  /**
58
- * The outbound edges from this node
53
+ * The outbound edges from this node.
59
54
  */
60
55
  readonly edges: Edge[];
61
56
  /**
62
- * The type of stream for this node
57
+ * The type of stream for this node.
63
58
  */
64
59
  readonly type: StreamType;
65
60
  constructor(type: StreamType);
66
61
  /**
67
- * Creates an outbound edge from this node
62
+ * Creates an outbound edge from this node.
68
63
  *
69
64
  * @param edge - The edge to create
70
65
  */
@@ -74,7 +69,7 @@ declare class Node {
74
69
  /**
75
70
  * Options that are set when creating a new audio resource.
76
71
  *
77
- * @template T - the type for the metadata (if any) of the audio resource.
72
+ * @template T - the type for the metadata (if any) of the audio resource
78
73
  */
79
74
  interface CreateAudioResourceOptions<T> {
80
75
  /**
@@ -82,7 +77,7 @@ interface CreateAudioResourceOptions<T> {
82
77
  */
83
78
  inputType?: StreamType;
84
79
  /**
85
- * Optional metadata that can be attached to the resource (e.g. track title, random ID).
80
+ * Optional metadata that can be attached to the resource (e.g. track title, random id).
86
81
  * This is useful for identification purposes when the resource is passed around in events.
87
82
  * See {@link AudioResource.metadata}
88
83
  */
@@ -101,7 +96,7 @@ interface CreateAudioResourceOptions<T> {
101
96
  /**
102
97
  * Represents an audio resource that can be played by an audio player.
103
98
  *
104
- * @template T - the type for the metadata (if any) of the audio resource.
99
+ * @template T - the type for the metadata (if any) of the audio resource
105
100
  */
106
101
  declare class AudioResource<T = unknown> {
107
102
  /**
@@ -161,15 +156,47 @@ declare class AudioResource<T = unknown> {
161
156
  /**
162
157
  * Attempts to read an Opus packet from the audio resource. If a packet is available, the playbackDuration
163
158
  * is incremented.
164
- * @internal
159
+ *
165
160
  * @remarks
166
161
  * It is advisable to check that the playStream is readable before calling this method. While no runtime
167
162
  * errors will be thrown, you should check that the resource is still available before attempting to
168
163
  * read from it.
164
+ *
165
+ * @internal
169
166
  */
170
167
  read(): Buffer | null;
171
168
  }
169
+ /**
170
+ * Creates an audio resource that can be played by audio players.
171
+ *
172
+ * @remarks
173
+ * If the input is given as a string, then the inputType option will be overridden and FFmpeg will be used.
174
+ *
175
+ * If the input is not in the correct format, then a pipeline of transcoders and transformers will be created
176
+ * to ensure that the resultant stream is in the correct format for playback. This could involve using FFmpeg,
177
+ * Opus transcoders, and Ogg/WebM demuxers.
178
+ *
179
+ * @param input - The resource to play
180
+ * @param options - Configurable options for creating the resource
181
+ *
182
+ * @template T - the type for the metadata (if any) of the audio resource
183
+ */
172
184
  declare function createAudioResource<T>(input: string | Readable, options: CreateAudioResourceOptions<T> & Pick<T extends null | undefined ? CreateAudioResourceOptions<T> : Required<CreateAudioResourceOptions<T>>, 'metadata'>): AudioResource<T extends null | undefined ? null : T>;
185
+ /**
186
+ * Creates an audio resource that can be played by audio players.
187
+ *
188
+ * @remarks
189
+ * If the input is given as a string, then the inputType option will be overridden and FFmpeg will be used.
190
+ *
191
+ * If the input is not in the correct format, then a pipeline of transcoders and transformers will be created
192
+ * to ensure that the resultant stream is in the correct format for playback. This could involve using FFmpeg,
193
+ * Opus transcoders, and Ogg/WebM demuxers.
194
+ *
195
+ * @param input - The resource to play
196
+ * @param options - Configurable options for creating the resource
197
+ *
198
+ * @template T - the type for the metadata (if any) of the audio resource
199
+ */
173
200
  declare function createAudioResource<T extends null | undefined>(input: string | Readable, options?: Omit<CreateAudioResourceOptions<T>, 'metadata'>): AudioResource<null>;
174
201
 
175
202
  /**
@@ -190,11 +217,11 @@ declare class AudioPlayerError extends Error {
190
217
  */
191
218
  declare class PlayerSubscription {
192
219
  /**
193
- * The voice connection of this subscription
220
+ * The voice connection of this subscription.
194
221
  */
195
222
  readonly connection: VoiceConnection;
196
223
  /**
197
- * The audio player of this subscription
224
+ * The audio player of this subscription.
198
225
  */
199
226
  readonly player: AudioPlayer;
200
227
  constructor(connection: VoiceConnection, player: AudioPlayer);
@@ -211,33 +238,33 @@ declare class PlayerSubscription {
211
238
  */
212
239
  declare enum NoSubscriberBehavior {
213
240
  /**
214
- * Pauses playing the stream until a voice connection becomes available
241
+ * Pauses playing the stream until a voice connection becomes available.
215
242
  */
216
243
  Pause = "pause",
217
244
  /**
218
- * Continues to play through the resource regardless
245
+ * Continues to play through the resource regardless.
219
246
  */
220
247
  Play = "play",
221
248
  /**
222
- * The player stops and enters the Idle state
249
+ * The player stops and enters the Idle state.
223
250
  */
224
251
  Stop = "stop"
225
252
  }
226
253
  declare enum AudioPlayerStatus {
227
254
  /**
228
- * When there is currently no resource for the player to be playing
255
+ * When there is currently no resource for the player to be playing.
229
256
  */
230
257
  Idle = "idle",
231
258
  /**
232
- * When the player is waiting for an audio resource to become readable before transitioning to Playing
259
+ * When the player is waiting for an audio resource to become readable before transitioning to Playing.
233
260
  */
234
261
  Buffering = "buffering",
235
262
  /**
236
- * When the player has been manually paused
263
+ * When the player has been manually paused.
237
264
  */
238
265
  Paused = "paused",
239
266
  /**
240
- * When the player is actively playing an audio resource
267
+ * When the player is actively playing an audio resource.
241
268
  */
242
269
  Playing = "playing",
243
270
  /**
@@ -292,7 +319,7 @@ interface AudioPlayerPlayingState {
292
319
  */
293
320
  playbackDuration: number;
294
321
  /**
295
- * The resource that is being played
322
+ * The resource that is being played.
296
323
  */
297
324
  resource: AudioResource;
298
325
  onStreamError: (error: Error) => void;
@@ -304,7 +331,7 @@ interface AudioPlayerPlayingState {
304
331
  interface AudioPlayerPausedState {
305
332
  status: AudioPlayerStatus.Paused | AudioPlayerStatus.AutoPaused;
306
333
  /**
307
- * How many silence packets still need to be played to avoid audio interpolation due to the stream suddenly pausing
334
+ * How many silence packets still need to be played to avoid audio interpolation due to the stream suddenly pausing.
308
335
  */
309
336
  silencePacketsRemaining: number;
310
337
  /**
@@ -313,7 +340,7 @@ interface AudioPlayerPausedState {
313
340
  */
314
341
  playbackDuration: number;
315
342
  /**
316
- * The current resource of the audio player
343
+ * The current resource of the audio player.
317
344
  */
318
345
  resource: AudioResource;
319
346
  onStreamError: (error: Error) => void;
@@ -345,7 +372,7 @@ declare type AudioPlayerEvents = {
345
372
  */
346
373
  declare class AudioPlayer extends TypedEmitter<AudioPlayerEvents> {
347
374
  /**
348
- * The state that the AudioPlayer is in
375
+ * The state that the AudioPlayer is in.
349
376
  */
350
377
  private _state;
351
378
  /**
@@ -362,11 +389,11 @@ declare class AudioPlayer extends TypedEmitter<AudioPlayerEvents> {
362
389
  */
363
390
  private readonly debug;
364
391
  /**
365
- * Creates a new AudioPlayer
392
+ * Creates a new AudioPlayer.
366
393
  */
367
394
  constructor(options?: CreateAudioPlayerOptions);
368
395
  /**
369
- * A list of subscribed voice connections that can currently receive audio to play
396
+ * A list of subscribed voice connections that can currently receive audio to play.
370
397
  */
371
398
  get playable(): VoiceConnection[];
372
399
  /**
@@ -377,7 +404,8 @@ declare class AudioPlayer extends TypedEmitter<AudioPlayerEvents> {
377
404
  * This method should not be directly called. Instead, use VoiceConnection#subscribe.
378
405
  *
379
406
  * @param connection - The connection to subscribe
380
- * @returns The new subscription if the voice connection is not yet subscribed, otherwise the existing subscription.
407
+ *
408
+ * @returns The new subscription if the voice connection is not yet subscribed, otherwise the existing subscription
381
409
  */
382
410
  private subscribe;
383
411
  /**
@@ -387,7 +415,8 @@ declare class AudioPlayer extends TypedEmitter<AudioPlayerEvents> {
387
415
  * This method should not be directly called. Instead, use PlayerSubscription#unsubscribe.
388
416
  *
389
417
  * @param subscription - The subscription to remove
390
- * @returns Whether or not the subscription existed on the player and was removed.
418
+ *
419
+ * @returns Whether or not the subscription existed on the player and was removed
391
420
  */
392
421
  private unsubscribe;
393
422
  /**
@@ -410,34 +439,37 @@ declare class AudioPlayer extends TypedEmitter<AudioPlayerEvents> {
410
439
  * Idle state during the swap over.
411
440
  *
412
441
  * @param resource - The resource to play
413
- * @throws Will throw if attempting to play an audio resource that has already ended, or is being played by another player.
442
+ *
443
+ * @throws Will throw if attempting to play an audio resource that has already ended, or is being played by another player
414
444
  */
415
445
  play<T>(resource: AudioResource<T>): void;
416
446
  /**
417
447
  * Pauses playback of the current resource, if any.
418
448
  *
419
- * @param interpolateSilence - If true, the player will play 5 packets of silence after pausing to prevent audio glitches.
420
- * @returns true if the player was successfully paused, otherwise false.
449
+ * @param interpolateSilence - If true, the player will play 5 packets of silence after pausing to prevent audio glitches
450
+ *
451
+ * @returns `true` if the player was successfully paused, otherwise `false`
421
452
  */
422
453
  pause(interpolateSilence?: boolean): boolean;
423
454
  /**
424
455
  * Unpauses playback of the current resource, if any.
425
456
  *
426
- * @returns true if the player was successfully unpaused, otherwise false.
457
+ * @returns `true` if the player was successfully unpaused, otherwise `false`
427
458
  */
428
459
  unpause(): boolean;
429
460
  /**
430
461
  * Stops playback of the current resource and destroys the resource. The player will either transition to the Idle state,
431
462
  * or remain in its current state until the silence padding frames of the resource have been played.
432
463
  *
433
- * @param force - If true, will force the player to enter the Idle state even if the resource has silence padding frames.
434
- * @returns true if the player will come to a stop, otherwise false.
464
+ * @param force - If true, will force the player to enter the Idle state even if the resource has silence padding frames
465
+ *
466
+ * @returns `true` if the player will come to a stop, otherwise `false`
435
467
  */
436
468
  stop(force?: boolean): boolean;
437
469
  /**
438
- * Checks whether the underlying resource (if any) is playable (readable).
470
+ * Checks whether the underlying resource (if any) is playable (readable)
439
471
  *
440
- * @returns true if the resource is playable, false otherwise.
472
+ * @returns `true` if the resource is playable, otherwise `false`
441
473
  */
442
474
  checkPlayable(): boolean;
443
475
  /**
@@ -466,7 +498,7 @@ declare class AudioPlayer extends TypedEmitter<AudioPlayerEvents> {
466
498
  private _preparePacket;
467
499
  }
468
500
  /**
469
- * Creates a new AudioPlayer to be used
501
+ * Creates a new AudioPlayer to be used.
470
502
  */
471
503
  declare function createAudioPlayer(options?: CreateAudioPlayerOptions): AudioPlayer;
472
504
 
@@ -480,15 +512,32 @@ interface JoinConfig {
480
512
  /**
481
513
  * Retrieves the map of group names to maps of voice connections. By default, all voice connections
482
514
  * are created under the 'default' group.
515
+ *
483
516
  * @returns The group map
484
517
  */
485
518
  declare function getGroups(): Map<string, Map<string, VoiceConnection>>;
519
+ /**
520
+ * Retrieves all the voice connections under the 'default' group.
521
+ *
522
+ * @param group - The group to look up
523
+ *
524
+ * @returns The map of voice connections
525
+ */
486
526
  declare function getVoiceConnections(group?: 'default'): Map<string, VoiceConnection>;
527
+ /**
528
+ * Retrieves all the voice connections under the given group name.
529
+ *
530
+ * @param group - The group to look up
531
+ *
532
+ * @returns The map of voice connections
533
+ */
487
534
  declare function getVoiceConnections(group: string): Map<string, VoiceConnection> | undefined;
488
535
  /**
489
- * Finds a voice connection with the given guild ID and group. Defaults to the 'default' group.
490
- * @param guildId - The guild ID of the voice connection
536
+ * Finds a voice connection with the given guild id and group. Defaults to the 'default' group.
537
+ *
538
+ * @param guildId - The guild id of the voice connection
491
539
  * @param group - the group that the voice connection was registered with
540
+ *
492
541
  * @returns The voice connection, if it exists
493
542
  */
494
543
  declare function getVoiceConnection(guildId: string, group?: string): VoiceConnection | undefined;
@@ -523,7 +572,8 @@ interface DiscordGatewayAdapterImplementerMethods {
523
572
  * Implement this method such that the given payload is sent to the main Discord gateway connection.
524
573
  *
525
574
  * @param payload - The payload to send to the main Discord gateway connection
526
- * @returns false if the payload definitely failed to send - in this case, the voice connection disconnects.
575
+ *
576
+ * @returns `false` if the payload definitely failed to send - in this case, the voice connection disconnects
527
577
  */
528
578
  sendPayload(payload: any): boolean;
529
579
  /**
@@ -563,7 +613,7 @@ declare class VoiceUDPSocket extends TypedEmitter<VoiceUDPSocketEvents> {
563
613
  */
564
614
  private readonly socket;
565
615
  /**
566
- * The socket details for Discord (remote).
616
+ * The socket details for Discord (remote)
567
617
  */
568
618
  private readonly remote;
569
619
  /**
@@ -571,19 +621,19 @@ declare class VoiceUDPSocket extends TypedEmitter<VoiceUDPSocketEvents> {
571
621
  */
572
622
  private readonly keepAlives;
573
623
  /**
574
- * The counter used in the keep alive mechanism
624
+ * The counter used in the keep alive mechanism.
575
625
  */
576
626
  private keepAliveCounter;
577
627
  /**
578
- * The buffer used to write the keep alive counter into
628
+ * The buffer used to write the keep alive counter into.
579
629
  */
580
630
  private readonly keepAliveBuffer;
581
631
  /**
582
- * The Node.js interval for the keep-alive mechanism
632
+ * The Node.js interval for the keep-alive mechanism.
583
633
  */
584
634
  private readonly keepAliveInterval;
585
635
  /**
586
- * The time taken to receive a response to keep alive messages
636
+ * The time taken to receive a response to keep alive messages.
587
637
  */
588
638
  ping?: number;
589
639
  /**
@@ -597,12 +647,13 @@ declare class VoiceUDPSocket extends TypedEmitter<VoiceUDPSocketEvents> {
597
647
  */
598
648
  constructor(remote: SocketConfig, debug?: boolean);
599
649
  /**
600
- * Called when a message is received on the UDP socket
650
+ * Called when a message is received on the UDP socket.
651
+ *
601
652
  * @param buffer The received buffer
602
653
  */
603
654
  private onMessage;
604
655
  /**
605
- * Called at a regular interval to check whether we are still able to send datagrams to Discord
656
+ * Called at a regular interval to check whether we are still able to send datagrams to Discord.
606
657
  */
607
658
  private keepAlive;
608
659
  /**
@@ -631,7 +682,7 @@ declare class VoiceUDPSocket extends TypedEmitter<VoiceUDPSocketEvents> {
631
682
  */
632
683
  interface VoiceWebSocketEvents {
633
684
  error: (error: Error) => Awaited<void>;
634
- open: (event: WebSocket.OpenEvent) => Awaited<void>;
685
+ open: (event: WebSocket.Event) => Awaited<void>;
635
686
  close: (event: WebSocket.CloseEvent) => Awaited<void>;
636
687
  debug: (message: string) => Awaited<void>;
637
688
  packet: (packet: any) => Awaited<void>;
@@ -642,7 +693,7 @@ interface VoiceWebSocketEvents {
642
693
  */
643
694
  declare class VoiceWebSocket extends TypedEmitter<VoiceWebSocketEvents> {
644
695
  /**
645
- * The current heartbeat interval, if any
696
+ * The current heartbeat interval, if any.
646
697
  */
647
698
  private heartbeatInterval?;
648
699
  /**
@@ -668,11 +719,11 @@ declare class VoiceWebSocket extends TypedEmitter<VoiceWebSocketEvents> {
668
719
  */
669
720
  private readonly debug;
670
721
  /**
671
- * The underlying WebSocket of this wrapper
722
+ * The underlying WebSocket of this wrapper.
672
723
  */
673
724
  private readonly ws;
674
725
  /**
675
- * Creates a new VoiceWebSocket
726
+ * Creates a new VoiceWebSocket.
676
727
  *
677
728
  * @param address - The address to connect to
678
729
  */
@@ -689,19 +740,19 @@ declare class VoiceWebSocket extends TypedEmitter<VoiceWebSocketEvents> {
689
740
  */
690
741
  onMessage(event: MessageEvent): void;
691
742
  /**
692
- * Sends a JSON-stringifiable packet over the WebSocket
743
+ * Sends a JSON-stringifiable packet over the WebSocket.
693
744
  *
694
745
  * @param packet - The packet to send
695
746
  */
696
747
  sendPacket(packet: any): void;
697
748
  /**
698
- * Sends a heartbeat over the WebSocket
749
+ * Sends a heartbeat over the WebSocket.
699
750
  */
700
751
  private sendHeartbeat;
701
752
  /**
702
- * Sets/clears an interval to send heartbeats over the WebSocket
753
+ * Sets/clears an interval to send heartbeats over the WebSocket.
703
754
  *
704
- * @param ms - The interval in milliseconds. If negative, the interval will be unset.
755
+ * @param ms - The interval in milliseconds. If negative, the interval will be unset
705
756
  */
706
757
  setHeartbeatInterval(ms: number): void;
707
758
  }
@@ -878,11 +929,12 @@ declare class Networking extends TypedEmitter<NetworkingEvents> {
878
929
  */
879
930
  private onWsClose;
880
931
  /**
881
- * Called when the UDP socket has closed itself if it has stopped receiving replies from Discord
932
+ * Called when the UDP socket has closed itself if it has stopped receiving replies from Discord.
882
933
  */
883
934
  private onUdpClose;
884
935
  /**
885
- * Called when a packet is received on the connection's WebSocket
936
+ * Called when a packet is received on the connection's WebSocket.
937
+ *
886
938
  * @param packet - The received packet
887
939
  */
888
940
  private onWsPacket;
@@ -900,7 +952,7 @@ declare class Networking extends TypedEmitter<NetworkingEvents> {
900
952
  private onUdpDebug;
901
953
  /**
902
954
  * Prepares an Opus packet for playback. This includes attaching metadata to it and encrypting it.
903
- * It will be stored within the instance, and can be played by dispatchAudio().
955
+ * It will be stored within the instance, and can be played by dispatchAudio()
904
956
  *
905
957
  * @remarks
906
958
  * Calling this method while there is already a prepared audio packet that has not yet been dispatched
@@ -908,7 +960,7 @@ declare class Networking extends TypedEmitter<NetworkingEvents> {
908
960
  *
909
961
  * @param opusPacket - The Opus packet to encrypt
910
962
  *
911
- * @returns The audio packet that was prepared.
963
+ * @returns The audio packet that was prepared
912
964
  */
913
965
  prepareAudioPacket(opusPacket: Buffer): Buffer | undefined;
914
966
  /**
@@ -990,7 +1042,7 @@ declare class AudioReceiveStream extends Readable {
990
1042
  }
991
1043
 
992
1044
  /**
993
- * The events that a SpeakingMap can emit
1045
+ * The events that a SpeakingMap can emit.
994
1046
  */
995
1047
  interface SpeakingMapEvents {
996
1048
  /**
@@ -1021,20 +1073,20 @@ declare class SpeakingMap extends TypedEmitter<SpeakingMapEvents> {
1021
1073
  }
1022
1074
 
1023
1075
  /**
1024
- * The known data for a user in a Discord voice connection
1076
+ * The known data for a user in a Discord voice connection.
1025
1077
  */
1026
1078
  interface VoiceUserData {
1027
1079
  /**
1028
- * The SSRC of the user's audio stream
1080
+ * The SSRC of the user's audio stream.
1029
1081
  */
1030
1082
  audioSSRC: number;
1031
1083
  /**
1032
- * The SSRC of the user's video stream (if one exists).
1084
+ * The SSRC of the user's video stream (if one exists)
1033
1085
  * Cannot be 0. If undefined, the user has no video stream.
1034
1086
  */
1035
1087
  videoSSRC?: number;
1036
1088
  /**
1037
- * The Discord user ID of the user
1089
+ * The Discord user id of the user.
1038
1090
  */
1039
1091
  userId: string;
1040
1092
  }
@@ -1051,7 +1103,7 @@ interface SSRCMapEvents {
1051
1103
  */
1052
1104
  declare class SSRCMap extends TypedEmitter<SSRCMapEvents> {
1053
1105
  /**
1054
- * The underlying map
1106
+ * The underlying map.
1055
1107
  */
1056
1108
  private readonly map;
1057
1109
  constructor();
@@ -1064,13 +1116,14 @@ declare class SSRCMap extends TypedEmitter<SSRCMapEvents> {
1064
1116
  /**
1065
1117
  * Gets the stored voice data of a user.
1066
1118
  *
1067
- * @param target The target, either their user ID or audio SSRC
1119
+ * @param target The target, either their user id or audio SSRC
1068
1120
  */
1069
1121
  get(target: number | string): VoiceUserData | undefined;
1070
1122
  /**
1071
1123
  * Deletes the stored voice data about a user.
1072
1124
  *
1073
- * @param target The target of the delete operation, either their audio SSRC or user ID
1125
+ * @param target The target of the delete operation, either their audio SSRC or user id
1126
+ *
1074
1127
  * @returns The data that was deleted, if any
1075
1128
  */
1076
1129
  delete(target: number | string): VoiceUserData | undefined;
@@ -1088,7 +1141,7 @@ declare class VoiceReceiver {
1088
1141
  */
1089
1142
  readonly voiceConnection: VoiceConnection;
1090
1143
  /**
1091
- * Maps SSRCs to Discord user IDs.
1144
+ * Maps SSRCs to Discord user ids.
1092
1145
  */
1093
1146
  readonly ssrcMap: SSRCMap;
1094
1147
  /**
@@ -1097,6 +1150,7 @@ declare class VoiceReceiver {
1097
1150
  readonly subscriptions: Map<string, AudioReceiveStream>;
1098
1151
  /**
1099
1152
  * The connection data of the receiver.
1153
+ *
1100
1154
  * @internal
1101
1155
  */
1102
1156
  connectionData: Partial<ConnectionData>;
@@ -1109,6 +1163,7 @@ declare class VoiceReceiver {
1109
1163
  * Called when a packet is received on the attached connection's WebSocket.
1110
1164
  *
1111
1165
  * @param packet The received packet
1166
+ *
1112
1167
  * @internal
1113
1168
  */
1114
1169
  onWsPacket(packet: any): void;
@@ -1120,6 +1175,7 @@ declare class VoiceReceiver {
1120
1175
  * @param mode The encryption mode
1121
1176
  * @param nonce The nonce buffer used by the connection for encryption
1122
1177
  * @param secretKey The secret key used by the connection for encryption
1178
+ *
1123
1179
  * @returns The parsed Opus packet
1124
1180
  */
1125
1181
  private parsePacket;
@@ -1127,13 +1183,15 @@ declare class VoiceReceiver {
1127
1183
  * Called when the UDP socket of the attached connection receives a message.
1128
1184
  *
1129
1185
  * @param msg The received message
1186
+ *
1130
1187
  * @internal
1131
1188
  */
1132
1189
  onUdpMessage(msg: Buffer): void;
1133
1190
  /**
1134
- * Creates a subscription for the given user ID.
1191
+ * Creates a subscription for the given user id.
1192
+ *
1193
+ * @param target The id of the user to subscribe to
1135
1194
  *
1136
- * @param target The ID of the user to subscribe to
1137
1195
  * @returns A readable stream of Opus packets received from the target
1138
1196
  */
1139
1197
  subscribe(userId: string, options?: Partial<AudioReceiveStreamOptions>): AudioReceiveStream;
@@ -1152,7 +1210,7 @@ declare enum VoiceConnectionStatus {
1152
1210
  */
1153
1211
  Connecting = "connecting",
1154
1212
  /**
1155
- * A voice connection has been established, and is ready to be used
1213
+ * A voice connection has been established, and is ready to be used.
1156
1214
  */
1157
1215
  Ready = "ready",
1158
1216
  /**
@@ -1277,11 +1335,12 @@ declare class VoiceConnection extends TypedEmitter<VoiceConnectionEvents> {
1277
1335
  */
1278
1336
  rejoinAttempts: number;
1279
1337
  /**
1280
- * The state of the voice connection
1338
+ * The state of the voice connection.
1281
1339
  */
1282
1340
  private _state;
1283
1341
  /**
1284
1342
  * A configuration storing all the data needed to reconnect to a Guild's voice server.
1343
+ *
1285
1344
  * @internal
1286
1345
  */
1287
1346
  readonly joinConfig: JoinConfig;
@@ -1307,7 +1366,7 @@ declare class VoiceConnection extends TypedEmitter<VoiceConnectionEvents> {
1307
1366
  */
1308
1367
  constructor(joinConfig: JoinConfig, { debug, adapterCreator }: CreateVoiceConnectionOptions);
1309
1368
  /**
1310
- * The current state of the voice connection
1369
+ * The current state of the voice connection.
1311
1370
  */
1312
1371
  get state(): VoiceConnectionState;
1313
1372
  /**
@@ -1322,7 +1381,7 @@ declare class VoiceConnection extends TypedEmitter<VoiceConnectionEvents> {
1322
1381
  */
1323
1382
  private addServerPacket;
1324
1383
  /**
1325
- * Registers a `VOICE_STATE_UPDATE` packet to the voice connection. Most importantly, it stores the ID of the
1384
+ * Registers a `VOICE_STATE_UPDATE` packet to the voice connection. Most importantly, it stores the id of the
1326
1385
  * channel that the client is connected to.
1327
1386
  *
1328
1387
  * @param packet - The received `VOICE_STATE_UPDATE` packet
@@ -1380,7 +1439,7 @@ declare class VoiceConnection extends TypedEmitter<VoiceConnectionEvents> {
1380
1439
  */
1381
1440
  private onNetworkingDebug;
1382
1441
  /**
1383
- * Prepares an audio packet for dispatch
1442
+ * Prepares an audio packet for dispatch.
1384
1443
  *
1385
1444
  * @param buffer - The Opus packet to prepare
1386
1445
  */
@@ -1390,7 +1449,7 @@ declare class VoiceConnection extends TypedEmitter<VoiceConnectionEvents> {
1390
1449
  */
1391
1450
  dispatchAudio(): boolean | undefined;
1392
1451
  /**
1393
- * Prepares an audio packet and dispatches it immediately
1452
+ * Prepares an audio packet and dispatches it immediately.
1394
1453
  *
1395
1454
  * @param buffer - The Opus packet to play
1396
1455
  */
@@ -1399,12 +1458,14 @@ declare class VoiceConnection extends TypedEmitter<VoiceConnectionEvents> {
1399
1458
  * Destroys the VoiceConnection, preventing it from connecting to voice again.
1400
1459
  * This method should be called when you no longer require the VoiceConnection to
1401
1460
  * prevent memory leaks.
1461
+ *
1402
1462
  * @param adapterAvailable - Whether the adapter can be used
1403
1463
  */
1404
1464
  destroy(adapterAvailable?: boolean): void;
1405
1465
  /**
1406
1466
  * Disconnects the VoiceConnection, allowing the possibility of rejoining later on.
1407
- * @returns - true if the connection was successfully disconnected.
1467
+ *
1468
+ * @returns `true` if the connection was successfully disconnected
1408
1469
  */
1409
1470
  disconnect(): boolean;
1410
1471
  /**
@@ -1424,11 +1485,12 @@ declare class VoiceConnection extends TypedEmitter<VoiceConnectionEvents> {
1424
1485
  *
1425
1486
  * @param enabled - Whether or not to show as speaking
1426
1487
  */
1427
- setSpeaking(enabled: boolean): false | undefined;
1488
+ setSpeaking(enabled: boolean): false | void;
1428
1489
  /**
1429
1490
  * Subscribes to an audio player, allowing the player to play audio on this voice connection.
1430
1491
  *
1431
1492
  * @param player - The audio player to subscribe to
1493
+ *
1432
1494
  * @returns The created subscription
1433
1495
  */
1434
1496
  subscribe(player: AudioPlayer): PlayerSubscription | undefined;
@@ -1468,11 +1530,11 @@ interface CreateVoiceConnectionOptions {
1468
1530
  */
1469
1531
  interface JoinVoiceChannelOptions {
1470
1532
  /**
1471
- * The ID of the Discord voice channel to join
1533
+ * The id of the Discord voice channel to join.
1472
1534
  */
1473
1535
  channelId: string;
1474
1536
  /**
1475
- * The ID of the guild that the voice channel belongs to
1537
+ * The id of the guild that the voice channel belongs to.
1476
1538
  */
1477
1539
  guildId: string;
1478
1540
  /**
@@ -1484,7 +1546,7 @@ interface JoinVoiceChannelOptions {
1484
1546
  */
1485
1547
  selfMute?: boolean;
1486
1548
  /**
1487
- * An optional group identifier for the voice connection
1549
+ * An optional group identifier for the voice connection.
1488
1550
  */
1489
1551
  group?: string;
1490
1552
  }
@@ -1521,8 +1583,10 @@ declare function entersState(target: AudioPlayer, status: AudioPlayerStatus, tim
1521
1583
 
1522
1584
  /**
1523
1585
  * Takes an Opus Head, and verifies whether the associated Opus audio is suitable to play in a Discord voice channel.
1586
+ *
1524
1587
  * @param opusHead The Opus Head to validate
1525
- * @returns true if suitable to play in a Discord voice channel, false otherwise
1588
+ *
1589
+ * @returns `true` if suitable to play in a Discord voice channel, otherwise `false`
1526
1590
  */
1527
1591
  declare function validateDiscordOpusHead(opusHead: Buffer): boolean;
1528
1592
  /**
@@ -1535,17 +1599,19 @@ interface ProbeInfo {
1535
1599
  */
1536
1600
  stream: Readable;
1537
1601
  /**
1538
- * The recommended stream type for this audio stream
1602
+ * The recommended stream type for this audio stream.
1539
1603
  */
1540
1604
  type: StreamType;
1541
1605
  }
1542
1606
  /**
1543
1607
  * Attempt to probe a readable stream to figure out whether it can be demuxed using an Ogg or WebM Opus demuxer.
1608
+ *
1544
1609
  * @param stream The readable stream to probe
1545
1610
  * @param probeSize The number of bytes to attempt to read before giving up on the probe
1546
1611
  * @param validator The Opus Head validator function
1612
+ *
1547
1613
  * @experimental
1548
1614
  */
1549
1615
  declare function demuxProbe(stream: Readable, probeSize?: number, validator?: typeof validateDiscordOpusHead): Promise<ProbeInfo>;
1550
1616
 
1551
- export { AudioPlayer, AudioPlayerBufferingState, AudioPlayerError, AudioPlayerEvents, AudioPlayerIdleState, AudioPlayerPausedState, AudioPlayerPlayingState, AudioPlayerState, AudioPlayerStatus, AudioReceiveStream, AudioReceiveStreamOptions, AudioResource, CreateAudioPlayerOptions, CreateVoiceConnectionOptions, DiscordGatewayAdapterCreator, DiscordGatewayAdapterImplementerMethods, DiscordGatewayAdapterLibraryMethods, EndBehavior, EndBehaviorType, JoinVoiceChannelOptions, NoSubscriberBehavior, PlayerSubscription, ProbeInfo, SSRCMap, SSRCMapEvents, StreamType, VoiceConnection, VoiceConnectionConnectingState, VoiceConnectionDestroyedState, VoiceConnectionDisconnectReason, VoiceConnectionDisconnectedBaseState, VoiceConnectionDisconnectedOtherState, VoiceConnectionDisconnectedState, VoiceConnectionDisconnectedWebSocketState, VoiceConnectionEvents, VoiceConnectionReadyState, VoiceConnectionSignallingState, VoiceConnectionState, VoiceConnectionStatus, VoiceReceiver, VoiceUserData, createAudioPlayer, createAudioResource, createDefaultAudioReceiveStreamOptions, demuxProbe, entersState, generateDependencyReport, getGroups, getVoiceConnection, getVoiceConnections, joinVoiceChannel, validateDiscordOpusHead };
1617
+ export { AudioPlayer, AudioPlayerBufferingState, AudioPlayerError, AudioPlayerEvents, AudioPlayerIdleState, AudioPlayerPausedState, AudioPlayerPlayingState, AudioPlayerState, AudioPlayerStatus, AudioReceiveStream, AudioReceiveStreamOptions, AudioResource, CreateAudioPlayerOptions, CreateAudioResourceOptions, CreateVoiceConnectionOptions, DiscordGatewayAdapterCreator, DiscordGatewayAdapterImplementerMethods, DiscordGatewayAdapterLibraryMethods, EndBehavior, EndBehaviorType, JoinConfig, JoinVoiceChannelOptions, NoSubscriberBehavior, PlayerSubscription, ProbeInfo, SSRCMap, SSRCMapEvents, SpeakingMap, SpeakingMapEvents, StreamType, VoiceConnection, VoiceConnectionConnectingState, VoiceConnectionDestroyedState, VoiceConnectionDisconnectReason, VoiceConnectionDisconnectedBaseState, VoiceConnectionDisconnectedOtherState, VoiceConnectionDisconnectedState, VoiceConnectionDisconnectedWebSocketState, VoiceConnectionEvents, VoiceConnectionReadyState, VoiceConnectionSignallingState, VoiceConnectionState, VoiceConnectionStatus, VoiceReceiver, VoiceUserData, createAudioPlayer, createAudioResource, createDefaultAudioReceiveStreamOptions, demuxProbe, entersState, generateDependencyReport, getGroups, getVoiceConnection, getVoiceConnections, joinVoiceChannel, validateDiscordOpusHead };