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 +44 -14
- package/dist/index.d.mts +5 -1
- package/dist/index.d.ts +5 -1
- package/dist/index.js +37 -15
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +27 -15
- package/dist/index.mjs.map +1 -1
- package/package.json +12 -14
package/dist/index.mjs
CHANGED
|
@@ -83,7 +83,7 @@ var ERROR_MESSAGES = {
|
|
|
83
83
|
VOICE_DIFFERENT_CLIENT: "Cannot join a voice channel created by a different client",
|
|
84
84
|
FFMPEG_EXITED: /* @__PURE__ */ __name((code) => `ffmpeg exited with code ${code}`, "FFMPEG_EXITED"),
|
|
85
85
|
FFMPEG_NOT_INSTALLED: /* @__PURE__ */ __name((path) => `ffmpeg is not installed at '${path}' path`, "FFMPEG_NOT_INSTALLED"),
|
|
86
|
-
ENCRYPTION_LIBRARIES_MISSING: "Cannot play audio as no valid encryption package is installed.\nPlease install sodium-native
|
|
86
|
+
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.",
|
|
87
87
|
NO_QUEUE: "There is no playing queue in this guild",
|
|
88
88
|
QUEUE_EXIST: "This guild has a Queue already",
|
|
89
89
|
QUEUE_STOPPED: "The queue has been stopped already",
|
|
@@ -138,7 +138,9 @@ var Task = class {
|
|
|
138
138
|
}
|
|
139
139
|
resolve;
|
|
140
140
|
promise;
|
|
141
|
-
|
|
141
|
+
isPlay;
|
|
142
|
+
constructor(isPlay) {
|
|
143
|
+
this.isPlay = isPlay;
|
|
142
144
|
this.promise = new Promise((res) => {
|
|
143
145
|
this.resolve = res;
|
|
144
146
|
});
|
|
@@ -155,9 +157,9 @@ var TaskQueue = class {
|
|
|
155
157
|
/**
|
|
156
158
|
* Waits for last task finished and queues a new task
|
|
157
159
|
*/
|
|
158
|
-
queuing() {
|
|
160
|
+
queuing(isPlay = false) {
|
|
159
161
|
const next = this.remaining ? this.#tasks[this.#tasks.length - 1].promise : Promise.resolve();
|
|
160
|
-
this.#tasks.push(new Task());
|
|
162
|
+
this.#tasks.push(new Task(isPlay));
|
|
161
163
|
return next;
|
|
162
164
|
}
|
|
163
165
|
/**
|
|
@@ -172,6 +174,12 @@ var TaskQueue = class {
|
|
|
172
174
|
get remaining() {
|
|
173
175
|
return this.#tasks.length;
|
|
174
176
|
}
|
|
177
|
+
/**
|
|
178
|
+
* Whether or not having a play task
|
|
179
|
+
*/
|
|
180
|
+
get hasPlayTask() {
|
|
181
|
+
return this.#tasks.some((t) => t.isPlay);
|
|
182
|
+
}
|
|
175
183
|
};
|
|
176
184
|
|
|
177
185
|
// src/struct/Playlist.ts
|
|
@@ -1829,9 +1837,6 @@ var Queue = class extends DisTubeBase {
|
|
|
1829
1837
|
async stop() {
|
|
1830
1838
|
await this._taskQueue.queuing();
|
|
1831
1839
|
try {
|
|
1832
|
-
this.playing = false;
|
|
1833
|
-
this.paused = false;
|
|
1834
|
-
this.stopped = true;
|
|
1835
1840
|
this.voice.stop();
|
|
1836
1841
|
this.remove();
|
|
1837
1842
|
} finally {
|
|
@@ -1842,14 +1847,12 @@ var Queue = class extends DisTubeBase {
|
|
|
1842
1847
|
* Remove the queue from the manager
|
|
1843
1848
|
*/
|
|
1844
1849
|
remove() {
|
|
1850
|
+
this.playing = false;
|
|
1851
|
+
this.paused = false;
|
|
1845
1852
|
this.stopped = true;
|
|
1846
1853
|
this.songs = [];
|
|
1847
1854
|
this.previousSongs = [];
|
|
1848
|
-
if (this._listeners)
|
|
1849
|
-
for (const event of objectKeys(this._listeners)) {
|
|
1850
|
-
this.voice.off(event, this._listeners[event]);
|
|
1851
|
-
}
|
|
1852
|
-
}
|
|
1855
|
+
if (this._listeners) for (const event of objectKeys(this._listeners)) this.voice.off(event, this._listeners[event]);
|
|
1853
1856
|
this.queues.remove(this.id);
|
|
1854
1857
|
this.emit("deleteQueue" /* DELETE_QUEUE */, this);
|
|
1855
1858
|
}
|
|
@@ -2024,7 +2027,15 @@ function isNsfwChannel(channel) {
|
|
|
2024
2027
|
__name(isNsfwChannel, "isNsfwChannel");
|
|
2025
2028
|
var isTruthy = /* @__PURE__ */ __name((x) => Boolean(x), "isTruthy");
|
|
2026
2029
|
var checkEncryptionLibraries = /* @__PURE__ */ __name(async () => {
|
|
2027
|
-
|
|
2030
|
+
if (await import("node:crypto").then((m) => m.getCiphers().includes("aes-256-gcm"))) return true;
|
|
2031
|
+
for (const lib of [
|
|
2032
|
+
"@noble/ciphers",
|
|
2033
|
+
"@stablelib/xchacha20poly1305",
|
|
2034
|
+
"sodium-native",
|
|
2035
|
+
"sodium",
|
|
2036
|
+
"libsodium-wrappers",
|
|
2037
|
+
"tweetnacl"
|
|
2038
|
+
]) {
|
|
2028
2039
|
try {
|
|
2029
2040
|
await import(lib);
|
|
2030
2041
|
return true;
|
|
@@ -2211,7 +2222,7 @@ var DisTube = class extends TypedEmitter3 {
|
|
|
2211
2222
|
throw new DisTubeError("INVALID_TYPE", "Discord.GuildMember", member, "options.member");
|
|
2212
2223
|
}
|
|
2213
2224
|
const queue = this.getQueue(voiceChannel) || await this.queues.create(voiceChannel, textChannel);
|
|
2214
|
-
await queue._taskQueue.queuing();
|
|
2225
|
+
await queue._taskQueue.queuing(true);
|
|
2215
2226
|
try {
|
|
2216
2227
|
this.debug(`[${queue.id}] Playing input: ${song}`);
|
|
2217
2228
|
const resolved = await this.handler.resolve(song, { member, metadata });
|
|
@@ -2247,6 +2258,7 @@ ${e.message}`;
|
|
|
2247
2258
|
}
|
|
2248
2259
|
throw e;
|
|
2249
2260
|
} finally {
|
|
2261
|
+
if (!queue.songs.length && !queue._taskQueue.hasPlayTask) queue.remove();
|
|
2250
2262
|
queue._taskQueue.resolve();
|
|
2251
2263
|
}
|
|
2252
2264
|
}
|
|
@@ -2423,7 +2435,7 @@ ${e.message}`;
|
|
|
2423
2435
|
};
|
|
2424
2436
|
|
|
2425
2437
|
// src/index.ts
|
|
2426
|
-
var version = "5.0.
|
|
2438
|
+
var version = "5.0.7";
|
|
2427
2439
|
export {
|
|
2428
2440
|
BaseManager,
|
|
2429
2441
|
DisTube,
|