distube 5.0.4 → 5.0.5
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/dist/index.d.mts +6 -5
- package/dist/index.d.ts +6 -5
- package/dist/index.js +35 -17
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +32 -14
- package/dist/index.mjs.map +1 -1
- package/package.json +19 -20
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as discord_js from 'discord.js';
|
|
2
|
-
import { Snowflake, Message, GuildTextBasedChannel, VoiceBasedChannel, VoiceState, Guild,
|
|
2
|
+
import { GuildMember, Snowflake, Message, GuildTextBasedChannel, VoiceBasedChannel, VoiceState, Guild, Interaction, Client, Collection, ClientOptions } from 'discord.js';
|
|
3
3
|
import { TypedEmitter } from 'tiny-typed-emitter';
|
|
4
4
|
import { AudioPlayer, VoiceConnection, AudioResource } from '@discordjs/voice';
|
|
5
5
|
import { Transform, TransformCallback } from 'stream';
|
|
@@ -637,6 +637,7 @@ declare class DisTubeVoice extends TypedEmitter<DisTubeVoiceEvents> {
|
|
|
637
637
|
emittedError: boolean;
|
|
638
638
|
isDisconnected: boolean;
|
|
639
639
|
stream?: DisTubeStream;
|
|
640
|
+
pausingStream?: DisTubeStream;
|
|
640
641
|
constructor(voiceManager: DisTubeVoiceManager, channel: VoiceBasedChannel);
|
|
641
642
|
/**
|
|
642
643
|
* The voice channel id the bot is in
|
|
@@ -1026,12 +1027,12 @@ declare class Queue extends DisTubeBase {
|
|
|
1026
1027
|
* Pause the guild stream
|
|
1027
1028
|
* @returns The guild queue
|
|
1028
1029
|
*/
|
|
1029
|
-
pause(): Queue
|
|
1030
|
+
pause(): Promise<Queue>;
|
|
1030
1031
|
/**
|
|
1031
1032
|
* Resume the guild stream
|
|
1032
1033
|
* @returns The guild queue
|
|
1033
1034
|
*/
|
|
1034
|
-
resume(): Queue
|
|
1035
|
+
resume(): Promise<Queue>;
|
|
1035
1036
|
/**
|
|
1036
1037
|
* Set the guild stream's volume
|
|
1037
1038
|
* @param percent - The percentage of volume you want to set
|
|
@@ -1390,13 +1391,13 @@ declare class DisTube extends TypedEmitter<TypedDisTubeEvents> {
|
|
|
1390
1391
|
* @param guild - The type can be resolved to give a {@link Queue}
|
|
1391
1392
|
* @returns The guild queue
|
|
1392
1393
|
*/
|
|
1393
|
-
pause(guild: GuildIdResolvable): Queue
|
|
1394
|
+
pause(guild: GuildIdResolvable): Promise<Queue>;
|
|
1394
1395
|
/**
|
|
1395
1396
|
* Resume the guild stream
|
|
1396
1397
|
* @param guild - The type can be resolved to give a {@link Queue}
|
|
1397
1398
|
* @returns The guild queue
|
|
1398
1399
|
*/
|
|
1399
|
-
resume(guild: GuildIdResolvable): Queue
|
|
1400
|
+
resume(guild: GuildIdResolvable): Promise<Queue>;
|
|
1400
1401
|
/**
|
|
1401
1402
|
* Stop the guild stream
|
|
1402
1403
|
* @param guild - The type can be resolved to give a {@link Queue}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as discord_js from 'discord.js';
|
|
2
|
-
import { Snowflake, Message, GuildTextBasedChannel, VoiceBasedChannel, VoiceState, Guild,
|
|
2
|
+
import { GuildMember, Snowflake, Message, GuildTextBasedChannel, VoiceBasedChannel, VoiceState, Guild, Interaction, Client, Collection, ClientOptions } from 'discord.js';
|
|
3
3
|
import { TypedEmitter } from 'tiny-typed-emitter';
|
|
4
4
|
import { AudioPlayer, VoiceConnection, AudioResource } from '@discordjs/voice';
|
|
5
5
|
import { Transform, TransformCallback } from 'stream';
|
|
@@ -637,6 +637,7 @@ declare class DisTubeVoice extends TypedEmitter<DisTubeVoiceEvents> {
|
|
|
637
637
|
emittedError: boolean;
|
|
638
638
|
isDisconnected: boolean;
|
|
639
639
|
stream?: DisTubeStream;
|
|
640
|
+
pausingStream?: DisTubeStream;
|
|
640
641
|
constructor(voiceManager: DisTubeVoiceManager, channel: VoiceBasedChannel);
|
|
641
642
|
/**
|
|
642
643
|
* The voice channel id the bot is in
|
|
@@ -1026,12 +1027,12 @@ declare class Queue extends DisTubeBase {
|
|
|
1026
1027
|
* Pause the guild stream
|
|
1027
1028
|
* @returns The guild queue
|
|
1028
1029
|
*/
|
|
1029
|
-
pause(): Queue
|
|
1030
|
+
pause(): Promise<Queue>;
|
|
1030
1031
|
/**
|
|
1031
1032
|
* Resume the guild stream
|
|
1032
1033
|
* @returns The guild queue
|
|
1033
1034
|
*/
|
|
1034
|
-
resume(): Queue
|
|
1035
|
+
resume(): Promise<Queue>;
|
|
1035
1036
|
/**
|
|
1036
1037
|
* Set the guild stream's volume
|
|
1037
1038
|
* @param percent - The percentage of volume you want to set
|
|
@@ -1390,13 +1391,13 @@ declare class DisTube extends TypedEmitter<TypedDisTubeEvents> {
|
|
|
1390
1391
|
* @param guild - The type can be resolved to give a {@link Queue}
|
|
1391
1392
|
* @returns The guild queue
|
|
1392
1393
|
*/
|
|
1393
|
-
pause(guild: GuildIdResolvable): Queue
|
|
1394
|
+
pause(guild: GuildIdResolvable): Promise<Queue>;
|
|
1394
1395
|
/**
|
|
1395
1396
|
* Resume the guild stream
|
|
1396
1397
|
* @param guild - The type can be resolved to give a {@link Queue}
|
|
1397
1398
|
* @returns The guild queue
|
|
1398
1399
|
*/
|
|
1399
|
-
resume(guild: GuildIdResolvable): Queue
|
|
1400
|
+
resume(guild: GuildIdResolvable): Promise<Queue>;
|
|
1400
1401
|
/**
|
|
1401
1402
|
* Stop the guild stream
|
|
1402
1403
|
* @param guild - The type can be resolved to give a {@link Queue}
|
package/dist/index.js
CHANGED
|
@@ -19,8 +19,8 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
19
19
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
20
|
|
|
21
21
|
// src/index.ts
|
|
22
|
-
var
|
|
23
|
-
__export(
|
|
22
|
+
var index_exports = {};
|
|
23
|
+
__export(index_exports, {
|
|
24
24
|
BaseManager: () => BaseManager,
|
|
25
25
|
DisTube: () => DisTube,
|
|
26
26
|
DisTubeBase: () => DisTubeBase,
|
|
@@ -68,7 +68,7 @@ __export(src_exports, {
|
|
|
68
68
|
resolveGuildId: () => resolveGuildId,
|
|
69
69
|
version: () => version
|
|
70
70
|
});
|
|
71
|
-
module.exports = __toCommonJS(
|
|
71
|
+
module.exports = __toCommonJS(index_exports);
|
|
72
72
|
|
|
73
73
|
// src/type.ts
|
|
74
74
|
var Events = /* @__PURE__ */ ((Events2) => {
|
|
@@ -563,6 +563,7 @@ var DisTubeVoice = class extends import_tiny_typed_emitter.TypedEmitter {
|
|
|
563
563
|
emittedError;
|
|
564
564
|
isDisconnected = false;
|
|
565
565
|
stream;
|
|
566
|
+
pausingStream;
|
|
566
567
|
#channel;
|
|
567
568
|
#volume = 100;
|
|
568
569
|
constructor(voiceManager, channel) {
|
|
@@ -696,11 +697,15 @@ var DisTubeVoice = class extends import_tiny_typed_emitter.TypedEmitter {
|
|
|
696
697
|
this.emittedError = true;
|
|
697
698
|
this.emit("error", error);
|
|
698
699
|
});
|
|
699
|
-
if (this.audioPlayer.state.status !== import_voice.AudioPlayerStatus.Paused)
|
|
700
|
-
|
|
700
|
+
if (this.audioPlayer.state.status !== import_voice.AudioPlayerStatus.Paused) {
|
|
701
|
+
this.audioPlayer.play(dtStream.audioResource);
|
|
702
|
+
this.stream?.kill();
|
|
703
|
+
dtStream.spawn();
|
|
704
|
+
} else if (!this.pausingStream) {
|
|
705
|
+
this.pausingStream = this.stream;
|
|
706
|
+
}
|
|
701
707
|
this.stream = dtStream;
|
|
702
708
|
this.volume = this.#volume;
|
|
703
|
-
dtStream.spawn();
|
|
704
709
|
}
|
|
705
710
|
set volume(volume) {
|
|
706
711
|
if (typeof volume !== "number" || isNaN(volume)) {
|
|
@@ -732,6 +737,9 @@ var DisTubeVoice = class extends import_tiny_typed_emitter.TypedEmitter {
|
|
|
732
737
|
if (state.status !== import_voice.AudioPlayerStatus.Paused) return;
|
|
733
738
|
if (this.stream?.audioResource && state.resource !== this.stream.audioResource) {
|
|
734
739
|
this.audioPlayer.play(this.stream.audioResource);
|
|
740
|
+
this.stream.spawn();
|
|
741
|
+
this.pausingStream?.kill();
|
|
742
|
+
delete this.pausingStream;
|
|
735
743
|
} else {
|
|
736
744
|
this.audioPlayer.unpause();
|
|
737
745
|
}
|
|
@@ -1691,21 +1699,31 @@ var Queue = class extends DisTubeBase {
|
|
|
1691
1699
|
* Pause the guild stream
|
|
1692
1700
|
* @returns The guild queue
|
|
1693
1701
|
*/
|
|
1694
|
-
pause() {
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
|
|
1702
|
+
async pause() {
|
|
1703
|
+
await this._taskQueue.queuing();
|
|
1704
|
+
try {
|
|
1705
|
+
if (this.paused) throw new DisTubeError("PAUSED");
|
|
1706
|
+
this.paused = true;
|
|
1707
|
+
this.voice.pause();
|
|
1708
|
+
return this;
|
|
1709
|
+
} finally {
|
|
1710
|
+
this._taskQueue.resolve();
|
|
1711
|
+
}
|
|
1699
1712
|
}
|
|
1700
1713
|
/**
|
|
1701
1714
|
* Resume the guild stream
|
|
1702
1715
|
* @returns The guild queue
|
|
1703
1716
|
*/
|
|
1704
|
-
resume() {
|
|
1705
|
-
|
|
1706
|
-
|
|
1707
|
-
|
|
1708
|
-
|
|
1717
|
+
async resume() {
|
|
1718
|
+
await this._taskQueue.queuing();
|
|
1719
|
+
try {
|
|
1720
|
+
if (!this.paused) throw new DisTubeError("RESUMED");
|
|
1721
|
+
this.paused = false;
|
|
1722
|
+
this.voice.unpause();
|
|
1723
|
+
return this;
|
|
1724
|
+
} finally {
|
|
1725
|
+
this._taskQueue.resolve();
|
|
1726
|
+
}
|
|
1709
1727
|
}
|
|
1710
1728
|
/**
|
|
1711
1729
|
* Set the guild stream's volume
|
|
@@ -2467,7 +2485,7 @@ ${e.message}`;
|
|
|
2467
2485
|
};
|
|
2468
2486
|
|
|
2469
2487
|
// src/index.ts
|
|
2470
|
-
var version = "5.0.
|
|
2488
|
+
var version = "5.0.5";
|
|
2471
2489
|
// Annotate the CommonJS export names for ESM import in node:
|
|
2472
2490
|
0 && (module.exports = {
|
|
2473
2491
|
BaseManager,
|