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/README.md
CHANGED
|
@@ -19,31 +19,61 @@
|
|
|
19
19
|
|
|
20
20
|
# DisTube
|
|
21
21
|
|
|
22
|
-
|
|
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
|
-
|
|
24
|
+
## 🌟 Features
|
|
25
25
|
|
|
26
|
-
|
|
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
|
-
|
|
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
|
-
##
|
|
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
|
-
|
|
75
|
+
Licensed under [MIT License](https://github.com/skick1234/DisTube/blob/main/LICENSE)
|
|
46
76
|
|
|
47
|
-
|
|
77
|
+
## 💖 Support
|
|
48
78
|
|
|
49
|
-
|
|
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
|
@@ -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
|
@@ -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,11 +18,19 @@ 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
|
|
22
|
-
var
|
|
23
|
-
__export(
|
|
32
|
+
var index_exports = {};
|
|
33
|
+
__export(index_exports, {
|
|
24
34
|
BaseManager: () => BaseManager,
|
|
25
35
|
DisTube: () => DisTube,
|
|
26
36
|
DisTubeBase: () => DisTubeBase,
|
|
@@ -68,7 +78,7 @@ __export(src_exports, {
|
|
|
68
78
|
resolveGuildId: () => resolveGuildId,
|
|
69
79
|
version: () => version
|
|
70
80
|
});
|
|
71
|
-
module.exports = __toCommonJS(
|
|
81
|
+
module.exports = __toCommonJS(index_exports);
|
|
72
82
|
|
|
73
83
|
// src/type.ts
|
|
74
84
|
var Events = /* @__PURE__ */ ((Events2) => {
|
|
@@ -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
|
|
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",
|
|
@@ -563,6 +573,7 @@ var DisTubeVoice = class extends import_tiny_typed_emitter.TypedEmitter {
|
|
|
563
573
|
emittedError;
|
|
564
574
|
isDisconnected = false;
|
|
565
575
|
stream;
|
|
576
|
+
pausingStream;
|
|
566
577
|
#channel;
|
|
567
578
|
#volume = 100;
|
|
568
579
|
constructor(voiceManager, channel) {
|
|
@@ -696,11 +707,15 @@ var DisTubeVoice = class extends import_tiny_typed_emitter.TypedEmitter {
|
|
|
696
707
|
this.emittedError = true;
|
|
697
708
|
this.emit("error", error);
|
|
698
709
|
});
|
|
699
|
-
if (this.audioPlayer.state.status !== import_voice.AudioPlayerStatus.Paused)
|
|
700
|
-
|
|
710
|
+
if (this.audioPlayer.state.status !== import_voice.AudioPlayerStatus.Paused) {
|
|
711
|
+
this.audioPlayer.play(dtStream.audioResource);
|
|
712
|
+
this.stream?.kill();
|
|
713
|
+
dtStream.spawn();
|
|
714
|
+
} else if (!this.pausingStream) {
|
|
715
|
+
this.pausingStream = this.stream;
|
|
716
|
+
}
|
|
701
717
|
this.stream = dtStream;
|
|
702
718
|
this.volume = this.#volume;
|
|
703
|
-
dtStream.spawn();
|
|
704
719
|
}
|
|
705
720
|
set volume(volume) {
|
|
706
721
|
if (typeof volume !== "number" || isNaN(volume)) {
|
|
@@ -732,6 +747,9 @@ var DisTubeVoice = class extends import_tiny_typed_emitter.TypedEmitter {
|
|
|
732
747
|
if (state.status !== import_voice.AudioPlayerStatus.Paused) return;
|
|
733
748
|
if (this.stream?.audioResource && state.resource !== this.stream.audioResource) {
|
|
734
749
|
this.audioPlayer.play(this.stream.audioResource);
|
|
750
|
+
this.stream.spawn();
|
|
751
|
+
this.pausingStream?.kill();
|
|
752
|
+
delete this.pausingStream;
|
|
735
753
|
} else {
|
|
736
754
|
this.audioPlayer.unpause();
|
|
737
755
|
}
|
|
@@ -1691,21 +1709,31 @@ var Queue = class extends DisTubeBase {
|
|
|
1691
1709
|
* Pause the guild stream
|
|
1692
1710
|
* @returns The guild queue
|
|
1693
1711
|
*/
|
|
1694
|
-
pause() {
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
|
|
1712
|
+
async pause() {
|
|
1713
|
+
await this._taskQueue.queuing();
|
|
1714
|
+
try {
|
|
1715
|
+
if (this.paused) throw new DisTubeError("PAUSED");
|
|
1716
|
+
this.paused = true;
|
|
1717
|
+
this.voice.pause();
|
|
1718
|
+
return this;
|
|
1719
|
+
} finally {
|
|
1720
|
+
this._taskQueue.resolve();
|
|
1721
|
+
}
|
|
1699
1722
|
}
|
|
1700
1723
|
/**
|
|
1701
1724
|
* Resume the guild stream
|
|
1702
1725
|
* @returns The guild queue
|
|
1703
1726
|
*/
|
|
1704
|
-
resume() {
|
|
1705
|
-
|
|
1706
|
-
|
|
1707
|
-
|
|
1708
|
-
|
|
1727
|
+
async resume() {
|
|
1728
|
+
await this._taskQueue.queuing();
|
|
1729
|
+
try {
|
|
1730
|
+
if (!this.paused) throw new DisTubeError("RESUMED");
|
|
1731
|
+
this.paused = false;
|
|
1732
|
+
this.voice.unpause();
|
|
1733
|
+
return this;
|
|
1734
|
+
} finally {
|
|
1735
|
+
this._taskQueue.resolve();
|
|
1736
|
+
}
|
|
1709
1737
|
}
|
|
1710
1738
|
/**
|
|
1711
1739
|
* Set the guild stream's volume
|
|
@@ -2068,7 +2096,15 @@ function isNsfwChannel(channel) {
|
|
|
2068
2096
|
__name(isNsfwChannel, "isNsfwChannel");
|
|
2069
2097
|
var isTruthy = /* @__PURE__ */ __name((x) => Boolean(x), "isTruthy");
|
|
2070
2098
|
var checkEncryptionLibraries = /* @__PURE__ */ __name(async () => {
|
|
2071
|
-
|
|
2099
|
+
if (await import("crypto").then((m) => m.getCiphers().includes("aes-256-gcm"))) return true;
|
|
2100
|
+
for (const lib of [
|
|
2101
|
+
"@noble/ciphers",
|
|
2102
|
+
"@stablelib/xchacha20poly1305",
|
|
2103
|
+
"sodium-native",
|
|
2104
|
+
"sodium",
|
|
2105
|
+
"libsodium-wrappers",
|
|
2106
|
+
"tweetnacl"
|
|
2107
|
+
]) {
|
|
2072
2108
|
try {
|
|
2073
2109
|
await import(lib);
|
|
2074
2110
|
return true;
|
|
@@ -2467,7 +2503,7 @@ ${e.message}`;
|
|
|
2467
2503
|
};
|
|
2468
2504
|
|
|
2469
2505
|
// src/index.ts
|
|
2470
|
-
var version = "5.0.
|
|
2506
|
+
var version = "5.0.6";
|
|
2471
2507
|
// Annotate the CommonJS export names for ESM import in node:
|
|
2472
2508
|
0 && (module.exports = {
|
|
2473
2509
|
BaseManager,
|