distube 5.0.4 → 5.0.6
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 +6 -5
- package/dist/index.d.ts +6 -5
- package/dist/index.js +55 -19
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +42 -16
- package/dist/index.mjs.map +1 -1
- package/package.json +19 -20
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",
|
|
@@ -501,6 +501,7 @@ var DisTubeVoice = class extends TypedEmitter {
|
|
|
501
501
|
emittedError;
|
|
502
502
|
isDisconnected = false;
|
|
503
503
|
stream;
|
|
504
|
+
pausingStream;
|
|
504
505
|
#channel;
|
|
505
506
|
#volume = 100;
|
|
506
507
|
constructor(voiceManager, channel) {
|
|
@@ -634,11 +635,15 @@ var DisTubeVoice = class extends TypedEmitter {
|
|
|
634
635
|
this.emittedError = true;
|
|
635
636
|
this.emit("error", error);
|
|
636
637
|
});
|
|
637
|
-
if (this.audioPlayer.state.status !== AudioPlayerStatus.Paused)
|
|
638
|
-
|
|
638
|
+
if (this.audioPlayer.state.status !== AudioPlayerStatus.Paused) {
|
|
639
|
+
this.audioPlayer.play(dtStream.audioResource);
|
|
640
|
+
this.stream?.kill();
|
|
641
|
+
dtStream.spawn();
|
|
642
|
+
} else if (!this.pausingStream) {
|
|
643
|
+
this.pausingStream = this.stream;
|
|
644
|
+
}
|
|
639
645
|
this.stream = dtStream;
|
|
640
646
|
this.volume = this.#volume;
|
|
641
|
-
dtStream.spawn();
|
|
642
647
|
}
|
|
643
648
|
set volume(volume) {
|
|
644
649
|
if (typeof volume !== "number" || isNaN(volume)) {
|
|
@@ -670,6 +675,9 @@ var DisTubeVoice = class extends TypedEmitter {
|
|
|
670
675
|
if (state.status !== AudioPlayerStatus.Paused) return;
|
|
671
676
|
if (this.stream?.audioResource && state.resource !== this.stream.audioResource) {
|
|
672
677
|
this.audioPlayer.play(this.stream.audioResource);
|
|
678
|
+
this.stream.spawn();
|
|
679
|
+
this.pausingStream?.kill();
|
|
680
|
+
delete this.pausingStream;
|
|
673
681
|
} else {
|
|
674
682
|
this.audioPlayer.unpause();
|
|
675
683
|
}
|
|
@@ -1629,21 +1637,31 @@ var Queue = class extends DisTubeBase {
|
|
|
1629
1637
|
* Pause the guild stream
|
|
1630
1638
|
* @returns The guild queue
|
|
1631
1639
|
*/
|
|
1632
|
-
pause() {
|
|
1633
|
-
|
|
1634
|
-
|
|
1635
|
-
|
|
1636
|
-
|
|
1640
|
+
async pause() {
|
|
1641
|
+
await this._taskQueue.queuing();
|
|
1642
|
+
try {
|
|
1643
|
+
if (this.paused) throw new DisTubeError("PAUSED");
|
|
1644
|
+
this.paused = true;
|
|
1645
|
+
this.voice.pause();
|
|
1646
|
+
return this;
|
|
1647
|
+
} finally {
|
|
1648
|
+
this._taskQueue.resolve();
|
|
1649
|
+
}
|
|
1637
1650
|
}
|
|
1638
1651
|
/**
|
|
1639
1652
|
* Resume the guild stream
|
|
1640
1653
|
* @returns The guild queue
|
|
1641
1654
|
*/
|
|
1642
|
-
resume() {
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
|
|
1646
|
-
|
|
1655
|
+
async resume() {
|
|
1656
|
+
await this._taskQueue.queuing();
|
|
1657
|
+
try {
|
|
1658
|
+
if (!this.paused) throw new DisTubeError("RESUMED");
|
|
1659
|
+
this.paused = false;
|
|
1660
|
+
this.voice.unpause();
|
|
1661
|
+
return this;
|
|
1662
|
+
} finally {
|
|
1663
|
+
this._taskQueue.resolve();
|
|
1664
|
+
}
|
|
1647
1665
|
}
|
|
1648
1666
|
/**
|
|
1649
1667
|
* Set the guild stream's volume
|
|
@@ -2006,7 +2024,15 @@ function isNsfwChannel(channel) {
|
|
|
2006
2024
|
__name(isNsfwChannel, "isNsfwChannel");
|
|
2007
2025
|
var isTruthy = /* @__PURE__ */ __name((x) => Boolean(x), "isTruthy");
|
|
2008
2026
|
var checkEncryptionLibraries = /* @__PURE__ */ __name(async () => {
|
|
2009
|
-
|
|
2027
|
+
if (await import("node:crypto").then((m) => m.getCiphers().includes("aes-256-gcm"))) return true;
|
|
2028
|
+
for (const lib of [
|
|
2029
|
+
"@noble/ciphers",
|
|
2030
|
+
"@stablelib/xchacha20poly1305",
|
|
2031
|
+
"sodium-native",
|
|
2032
|
+
"sodium",
|
|
2033
|
+
"libsodium-wrappers",
|
|
2034
|
+
"tweetnacl"
|
|
2035
|
+
]) {
|
|
2010
2036
|
try {
|
|
2011
2037
|
await import(lib);
|
|
2012
2038
|
return true;
|
|
@@ -2405,7 +2431,7 @@ ${e.message}`;
|
|
|
2405
2431
|
};
|
|
2406
2432
|
|
|
2407
2433
|
// src/index.ts
|
|
2408
|
-
var version = "5.0.
|
|
2434
|
+
var version = "5.0.6";
|
|
2409
2435
|
export {
|
|
2410
2436
|
BaseManager,
|
|
2411
2437
|
DisTube,
|