distube 3.0.0-beta.35 → 3.0.0-beta.39

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 (88) hide show
  1. package/README.md +4 -3
  2. package/dist/DisTube.d.ts +78 -57
  3. package/dist/DisTube.d.ts.map +1 -1
  4. package/dist/DisTube.js +87 -87
  5. package/dist/DisTube.js.map +1 -1
  6. package/dist/constant.d.ts +43 -10
  7. package/dist/constant.d.ts.map +1 -1
  8. package/dist/constant.js +45 -11
  9. package/dist/constant.js.map +1 -1
  10. package/dist/core/DisTubeBase.d.ts +7 -13
  11. package/dist/core/DisTubeBase.d.ts.map +1 -1
  12. package/dist/core/DisTubeBase.js +4 -9
  13. package/dist/core/DisTubeBase.js.map +1 -1
  14. package/dist/core/DisTubeHandler.d.ts +9 -4
  15. package/dist/core/DisTubeHandler.d.ts.map +1 -1
  16. package/dist/core/DisTubeHandler.js +56 -10
  17. package/dist/core/DisTubeHandler.js.map +1 -1
  18. package/dist/core/DisTubeOptions.d.ts +0 -18
  19. package/dist/core/DisTubeOptions.d.ts.map +1 -1
  20. package/dist/core/DisTubeOptions.js +4 -1
  21. package/dist/core/DisTubeOptions.js.map +1 -1
  22. package/dist/core/DisTubeStream.d.ts +5 -2
  23. package/dist/core/DisTubeStream.d.ts.map +1 -1
  24. package/dist/core/DisTubeStream.js +23 -21
  25. package/dist/core/DisTubeStream.js.map +1 -1
  26. package/dist/core/manager/BaseManager.d.ts +2 -3
  27. package/dist/core/manager/BaseManager.d.ts.map +1 -1
  28. package/dist/core/manager/BaseManager.js +3 -3
  29. package/dist/core/manager/BaseManager.js.map +1 -1
  30. package/dist/core/manager/QueueManager.d.ts +2 -2
  31. package/dist/core/manager/QueueManager.d.ts.map +1 -1
  32. package/dist/core/manager/QueueManager.js +25 -22
  33. package/dist/core/manager/QueueManager.js.map +1 -1
  34. package/dist/core/voice/DisTubeVoice.d.ts +15 -15
  35. package/dist/core/voice/DisTubeVoice.d.ts.map +1 -1
  36. package/dist/core/voice/DisTubeVoice.js +27 -16
  37. package/dist/core/voice/DisTubeVoice.js.map +1 -1
  38. package/dist/core/voice/DisTubeVoiceManager.js +1 -1
  39. package/dist/core/voice/DisTubeVoiceManager.js.map +1 -1
  40. package/dist/plugin/http.js +2 -2
  41. package/dist/plugin/http.js.map +1 -1
  42. package/dist/plugin/https.js +3 -3
  43. package/dist/plugin/https.js.map +1 -1
  44. package/dist/plugin/youtube-dl.js +3 -3
  45. package/dist/plugin/youtube-dl.js.map +1 -1
  46. package/dist/struct/CustomPlugin.d.ts +17 -14
  47. package/dist/struct/CustomPlugin.d.ts.map +1 -1
  48. package/dist/struct/CustomPlugin.js +16 -16
  49. package/dist/struct/CustomPlugin.js.map +1 -1
  50. package/dist/struct/DisTubeError.d.ts +12 -3
  51. package/dist/struct/DisTubeError.d.ts.map +1 -1
  52. package/dist/struct/DisTubeError.js +11 -12
  53. package/dist/struct/DisTubeError.js.map +1 -1
  54. package/dist/struct/ExtractorPlugin.d.ts +16 -8
  55. package/dist/struct/ExtractorPlugin.d.ts.map +1 -1
  56. package/dist/struct/ExtractorPlugin.js +13 -12
  57. package/dist/struct/ExtractorPlugin.js.map +1 -1
  58. package/dist/struct/Playlist.d.ts +2 -3
  59. package/dist/struct/Playlist.d.ts.map +1 -1
  60. package/dist/struct/Playlist.js +9 -6
  61. package/dist/struct/Playlist.js.map +1 -1
  62. package/dist/struct/Plugin.d.ts +62 -9
  63. package/dist/struct/Plugin.d.ts.map +1 -1
  64. package/dist/struct/Plugin.js +73 -14
  65. package/dist/struct/Plugin.js.map +1 -1
  66. package/dist/struct/Queue.d.ts +17 -15
  67. package/dist/struct/Queue.d.ts.map +1 -1
  68. package/dist/struct/Queue.js +31 -16
  69. package/dist/struct/Queue.js.map +1 -1
  70. package/dist/struct/SearchResult.js +2 -2
  71. package/dist/struct/SearchResult.js.map +1 -1
  72. package/dist/struct/Song.d.ts +6 -8
  73. package/dist/struct/Song.d.ts.map +1 -1
  74. package/dist/struct/Song.js +17 -15
  75. package/dist/struct/Song.js.map +1 -1
  76. package/dist/struct/__mocks__/Queue.d.ts +12 -0
  77. package/dist/struct/__mocks__/Queue.d.ts.map +1 -0
  78. package/dist/struct/__mocks__/Queue.js +22 -0
  79. package/dist/struct/__mocks__/Queue.js.map +1 -0
  80. package/dist/tsconfig.tsbuildinfo +1 -1
  81. package/dist/type.d.ts +76 -20
  82. package/dist/type.d.ts.map +1 -1
  83. package/dist/type.js.map +1 -1
  84. package/dist/util.d.ts +1 -1
  85. package/dist/util.d.ts.map +1 -1
  86. package/dist/util.js +16 -7
  87. package/dist/util.js.map +1 -1
  88. package/package.json +30 -28
