distube 5.0.5 → 5.0.7

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
@@ -19,31 +19,61 @@
19
19
 
20
20
  # DisTube
21
21
 
22
- A powerful Discord.js module for simplifying music commands and effortless playback of various sources with integrated audio filters.
22
+ DisTube is a comprehensive Discord music bot library built for Discord.js, offering simplified music commands, effortless playback from diverse sources, and integrated audio filters.
23
23
 
24
- [DisTube Support Server](https://discord.gg/feaDd9h) - [Frequently Asked Questions](https://discord.gg/feaDd9h)
24
+ ## 🌟 Features
25
25
 
26
- ## Features
26
+ - **Easy Integration**: Built on top of [discord.js](https://discord.js.org) v14 and [@discordjs/voice](https://discord.js.org)
27
+ - **Voice Management**: Robust handling of voice connections and queue management
28
+ - **Audio Filters**: Built-in filters (bassboost, echo, karaoke, etc.) and custom filter support
29
+ - **Plugin System**: Extensible architecture supporting various music sources through plugins
30
+ - **Type Safety**: Written in TypeScript for better development experience
31
+ - **Active Community**: Join our [Discord Support Server](https://discord.gg/feaDd9h) for help
27
32
 
28
- - Easy Integration: Built on top of [discord.js](https://discord.js.org) v14 and [@discordjs/voice](https://discord.js.org).
29
- - Voice and Queue Management: Handles voice channel connections, disconnections, and manages music queues efficiently.
30
- - Audio Filters: Offers built-in audio filters (bassboost, echo, karaoke, etc.) and allows for custom filter implementations.
31
- - Plugin System: Supports extensibility through plugins
32
- > DisTube does not have built-in support for music sources. You need to use plugins to add support for them.
33
-
34
- ## Requirement
33
+ ## 📋 Requirements
35
34
 
36
35
  - Node.js 18.17.0 or higher
37
36
  - [discord.js](https://discord.js.org) v14
38
37
  - [@discordjs/voice](https://github.com/discordjs/voice)
39
38
  - [@discordjs/opus](https://github.com/discordjs/opus)
40
39
  - [FFmpeg](https://www.ffmpeg.org/download.html)
40
+
41
+ ### 🔒 Encryption Libraries
42
+
43
+ > [!NOTE]
44
+ > You only need to install one of these libraries if your system does not support `aes-256-gcm` (verify by running `require('node:crypto').getCiphers().includes('aes-256-gcm')`).
45
+
46
+ - [@noble/ciphers](https://www.npmjs.com/package/@noble/ciphers)
41
47
  - [sodium-native](https://www.npmjs.com/package/sodium-native)
42
48
 
43
- ## Documentation
49
+ ## 🚀 Installation
50
+
51
+ ```bash
52
+ npm install distube @discordjs/voice @discordjs/opus
53
+ ```
54
+
55
+ For FFmpeg installation:
56
+
57
+ - [Windows Guide](http://blog.gregzaal.com/how-to-install-ffmpeg-on-windows/)
58
+ - [Linux Guide](https://www.tecmint.com/install-ffmpeg-in-linux/)
59
+
60
+ > [!NOTE]
61
+ > Alternative FFmpeg builds available [here](https://github.com/BtbN/FFmpeg-Builds/releases)
62
+
63
+ ## 📚 Documentation
64
+
65
+ - [API Documentation](https://distube.js.org/) - Detailed API reference
66
+ - [DisTube Guide](https://github.com/skick1234/DisTube/wiki) - Step-by-step guide for beginners
67
+ - [Plugin List](https://github.com/skick1234/DisTube/wiki/Projects-Hub#plugins) - Available plugins for music sources
68
+
69
+ ## 🤝 Contributing
70
+
71
+ Contributions are welcome! Please read our [Contributing Guidelines](https://github.com/skick1234/DisTube/blob/main/.github/CONTRIBUTING.md) before submitting a pull request.
72
+
73
+ ## 📄 License
44
74
 
45
- Read DisTube's definitions, properties and events details in the [API Documentation page](https://distube.js.org/).
75
+ Licensed under [MIT License](https://github.com/skick1234/DisTube/blob/main/LICENSE)
46
76
 
47
- Learn how to build a music bot from scratch with [DisTube Guide](https://github.com/skick1234/DisTube/wiki)
77
+ ## 💖 Support
48
78
 
49
- [List of plugins](https://github.com/skick1234/DisTube/wiki/Projects-Hub#plugins) for supporting various sites
79
+ <a href='https://ko-fi.com/skick' target='_blank'><img height='48' src='https://storage.ko-fi.com/cdn/kofi3.png' alt='Support me on Ko-fi' /></a>
package/dist/index.d.mts CHANGED
@@ -387,7 +387,7 @@ declare class TaskQueue {
387
387
  /**
388
388
  * Waits for last task finished and queues a new task
389
389
  */
390
- queuing(): Promise<void>;
390
+ queuing(isPlay?: boolean): Promise<void>;
391
391
  /**
392
392
  * Removes the finished task and processes the next task
393
393
  */
@@ -396,6 +396,10 @@ declare class TaskQueue {
396
396
  * The remaining number of tasks
397
397
  */
398
398
  get remaining(): number;
399
+ /**
400
+ * Whether or not having a play task
401
+ */
402
+ get hasPlayTask(): boolean;
399
403
  }
400
404
 
401
405
  /**
package/dist/index.d.ts CHANGED
@@ -387,7 +387,7 @@ declare class TaskQueue {
387
387
  /**
388
388
  * Waits for last task finished and queues a new task
389
389
  */
390
- queuing(): Promise<void>;
390
+ queuing(isPlay?: boolean): Promise<void>;
391
391
  /**
392
392
  * Removes the finished task and processes the next task
393
393
  */
@@ -396,6 +396,10 @@ declare class TaskQueue {
396
396
  * The remaining number of tasks
397
397
  */
398
398
  get remaining(): number;
399
+ /**
400
+ * Whether or not having a play task
401
+ */
402
+ get hasPlayTask(): boolean;
399
403
  }
400
404
 
401
405
  /**
package/dist/index.js CHANGED
@@ -1,7 +1,9 @@
1
1
  "use strict";
2
+ var __create = Object.create;
2
3
  var __defProp = Object.defineProperty;
3
4
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
5
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
5
7
  var __hasOwnProp = Object.prototype.hasOwnProperty;
6
8
  var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
7
9
  var __export = (target, all) => {
@@ -16,6 +18,14 @@ var __copyProps = (to, from, except, desc) => {
16
18
  }
17
19
  return to;
18
20
  };
21
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
22
+ // If the importer is in node compatibility mode or this is not an ESM
23
+ // file that has been converted to a CommonJS file using a Babel-
24
+ // compatible transform (i.e. "__esModule" has not been set), then set
25
+ // "default" to the CommonJS "module.exports" for node compatibility.
26
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
27
+ mod
28
+ ));
19
29
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
20
30
 
21
31
  // src/index.ts
@@ -152,7 +162,7 @@ var ERROR_MESSAGES = {
152
162
  VOICE_DIFFERENT_CLIENT: "Cannot join a voice channel created by a different client",
153
163
  FFMPEG_EXITED: /* @__PURE__ */ __name((code) => `ffmpeg exited with code ${code}`, "FFMPEG_EXITED"),
154
164
  FFMPEG_NOT_INSTALLED: /* @__PURE__ */ __name((path) => `ffmpeg is not installed at '${path}' path`, "FFMPEG_NOT_INSTALLED"),
155
- ENCRYPTION_LIBRARIES_MISSING: "Cannot play audio as no valid encryption package is installed.\nPlease install sodium-native, sodium, libsodium-wrappers, or tweetnacl.",
165
+ ENCRYPTION_LIBRARIES_MISSING: "Cannot play audio as no valid encryption package is installed and your node doesn't support aes-256-gcm.\nPlease install @noble/ciphers, @stablelib/xchacha20poly1305, sodium-native or libsodium-wrappers.",
156
166
  NO_QUEUE: "There is no playing queue in this guild",
157
167
  QUEUE_EXIST: "This guild has a Queue already",
158
168
  QUEUE_STOPPED: "The queue has been stopped already",
@@ -207,7 +217,9 @@ var Task = class {
207
217
  }
208
218
  resolve;
209
219
  promise;
210
- constructor() {
220
+ isPlay;
221
+ constructor(isPlay) {
222
+ this.isPlay = isPlay;
211
223
  this.promise = new Promise((res) => {
212
224
  this.resolve = res;
213
225
  });
@@ -224,9 +236,9 @@ var TaskQueue = class {
224
236
  /**
225
237
  * Waits for last task finished and queues a new task
226
238
  */
227
- queuing() {
239
+ queuing(isPlay = false) {
228
240
  const next = this.remaining ? this.#tasks[this.#tasks.length - 1].promise : Promise.resolve();
229
- this.#tasks.push(new Task());
241
+ this.#tasks.push(new Task(isPlay));
230
242
  return next;
231
243
  }
232
244
  /**
@@ -241,6 +253,12 @@ var TaskQueue = class {
241
253
  get remaining() {
242
254
  return this.#tasks.length;
243
255
  }
256
+ /**
257
+ * Whether or not having a play task
258
+ */
259
+ get hasPlayTask() {
260
+ return this.#tasks.some((t) => t.isPlay);
261
+ }
244
262
  };
245
263
 
246
264
  // src/struct/Playlist.ts
@@ -1891,9 +1909,6 @@ var Queue = class extends DisTubeBase {
1891
1909
  async stop() {
1892
1910
  await this._taskQueue.queuing();
1893
1911
  try {
1894
- this.playing = false;
1895
- this.paused = false;
1896
- this.stopped = true;
1897
1912
  this.voice.stop();
1898
1913
  this.remove();
1899
1914
  } finally {
@@ -1904,14 +1919,12 @@ var Queue = class extends DisTubeBase {
1904
1919
  * Remove the queue from the manager
1905
1920
  */
1906
1921
  remove() {
1922
+ this.playing = false;
1923
+ this.paused = false;
1907
1924
  this.stopped = true;
1908
1925
  this.songs = [];
1909
1926
  this.previousSongs = [];
1910
- if (this._listeners) {
1911
- for (const event of objectKeys(this._listeners)) {
1912
- this.voice.off(event, this._listeners[event]);
1913
- }
1914
- }
1927
+ if (this._listeners) for (const event of objectKeys(this._listeners)) this.voice.off(event, this._listeners[event]);
1915
1928
  this.queues.remove(this.id);
1916
1929
  this.emit("deleteQueue" /* DELETE_QUEUE */, this);
1917
1930
  }
@@ -2086,7 +2099,15 @@ function isNsfwChannel(channel) {
2086
2099
  __name(isNsfwChannel, "isNsfwChannel");
2087
2100
  var isTruthy = /* @__PURE__ */ __name((x) => Boolean(x), "isTruthy");
2088
2101
  var checkEncryptionLibraries = /* @__PURE__ */ __name(async () => {
2089
- for (const lib of ["sodium-native", "sodium", "libsodium-wrappers", "tweetnacl"]) {
2102
+ if (await import("crypto").then((m) => m.getCiphers().includes("aes-256-gcm"))) return true;
2103
+ for (const lib of [
2104
+ "@noble/ciphers",
2105
+ "@stablelib/xchacha20poly1305",
2106
+ "sodium-native",
2107
+ "sodium",
2108
+ "libsodium-wrappers",
2109
+ "tweetnacl"
2110
+ ]) {
2090
2111
  try {
2091
2112
  await import(lib);
2092
2113
  return true;
@@ -2273,7 +2294,7 @@ var DisTube = class extends import_tiny_typed_emitter3.TypedEmitter {
2273
2294
  throw new DisTubeError("INVALID_TYPE", "Discord.GuildMember", member, "options.member");
2274
2295
  }
2275
2296
  const queue = this.getQueue(voiceChannel) || await this.queues.create(voiceChannel, textChannel);
2276
- await queue._taskQueue.queuing();
2297
+ await queue._taskQueue.queuing(true);
2277
2298
  try {
2278
2299
  this.debug(`[${queue.id}] Playing input: ${song}`);
2279
2300
  const resolved = await this.handler.resolve(song, { member, metadata });
@@ -2309,6 +2330,7 @@ ${e.message}`;
2309
2330
  }
2310
2331
  throw e;
2311
2332
  } finally {
2333
+ if (!queue.songs.length && !queue._taskQueue.hasPlayTask) queue.remove();
2312
2334
  queue._taskQueue.resolve();
2313
2335
  }
2314
2336
  }
@@ -2485,7 +2507,7 @@ ${e.message}`;
2485
2507
  };
2486
2508
 
2487
2509
  // src/index.ts
2488
- var version = "5.0.5";
2510
+ var version = "5.0.7";
2489
2511
  // Annotate the CommonJS export names for ESM import in node:
2490
2512
  0 && (module.exports = {
2491
2513
  BaseManager,