package/dist/DisTube.js CHANGED
@@ -6,17 +6,17 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.DisTube = void 0;
7
7
  const ytpl_1 = __importDefault(require("@distube/ytpl"));
8
8
  const ytsr_1 = __importDefault(require("@distube/ytsr"));
9
- const events_1 = require("events");
10
9
  const util_1 = require("./util");
10
+ const tiny_typed_emitter_1 = require("tiny-typed-emitter");
11
11
  const _1 = require(".");
12
12
  /**
13
13
  * DisTube class
14
14
  * @extends EventEmitter
15
15
  */
16
- class DisTube extends events_1.EventEmitter {
16
+ class DisTube extends tiny_typed_emitter_1.TypedEmitter {
17
17
  /**
18
18
  * Create a new DisTube class.
19
- * @param {Discord.Client} client JS client
19
+ * @param {Discord.Client} client Discord.JS client
20
20
  * @param {DisTubeOptions} [otp] Custom DisTube options
21
21
  * @example
22
22
  * const Discord = require('discord.js'),
@@ -30,24 +30,24 @@ class DisTube extends events_1.EventEmitter {
30
30
  constructor(client, otp = {}) {
31
31
  super();
32
32
  this.setMaxListeners(1);
33
- if (!_1.isClientInstance(client))
33
+ if (!(0, _1.isClientInstance)(client))
34
34
  throw new _1.DisTubeError("INVALID_TYPE", "Discord.Client", client, "client");
35
35
  /**
36
36
  * Discord.JS client
37
37
  * @type {Discord.Client}
38
38
  */
39
39
  this.client = client;
40
- util_1.checkIntents(client.options);
41
- /**
42
- * Voice connections manager
43
- * @type {DisTubeVoiceManager}
44
- */
45
- this.voices = new _1.DisTubeVoiceManager(this);
40
+ (0, util_1.checkIntents)(client.options);
46
41
  /**
47
42
  * DisTube options
48
43
  * @type {DisTubeOptions}
49
44
  */
50
45
  this.options = new _1.Options(otp);
46
+ /**
47
+ * Voice connections manager
48
+ * @type {DisTubeVoiceManager}
49
+ */
50
+ this.voices = new _1.DisTubeVoiceManager(this);
51
51
  /**
52
52
  * DisTube's Handler
53
53
  * @type {DisTubeHandler}
@@ -64,38 +64,7 @@ class DisTube extends events_1.EventEmitter {
64
64
  * @type {Filters}
65
65
  */
66
66
  this.filters = _1.defaultFilters;
67
- if (typeof this.options.customFilters === "object")
68
- Object.assign(this.filters, this.options.customFilters);
69
- if (this.options.leaveOnEmpty) {
70
- client.on("voiceStateUpdate", oldState => {
71
- if (!(oldState === null || oldState === void 0 ? void 0 : oldState.channel))
72
- return;
73
- const queue = this.getQueue(oldState);
74
- if (!queue) {
75
- if (util_1.isVoiceChannelEmpty(oldState)) {
76
- setTimeout(() => {
77
- const guildID = oldState.guild.id;
78
- if (!this.getQueue(oldState) && util_1.isVoiceChannelEmpty(oldState))
79
- this.voices.leave(guildID);
80
- }, this.options.emptyCooldown * 1e3).unref();
81
- }
82
- return;
83
- }
84
- if (queue.emptyTimeout) {
85
- clearTimeout(queue.emptyTimeout);
86
- delete queue.emptyTimeout;
87
- }
88
- if (util_1.isVoiceChannelEmpty(oldState)) {
89
- queue.emptyTimeout = setTimeout(() => {
90
- if (util_1.isVoiceChannelEmpty(oldState)) {
91
- queue.voice.leave();
92
- this.emit("empty", queue);
93
- queue.delete();
94
- }
95
- }, this.options.emptyCooldown * 1e3).unref();
96
- }
97
- });
98
- }
67
+ Object.assign(this.filters, this.options.customFilters);
99
68
  // Default plugin
100
69
  this.options.plugins.push(new _1.HTTPPlugin(), new _1.HTTPSPlugin());
101
70
  if (this.options.youtubeDL)
@@ -118,10 +87,12 @@ class DisTube extends events_1.EventEmitter {
118
87
  * Shorthand method for {@link DisTube#playVoiceChannel}
119
88
  * @returns {Promise<void>}
120
89
  * @param {Discord.Message} message A message from guild channel
121
- * @param {string|Song|SearchResult|Playlist} song YouTube url | Search string | {@link Song} | {@link SearchResult} | {@link Playlist}
90
+ * @param {string|Song|SearchResult|Playlist} song URL | Search string |
91
+ * {@link Song} | {@link SearchResult} | {@link Playlist}
122
92
  * @param {Object} [options] Optional options
123
93
  * @param {boolean} [options.skip=false] Skip the playing song (if exists) and play the added song/playlist instantly
124
- * @param {boolean} [options.unshift=false] Add the song/playlist to the beginning of the queue (after the playing song if exists)
94
+ * @param {boolean} [options.unshift=false] Add the song/playlist to the beginning of the queue
95
+ * (after the playing song if exists)
125
96
  * @example
126
97
  * client.on('message', (message) => {
127
98
  * if (!message.content.startsWith(config.prefix)) return;
@@ -134,7 +105,7 @@ class DisTube extends events_1.EventEmitter {
134
105
  async play(message, song, options = {}) {
135
106
  if (!song)
136
107
  return;
137
- if (!_1.isMessageInstance(message))
108
+ if (!(0, _1.isMessageInstance)(message))
138
109
  throw new _1.DisTubeError("INVALID_TYPE", "Discord.Message", message, "message");
139
110
  if (typeof options !== "object" || Array.isArray(options)) {
140
111
  throw new _1.DisTubeError("INVALID_TYPE", "object", options, "options");
@@ -158,17 +129,19 @@ class DisTube extends events_1.EventEmitter {
158
129
  * Emit {@link DisTube#addList}, {@link DisTube#addSong} or {@link DisTube#playSong} after executing
159
130
  * @returns {Promise<void>}
160
131
  * @param {Discord.VoiceChannel|Discord.StageChannel} voiceChannel The voice channel will be joined
161
- * @param {string|Song|SearchResult|Playlist} song YouTube url | Search string | {@link Song} | {@link SearchResult} | {@link Playlist}
132
+ * @param {string|Song|SearchResult|Playlist} song URL | Search string |
133
+ * {@link Song} | {@link SearchResult} | {@link Playlist}
162
134
  * @param {Object} [options] Optional options
163
135
  * @param {boolean} [options.skip=false] Skip the playing song (if exists) and play the added song/playlist instantly
164
- * @param {boolean} [options.unshift=false] Add the song/playlist to the beginning of the queue (after the playing song if exists)
136
+ * @param {boolean} [options.unshift=false] Add the song/playlist to the beginning of the queue
137
+ * (after the playing song if exists)
165
138
  * @param {Discord.GuildMember} [options.member] Requested user (default is your bot)
166
139
  * @param {Discord.TextChannel} [options.textChannel] Default {@link Queue#textChannel} (if the queue wasn't created)
167
140
  * @param {Discord.Message} [options.message] Called message (For built-in search events. If this is a {@link https://developer.mozilla.org/en-US/docs/Glossary/Falsy|falsy value}, it will play the first result instead)
168
141
  */
169
142
  async playVoiceChannel(voiceChannel, song, options = {}) {
170
143
  var _a;
171
- if (!_1.isSupportedVoiceChannel(voiceChannel))
144
+ if (!(0, _1.isSupportedVoiceChannel)(voiceChannel))
172
145
  throw new _1.DisTubeError("NOT_SUPPORTED_VOICE");
173
146
  if (typeof options !== "object" || Array.isArray(options)) {
174
147
  throw new _1.DisTubeError("INVALID_TYPE", "object", options, "options");
@@ -178,7 +151,7 @@ class DisTube extends events_1.EventEmitter {
178
151
  skip: false,
179
152
  unshift: false,
180
153
  }, options);
181
- if (message && !_1.isMessageInstance(message)) {
154
+ if (message && !(0, _1.isMessageInstance)(message)) {
182
155
  throw new _1.DisTubeError("INVALID_TYPE", ["Discord.Message", "a falsy value"], message, "options.message");
183
156
  }
184
157
  try {
@@ -198,7 +171,7 @@ class DisTube extends events_1.EventEmitter {
198
171
  song = song.url;
199
172
  if (typeof song === "string" && ytpl_1.default.validateID(song))
200
173
  song = await this.handler.resolvePlaylist(member, song);
201
- if (typeof song === "string" && !util_1.isURL(song)) {
174
+ if (typeof song === "string" && !(0, util_1.isURL)(song)) {
202
175
  if (!message)
203
176
  song = (await this.search(song, { limit: 1 }))[0];
204
177
  else
@@ -249,6 +222,11 @@ class DisTube extends events_1.EventEmitter {
249
222
  }
250
223
  }
251
224
  /**
225
+ * <info>Shorthand method of {@link DisTubeHandler#createCustomPlaylist} and {@link DisTube#playVoiceChannel}
226
+ *
227
+ * If you doesn't have a user message (interaction,...),
228
+ * see {@link DisTubeHandler#createCustomPlaylist} example</info>
229
+ *
252
230
  * Play or add array of video urls.
253
231
  * {@link DisTube#event:playSong} or {@link DisTube#event:addList} will be emitted
254
232
  * with `playlist`'s properties include `properties` parameter's properties such as
@@ -259,10 +237,11 @@ class DisTube extends events_1.EventEmitter {
259
237
  * @param {Object} [properties={}] Additional properties such as `name`
260
238
  * @param {Object} [options] Optional options
261
239
  * @param {boolean} [options.skip=false] Skip the playing song (if exists) and play the added song/playlist instantly
262
- * @param {boolean} [options.unshift=false] Add the song/playlist to the beginning of the queue (after the playing song if exists)
240
+ * @param {boolean} [options.unshift=false] Add the song/playlist to the beginning of the queue
241
+ * (after the playing song if exists)
263
242
  * @param {boolean} [options.parallel=true] Whether or not fetch the songs in parallel
264
243
  * @example
265
- * let songs = ["https://www.youtube.com/watch?v=xxx", "https://www.youtube.com/watch?v=yyy"];
244
+ * const songs = ["https://www.youtube.com/watch?v=xxx", "https://www.youtube.com/watch?v=yyy"];
266
245
  * distube.playCustomPlaylist(message, songs, { name: "My playlist name" });
267
246
  * // Fetching custom playlist sequentially (reduce lag for low specs)
268
247
  * distube.playCustomPlaylist(message, songs, { name: "My playlist name" }, false, false);
@@ -297,7 +276,7 @@ class DisTube extends events_1.EventEmitter {
297
276
  /**
298
277
  * Search for a song.
299
278
  * You can customize how user answers instead of send a number.
300
- * Then use {@link DisTube#play} or {@link DisTube#playSkip} to play it.
279
+ * Then use {@link DisTube#play} or {@link DisTube#playVoiceChannel} to play it.
301
280
  * @param {string} string The string search for
302
281
  * @param {Object} options Search options
303
282
  * @param {number} [options.limit=10] Limit the results
@@ -319,7 +298,7 @@ class DisTube extends events_1.EventEmitter {
319
298
  throw new _1.DisTubeError("INVALID_TYPE", "boolean", opts.safeSearch, "options.safeSearch");
320
299
  }
321
300
  try {
322
- const search = await ytsr_1.default(string, opts);
301
+ const search = await (0, ytsr_1.default)(string, opts);
323
302
  const results = search.items.map(i => new _1.SearchResult(i));
324
303
  if (results.length === 0)
325
304
  throw new _1.DisTubeError("NO_RESULT");
@@ -421,7 +400,9 @@ class DisTube extends events_1.EventEmitter {
421
400
  return q.setVolume(percent);
422
401
  }
423
402
  /**
424
- * Skip the playing song
403
+ * Skip the playing song if there is a next song in the queue.
404
+ * <info>If {@link Queue#autoplay} is `true` and there is no up next song,
405
+ * DisTube will add and play a related song.</info>
425
406
  * @param {GuildIDResolvable} queue The type can be resolved to give a {@link Queue}
426
407
  * @returns {Promise<Song>} The new Song will be played
427
408
  * @throws {Error}
@@ -504,12 +485,11 @@ class DisTube extends events_1.EventEmitter {
504
485
  return q.jump(num);
505
486
  }
506
487
  /**
507
- * Set the repeat mode of the guild queue.
508
- * Turn off if repeat mode is the same value as new mode.
509
- * Toggle mode `(0 -> 1 -> 2 -> 0...)`: `mode` is `undefined`
488
+ * Set the repeat mode of the guild queue.\
489
+ * Toggle mode `(Disabled -> Song -> Queue -> Disabled ->...)` if `mode` is `undefined`
510
490
  * @param {GuildIDResolvable} queue The type can be resolved to give a {@link Queue}
511
- * @param {number?} [mode] The repeat modes `(0: disabled, 1: Repeat a song, 2: Repeat all the queue)`
512
- * @returns {number} The new repeat mode
491
+ * @param {RepeatMode?} [mode] The repeat modes (toggle if `undefined`)
492
+ * @returns {RepeatMode} The new repeat mode
513
493
  * @example
514
494
  * client.on('message', (message) => {
515
495
  * if (!message.content.startsWith(config.prefix)) return;
@@ -521,6 +501,21 @@ class DisTube extends events_1.EventEmitter {
521
501
  * message.channel.send("Set repeat mode to `" + mode + "`");
522
502
  * }
523
503
  * });
504
+ * @example
505
+ * const { RepeatMode } = require("distube");
506
+ * let mode;
507
+ * switch(distube.setRepeatMode(message, parseInt(args[0]))) {
508
+ * case RepeatMode.DISABLED:
509
+ * mode = "Off";
510
+ * break;
511
+ * case RepeatMode.SONG:
512
+ * mode = "Repeat a song";
513
+ * break;
514
+ * case RepeatMode.QUEUE:
515
+ * mode = "Repeat all queue";
516
+ * break;
517
+ * }
518
+ * message.channel.send("Set repeat mode to `" + mode + "`");
524
519
  */
525
520
  setRepeatMode(queue, mode) {
526
521
  const q = this.getQueue(queue);
@@ -539,7 +534,7 @@ class DisTube extends events_1.EventEmitter {
539
534
  * const args = message.content.slice(config.prefix.length).trim().split(/ +/g);
540
535
  * const command = args.shift();
541
536
  * if (command == "autoplay") {
542
- * let mode = distube.toggleAutoplay(message);
537
+ * const mode = distube.toggleAutoplay(message);
543
538
  * message.channel.send("Set autoplay mode to `" + (mode ? "On" : "Off") + "`");
544
539
  * }
545
540
  * });
@@ -575,7 +570,7 @@ class DisTube extends events_1.EventEmitter {
575
570
  * const args = message.content.slice(config.prefix.length).trim().split(/ +/g);
576
571
  * const command = args.shift();
577
572
  * if ([`3d`, `bassboost`, `echo`, `karaoke`, `nightcore`, `vaporwave`].includes(command)) {
578
- * let filter = distube.setFilter(message, command);
573
+ * const filter = distube.setFilter(message, command);
579
574
  * message.channel.send("Current queue filter: " + (filter.join(", ") || "Off"));
580
575
  * }
581
576
  * });
@@ -614,7 +609,7 @@ class DisTube extends events_1.EventEmitter {
614
609
  * @private
615
610
  */
616
611
  emitError(error, channel) {
617
- if (!channel || !_1.isTextChannelInstance(channel)) {
612
+ if (!channel || !(0, _1.isTextChannelInstance)(channel)) {
618
613
  console.error(error);
619
614
  console.warn("This is logged because <Queue>.textChannel is undefined");
620
615
  }
@@ -631,7 +626,7 @@ class DisTube extends events_1.EventEmitter {
631
626
  exports.DisTube = DisTube;
632
627
  exports.default = DisTube;
633
628
  /**
634
- * Emitted after DisTube add a new playlist to the playing {@link Queue}
629
+ * Emitted after DisTube add a new playlist to the playing {@link Queue}.
635
630
  *
636
631
  * @event DisTube#addList
637
632
  * @param {Queue} queue The guild queue
@@ -642,7 +637,7 @@ exports.default = DisTube;
642
637
  * ));
643
638
  */
644
639
  /**
645
- * Emitted after DisTube add a new song to the playing {@link Queue}
640
+ * Emitted after DisTube add a new song to the playing {@link Queue}.
646
641
  *
647
642
  * @event DisTube#addSong
648
643
  * @param {Queue} queue The guild queue
@@ -653,16 +648,18 @@ exports.default = DisTube;
653
648
  * ));
654
649
  */
655
650
  /**
656
- * Emitted when there is no user in the voice channel, {@link DisTubeOptions}.leaveOnEmpty is `true` and there is a playing queue.
657
- * If there is no playing queue (stopped and {@link DisTubeOptions}.leaveOnStop is `false`), it will leave the channel without emitting this event.
651
+ * Emitted when there is no user in the voice channel,
652
+ * {@link DisTubeOptions}.leaveOnEmpty is `true` and there is a playing queue.
658
653
  *
654
+ * If there is no playing queue (stopped and {@link DisTubeOptions}.leaveOnStop is `false`),
655
+ * it will leave the channel without emitting this event.
659
656
  * @event DisTube#empty
660
657
  * @param {Queue} queue The guild queue
661
658
  * @example
662
659
  * distube.on("empty", queue => queue.textChannel.send("Channel is empty. Leaving the channel"))
663
660
  */
664
661
  /**
665
- * Emitted when {@link DisTube} encounters an error.
662
+ * Emitted when DisTube encounters an error.
666
663
  *
667
664
  * @event DisTube#error
668
665
  * @param {Discord.TextChannel} channel Text channel where the error is encountered.
@@ -674,7 +671,7 @@ exports.default = DisTube;
674
671
  */
675
672
  /**
676
673
  * Emitted when there is no more song in the queue and {@link Queue#autoplay} is `false`.
677
- * DisTube will leave voice channel if {@link DisTubeOptions}.leaveOnFinish is `true`
674
+ * DisTube will leave voice channel if {@link DisTubeOptions}.leaveOnFinish is `true`.
678
675
  *
679
676
  * @event DisTube#finish
680
677
  * @param {Queue} queue The guild queue
@@ -693,8 +690,8 @@ exports.default = DisTube;
693
690
  * });
694
691
  */
695
692
  /**
696
- * Emitted when {@link Queue#autoplay} is `true`, the {@link Queue#songs} is empty and
697
- * DisTube cannot find related songs to play
693
+ * Emitted when {@link Queue#autoplay} is `true`, {@link Queue#songs} is empty,
694
+ * and DisTube cannot find related songs to play.
698
695
  *
699
696
  * @event DisTube#noRelated
700
697
  * @param {Queue} queue The guild queue
@@ -703,19 +700,20 @@ exports.default = DisTube;
703
700
  */
704
701
  /**
705
702
  * Emitted when DisTube play a song.
706
- * If {@link DisTubeOptions}.emitNewSongOnly is `true`, event is not emitted when looping a song or next song is the previous one
703
+ *
704
+ * If {@link DisTubeOptions}.emitNewSongOnly is `true`,
705
+ * this event is not emitted when looping a song or next song is the previous one.
707
706
  *
708
707
  * @event DisTube#playSong
709
708
  * @param {Queue} queue The guild queue
710
709
  * @param {Song} song Playing song
711
710
  * @example
712
- * const status = (queue) => `Volume: \`${queue.volume}%\` | Loop: \`${queue.repeatMode ? queue.repeatMode == 2 ? "Server Queue" : "This Song" : "Off"}\` | Autoplay: \`${queue.autoplay ? "On" : "Off"}\``;
713
711
  * distube.on("playSong", (queue, song) => queue.textChannel.send(
714
- * `Playing \`${song.name}\` - \`${song.formattedDuration}\`\nRequested by: ${song.user}\n${status(queue)}`
712
+ * `Playing \`${song.name}\` - \`${song.formattedDuration}\`\nRequested by: ${song.user}`
715
713
  * ));
716
714
  */
717
715
  /**
718
- * Emitted when DisTube cannot find any results for the query
716
+ * Emitted when DisTube cannot find any results for the query.
719
717
  *
720
718
  * @event DisTube#searchNoResult
721
719
  * @param {Discord.Message} message The user message called play method
@@ -724,9 +722,9 @@ exports.default = DisTube;
724
722
  * distube.on("searchNoResult", (message, query) => message.channel.send(`No result found for ${query}!`));
725
723
  */
726
724
  /**
727
- * Emitted when {@link DisTubeOptions|DisTubeOptions.searchSongs} bigger than 0
728
- * and song param of {@link DisTube#play|play()} is invalid url.
729
- * DisTube will wait for user's next message to choose song manually.
725
+ * Emitted when {@link DisTubeOptions|DisTubeOptions.searchSongs} bigger than 0,
726
+ * and song param of {@link DisTube#playVoiceChannel} is invalid url.
727
+ * DisTube will wait for user's next message to choose a song manually.
730
728
  * <info>{@link https://support.google.com/youtube/answer/7354993|Safe search} is enabled
731
729
  * if {@link DisTubeOptions}.nsfw is disabled and the message's channel is not a nsfw channel.</info>
732
730
  *
@@ -737,12 +735,14 @@ exports.default = DisTube;
737
735
  * @example
738
736
  * // DisTubeOptions.searchSongs > 0
739
737
  * distube.on("searchResult", (message, results) => {
740
- * message.channel.send(`**Choose an option from below**\n${results.map((song, i) => `**${i + 1}**. ${song.name} - \`${song.formattedDuration}\``).join("\n")}\n*Enter anything else or wait 60 seconds to cancel*`);
738
+ * message.channel.send(`**Choose an option from below**\n${
739
+ * results.map((song, i) => `**${i + 1}**. ${song.name} - \`${song.formattedDuration}\``).join("\n")
740
+ * }\n*Enter anything else or wait 60 seconds to cancel*`);
741
741
  * });
742
742
  */
743
743
  /**
744
- * Emitted when {@link DisTubeOptions|DisTubeOptions.searchSongs} bigger than 0
745
- * and the search canceled due to {@link DisTubeOptions|DisTubeOptions.searchTimeout}
744
+ * Emitted when {@link DisTubeOptions|DisTubeOptions.searchSongs} bigger than 0,
745
+ * and the search canceled due to {@link DisTubeOptions|DisTubeOptions.searchTimeout}.
746
746
  *
747
747
  * @event DisTube#searchCancel
748
748
  * @param {Discord.Message} message The user message called play method
@@ -752,8 +752,8 @@ exports.default = DisTube;
752
752
  * distube.on("searchCancel", (message) => message.channel.send(`Searching canceled`));
753
753
  */
754
754
  /**
755
- * Emitted when {@link DisTubeOptions|DisTubeOptions.searchSongs} bigger than 0
756
- * and the search canceled due to user's next message is not a number or out of results range
755
+ * Emitted when {@link DisTubeOptions|DisTubeOptions.searchSongs} bigger than 0,
756
+ * and the search canceled due to user's next message is not a number or out of results range.
757
757
  *
758
758
  * @event DisTube#searchInvalidAnswer
759
759
  * @param {Discord.Message} message The user message called play method
@@ -764,8 +764,8 @@ exports.default = DisTube;
764
764
  * distube.on("searchInvalidAnswer", (message) => message.channel.send(`You answered an invalid number!`));
765
765
  */
766
766
  /**
767
- * Emitted when {@link DisTubeOptions|DisTubeOptions.searchSongs} bigger than 0
768
- * and after the user chose a search result to play
767
+ * Emitted when {@link DisTubeOptions|DisTubeOptions.searchSongs} bigger than 0,
768
+ * and after the user chose a search result to play.
769
769
  *
770
770
  * @event DisTube#searchDone
771
771
  * @param {Discord.Message} message The user message called play method
@@ -773,7 +773,7 @@ exports.default = DisTube;
773
773
  * @param {string} query The search query
774
774
  */
775
775
  /**
776
- * Emitted when the bot is disconnected to the voice channel
776
+ * Emitted when the bot is disconnected to a voice channel.
777
777
  *
778
778
  * @event DisTube#disconnect
779
779
  * @param {Queue} queue The guild queue
@@ -785,7 +785,7 @@ exports.default = DisTube;
785
785
  * @param {Queue} queue The guild queue
786
786
  */
787
787
  /**
788
- * Emitted when DisTube finished a song
788
+ * Emitted when DisTube finished a song.
789
789
  *
790
790
  * @event DisTube#finishSong
791
791
  * @param {Queue} queue The guild queue