distube 4.0.0-dev.2 → 4.0.0-dev.3
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 +1 -1
- package/dist/index.d.ts +593 -8
- package/dist/index.js +2360 -22
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +2300 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +67 -40
- package/dist/DisTube.d.ts +0 -54
- package/dist/DisTube.d.ts.map +0 -1
- package/dist/DisTube.js +0 -279
- package/dist/DisTube.js.map +0 -1
- package/dist/constant.d.ts +0 -27
- package/dist/constant.d.ts.map +0 -1
- package/dist/constant.js +0 -47
- package/dist/constant.js.map +0 -1
- package/dist/core/DisTubeBase.d.ts +0 -14
- package/dist/core/DisTubeBase.d.ts.map +0 -1
- package/dist/core/DisTubeBase.js +0 -31
- package/dist/core/DisTubeBase.js.map +0 -1
- package/dist/core/DisTubeHandler.d.ts +0 -27
- package/dist/core/DisTubeHandler.d.ts.map +0 -1
- package/dist/core/DisTubeHandler.js +0 -230
- package/dist/core/DisTubeHandler.js.map +0 -1
- package/dist/core/DisTubeOptions.d.ts +0 -23
- package/dist/core/DisTubeOptions.d.ts.map +0 -1
- package/dist/core/DisTubeOptions.js +0 -90
- package/dist/core/DisTubeOptions.js.map +0 -1
- package/dist/core/DisTubeStream.d.ts +0 -19
- package/dist/core/DisTubeStream.d.ts.map +0 -1
- package/dist/core/DisTubeStream.js +0 -72
- package/dist/core/DisTubeStream.js.map +0 -1
- package/dist/core/index.d.ts +0 -7
- package/dist/core/index.d.ts.map +0 -1
- package/dist/core/index.js +0 -19
- package/dist/core/index.js.map +0 -1
- package/dist/core/manager/BaseManager.d.ts +0 -7
- package/dist/core/manager/BaseManager.d.ts.map +0 -1
- package/dist/core/manager/BaseManager.js +0 -16
- package/dist/core/manager/BaseManager.js.map +0 -1
- package/dist/core/manager/FilterManager.d.ts +0 -16
- package/dist/core/manager/FilterManager.d.ts.map +0 -1
- package/dist/core/manager/FilterManager.js +0 -88
- package/dist/core/manager/FilterManager.js.map +0 -1
- package/dist/core/manager/GuildIdManager.d.ts +0 -9
- package/dist/core/manager/GuildIdManager.d.ts.map +0 -1
- package/dist/core/manager/GuildIdManager.js +0 -25
- package/dist/core/manager/GuildIdManager.js.map +0 -1
- package/dist/core/manager/QueueManager.d.ts +0 -11
- package/dist/core/manager/QueueManager.d.ts.map +0 -1
- package/dist/core/manager/QueueManager.js +0 -172
- package/dist/core/manager/QueueManager.js.map +0 -1
- package/dist/core/manager/index.d.ts +0 -5
- package/dist/core/manager/index.d.ts.map +0 -1
- package/dist/core/manager/index.js +0 -17
- package/dist/core/manager/index.js.map +0 -1
- package/dist/core/voice/DisTubeVoice.d.ts +0 -32
- package/dist/core/voice/DisTubeVoice.d.ts.map +0 -1
- package/dist/core/voice/DisTubeVoice.js +0 -190
- package/dist/core/voice/DisTubeVoice.js.map +0 -1
- package/dist/core/voice/DisTubeVoiceManager.d.ts +0 -10
- package/dist/core/voice/DisTubeVoiceManager.d.ts.map +0 -1
- package/dist/core/voice/DisTubeVoiceManager.js +0 -36
- package/dist/core/voice/DisTubeVoiceManager.js.map +0 -1
- package/dist/core/voice/index.d.ts +0 -3
- package/dist/core/voice/index.d.ts.map +0 -1
- package/dist/core/voice/index.js +0 -15
- package/dist/core/voice/index.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/plugin/http.d.ts +0 -10
- package/dist/plugin/http.d.ts.map +0 -1
- package/dist/plugin/http.js +0 -18
- package/dist/plugin/http.js.map +0 -1
- package/dist/plugin/https.d.ts +0 -19
- package/dist/plugin/https.d.ts.map +0 -1
- package/dist/plugin/https.js +0 -47
- package/dist/plugin/https.js.map +0 -1
- package/dist/plugin/index.d.ts +0 -3
- package/dist/plugin/index.d.ts.map +0 -1
- package/dist/plugin/index.js +0 -15
- package/dist/plugin/index.js.map +0 -1
- package/dist/struct/CustomPlugin.d.ts +0 -10
- package/dist/struct/CustomPlugin.d.ts.map +0 -1
- package/dist/struct/CustomPlugin.js +0 -16
- package/dist/struct/CustomPlugin.js.map +0 -1
- package/dist/struct/DisTubeError.d.ts +0 -55
- package/dist/struct/DisTubeError.d.ts.map +0 -1
- package/dist/struct/DisTubeError.js +0 -64
- package/dist/struct/DisTubeError.js.map +0 -1
- package/dist/struct/ExtractorPlugin.d.ts +0 -13
- package/dist/struct/ExtractorPlugin.d.ts.map +0 -1
- package/dist/struct/ExtractorPlugin.js +0 -16
- package/dist/struct/ExtractorPlugin.js.map +0 -1
- package/dist/struct/Playlist.d.ts +0 -25
- package/dist/struct/Playlist.d.ts.map +0 -1
- package/dist/struct/Playlist.js +0 -77
- package/dist/struct/Playlist.js.map +0 -1
- package/dist/struct/Plugin.d.ts +0 -17
- package/dist/struct/Plugin.d.ts.map +0 -1
- package/dist/struct/Plugin.js +0 -37
- package/dist/struct/Plugin.js.map +0 -1
- package/dist/struct/Queue.d.ts +0 -49
- package/dist/struct/Queue.d.ts.map +0 -1
- package/dist/struct/Queue.js +0 -272
- package/dist/struct/Queue.js.map +0 -1
- package/dist/struct/SearchResult.d.ts +0 -19
- package/dist/struct/SearchResult.d.ts.map +0 -1
- package/dist/struct/SearchResult.js +0 -30
- package/dist/struct/SearchResult.js.map +0 -1
- package/dist/struct/Song.d.ts +0 -43
- package/dist/struct/Song.d.ts.map +0 -1
- package/dist/struct/Song.js +0 -138
- package/dist/struct/Song.js.map +0 -1
- package/dist/struct/TaskQueue.d.ts +0 -8
- package/dist/struct/TaskQueue.d.ts.map +0 -1
- package/dist/struct/TaskQueue.js +0 -39
- package/dist/struct/TaskQueue.js.map +0 -1
- package/dist/struct/index.d.ts +0 -10
- package/dist/struct/index.d.ts.map +0 -1
- package/dist/struct/index.js +0 -22
- package/dist/struct/index.js.map +0 -1
- package/dist/tsconfig.tsbuildinfo +0 -1
- package/dist/type.d.ts +0 -104
- package/dist/type.d.ts.map +0 -1
- package/dist/type.js +0 -3
- package/dist/type.js.map +0 -1
- package/dist/util.d.ts +0 -22
- package/dist/util.d.ts.map +0 -1
- package/dist/util.js +0 -189
- package/dist/util.js.map +0 -1
package/dist/index.js
CHANGED
|
@@ -1,24 +1,2362 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
})
|
|
9
|
-
var
|
|
10
|
-
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
9
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
10
|
+
var __commonJS = (cb, mod) => function __require() {
|
|
11
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
12
|
+
};
|
|
13
|
+
var __export = (target, all) => {
|
|
14
|
+
for (var name in all)
|
|
15
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
16
|
+
};
|
|
17
|
+
var __copyProps = (to, from, except, desc) => {
|
|
18
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
19
|
+
for (let key of __getOwnPropNames(from))
|
|
20
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
21
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
22
|
+
}
|
|
23
|
+
return to;
|
|
24
|
+
};
|
|
25
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
|
|
26
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
27
|
+
var __publicField = (obj, key, value) => {
|
|
28
|
+
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
29
|
+
return value;
|
|
30
|
+
};
|
|
31
|
+
var __accessCheck = (obj, member, msg) => {
|
|
32
|
+
if (!member.has(obj))
|
|
33
|
+
throw TypeError("Cannot " + msg);
|
|
34
|
+
};
|
|
35
|
+
var __privateGet = (obj, member, getter) => {
|
|
36
|
+
__accessCheck(obj, member, "read from private field");
|
|
37
|
+
return getter ? getter.call(obj) : member.get(obj);
|
|
38
|
+
};
|
|
39
|
+
var __privateAdd = (obj, member, value) => {
|
|
40
|
+
if (member.has(obj))
|
|
41
|
+
throw TypeError("Cannot add the same private member more than once");
|
|
42
|
+
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
43
|
+
};
|
|
44
|
+
var __privateSet = (obj, member, value, setter) => {
|
|
45
|
+
__accessCheck(obj, member, "write to private field");
|
|
46
|
+
setter ? setter.call(obj, value) : member.set(obj, value);
|
|
47
|
+
return value;
|
|
48
|
+
};
|
|
49
|
+
var __privateMethod = (obj, member, method) => {
|
|
50
|
+
__accessCheck(obj, member, "access private method");
|
|
51
|
+
return method;
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
// package.json
|
|
55
|
+
var require_package = __commonJS({
|
|
56
|
+
"package.json"(exports, module2) {
|
|
57
|
+
module2.exports = {
|
|
58
|
+
name: "distube",
|
|
59
|
+
version: "4.0.0-dev.3",
|
|
60
|
+
description: "A Discord.js module to simplify your music commands and play songs with audio filters on Discord without any API key.",
|
|
61
|
+
main: "./dist/index.js",
|
|
62
|
+
module: "./dist/index.mjs",
|
|
63
|
+
types: "./dist/index.d.ts",
|
|
64
|
+
exports: {
|
|
65
|
+
import: "./dist/index.mjs",
|
|
66
|
+
require: "./dist/index.js"
|
|
67
|
+
},
|
|
68
|
+
directories: {
|
|
69
|
+
lib: "src",
|
|
70
|
+
test: "tests"
|
|
71
|
+
},
|
|
72
|
+
files: [
|
|
73
|
+
"dist"
|
|
74
|
+
],
|
|
75
|
+
scripts: {
|
|
76
|
+
test: "jest",
|
|
77
|
+
docs: "docgen -s src/*.ts src/**/*.ts -o docs.json -c pages/index.yml -g -j jsdoc.config.json",
|
|
78
|
+
lint: "prettier --check . && eslint .",
|
|
79
|
+
"lint:fix": "eslint . --fix",
|
|
80
|
+
prettier: "prettier --write **/*.{ts,json,yml,yaml,md}",
|
|
81
|
+
build: "tsup",
|
|
82
|
+
"build:check": "tsc --noEmit",
|
|
83
|
+
update: "ncu -u --dep dev,prod && yarn up '**' -R",
|
|
84
|
+
postinstall: "husky install",
|
|
85
|
+
prepublishOnly: "yarn lint && yarn test",
|
|
86
|
+
prepack: "yarn build && pinst --disable",
|
|
87
|
+
postpack: "pinst --enable"
|
|
88
|
+
},
|
|
89
|
+
repository: {
|
|
90
|
+
type: "git",
|
|
91
|
+
url: "git+https://github.com/skick1234/DisTube.git"
|
|
92
|
+
},
|
|
93
|
+
keywords: [
|
|
94
|
+
"youtube",
|
|
95
|
+
"music",
|
|
96
|
+
"discord",
|
|
97
|
+
"discordjs",
|
|
98
|
+
"bot",
|
|
99
|
+
"distube",
|
|
100
|
+
"queue",
|
|
101
|
+
"musicbot",
|
|
102
|
+
"discord-music-bot",
|
|
103
|
+
"music-bot",
|
|
104
|
+
"discord-js"
|
|
105
|
+
],
|
|
106
|
+
author: "Skick (https://github.com/skick1234)",
|
|
107
|
+
license: "MIT",
|
|
108
|
+
bugs: {
|
|
109
|
+
url: "https://github.com/skick1234/DisTube/issues"
|
|
110
|
+
},
|
|
111
|
+
funding: [
|
|
112
|
+
{
|
|
113
|
+
type: "individual",
|
|
114
|
+
url: "https://paypal.me/Skickkk"
|
|
115
|
+
},
|
|
116
|
+
{
|
|
117
|
+
type: "patreon",
|
|
118
|
+
url: "https://patreon.com/DisTube"
|
|
119
|
+
}
|
|
120
|
+
],
|
|
121
|
+
homepage: "https://distube.js.org/",
|
|
122
|
+
dependencies: {
|
|
123
|
+
"@distube/ytdl-core": "^4.11.1",
|
|
124
|
+
"@distube/ytpl": "^1.1.1",
|
|
125
|
+
"@distube/ytsr": "^1.1.5",
|
|
126
|
+
"prism-media": "https://codeload.github.com/distubejs/prism-media/tar.gz/main#workaround.tar.gz",
|
|
127
|
+
"tiny-typed-emitter": "^2.1.0",
|
|
128
|
+
tslib: "^2.3.1"
|
|
129
|
+
},
|
|
130
|
+
devDependencies: {
|
|
131
|
+
"@babel/core": "^7.17.8",
|
|
132
|
+
"@babel/plugin-proposal-class-properties": "^7.16.7",
|
|
133
|
+
"@babel/plugin-proposal-object-rest-spread": "^7.17.3",
|
|
134
|
+
"@babel/preset-env": "^7.16.11",
|
|
135
|
+
"@babel/preset-typescript": "^7.16.7",
|
|
136
|
+
"@commitlint/cli": "^16.2.3",
|
|
137
|
+
"@commitlint/config-conventional": "^16.2.1",
|
|
138
|
+
"@discordjs/voice": "dev",
|
|
139
|
+
"@distube/docgen": "distubejs/docgen",
|
|
140
|
+
"@types/jest": "^27.4.1",
|
|
141
|
+
"@types/node": "^17.0.23",
|
|
142
|
+
"@typescript-eslint/eslint-plugin": "^5.17.0",
|
|
143
|
+
"@typescript-eslint/parser": "^5.17.0",
|
|
144
|
+
"babel-jest": "^27.5.1",
|
|
145
|
+
"discord.js": "dev",
|
|
146
|
+
eslint: "^8.12.0",
|
|
147
|
+
"eslint-config-distube": "^1.6.4",
|
|
148
|
+
"eslint-config-prettier": "^8.5.0",
|
|
149
|
+
"eslint-plugin-deprecation": "^1.3.2",
|
|
150
|
+
"eslint-plugin-jsdoc": "^38.1.4",
|
|
151
|
+
husky: "^7.0.4",
|
|
152
|
+
jest: "^27.5.1",
|
|
153
|
+
"jsdoc-babel": "^0.5.0",
|
|
154
|
+
"nano-staged": "^0.6.0",
|
|
155
|
+
"npm-check-updates": "^12.5.4",
|
|
156
|
+
pinst: "^3.0.0",
|
|
157
|
+
prettier: "^2.6.1",
|
|
158
|
+
tsup: "^5.12.1",
|
|
159
|
+
typescript: "^4.6.3"
|
|
160
|
+
},
|
|
161
|
+
peerDependencies: {
|
|
162
|
+
"@discordjs/opus": "*",
|
|
163
|
+
"@discordjs/voice": "*",
|
|
164
|
+
"discord.js": "14||^14.0.0-dev"
|
|
165
|
+
},
|
|
166
|
+
peerDependenciesMeta: {
|
|
167
|
+
"@discordjs/opus": {
|
|
168
|
+
optional: true
|
|
169
|
+
}
|
|
170
|
+
},
|
|
171
|
+
"nano-staged": {
|
|
172
|
+
"*.ts": [
|
|
173
|
+
"prettier --write",
|
|
174
|
+
"eslint"
|
|
175
|
+
],
|
|
176
|
+
"*.{json,yml,yaml,md}": [
|
|
177
|
+
"prettier --write"
|
|
178
|
+
]
|
|
179
|
+
},
|
|
180
|
+
engines: {
|
|
181
|
+
node: ">=16.9.0"
|
|
182
|
+
},
|
|
183
|
+
packageManager: "yarn@3.2.0",
|
|
184
|
+
stableVersion: "4.0.0-dev"
|
|
185
|
+
};
|
|
186
|
+
}
|
|
187
|
+
});
|
|
188
|
+
|
|
189
|
+
// src/index.ts
|
|
190
|
+
var src_exports = {};
|
|
191
|
+
__export(src_exports, {
|
|
192
|
+
BaseManager: () => BaseManager,
|
|
193
|
+
CustomPlugin: () => CustomPlugin,
|
|
194
|
+
DisTube: () => DisTube,
|
|
195
|
+
DisTubeBase: () => DisTubeBase,
|
|
196
|
+
DisTubeError: () => DisTubeError,
|
|
197
|
+
DisTubeHandler: () => DisTubeHandler,
|
|
198
|
+
DisTubeStream: () => DisTubeStream,
|
|
199
|
+
DisTubeVoice: () => DisTubeVoice,
|
|
200
|
+
DisTubeVoiceManager: () => DisTubeVoiceManager,
|
|
201
|
+
ExtractorPlugin: () => ExtractorPlugin,
|
|
202
|
+
FilterManager: () => FilterManager,
|
|
203
|
+
GuildIdManager: () => GuildIdManager,
|
|
204
|
+
HTTPPlugin: () => HTTPPlugin,
|
|
205
|
+
HTTPSPlugin: () => HTTPSPlugin,
|
|
206
|
+
Options: () => Options,
|
|
207
|
+
Playlist: () => Playlist,
|
|
208
|
+
Plugin: () => Plugin,
|
|
209
|
+
PluginType: () => PluginType,
|
|
210
|
+
Queue: () => Queue,
|
|
211
|
+
QueueManager: () => QueueManager,
|
|
212
|
+
RepeatMode: () => RepeatMode,
|
|
213
|
+
SearchResult: () => SearchResult,
|
|
214
|
+
SearchResultType: () => SearchResultType,
|
|
215
|
+
Song: () => Song,
|
|
216
|
+
TaskQueue: () => TaskQueue,
|
|
217
|
+
checkIntents: () => checkIntents,
|
|
218
|
+
checkInvalidKey: () => checkInvalidKey,
|
|
219
|
+
chooseBestVideoFormat: () => chooseBestVideoFormat,
|
|
220
|
+
default: () => DisTube,
|
|
221
|
+
defaultFilters: () => defaultFilters,
|
|
222
|
+
defaultOptions: () => defaultOptions,
|
|
223
|
+
entersState: () => entersState,
|
|
224
|
+
formatDuration: () => formatDuration,
|
|
225
|
+
getResponseHeaders: () => getResponseHeaders,
|
|
226
|
+
isClientInstance: () => isClientInstance,
|
|
227
|
+
isGuildInstance: () => isGuildInstance,
|
|
228
|
+
isMemberInstance: () => isMemberInstance,
|
|
229
|
+
isMessageInstance: () => isMessageInstance,
|
|
230
|
+
isObject: () => isObject,
|
|
231
|
+
isRecord: () => isRecord,
|
|
232
|
+
isSnowflake: () => isSnowflake,
|
|
233
|
+
isSupportedVoiceChannel: () => isSupportedVoiceChannel,
|
|
234
|
+
isTextChannelInstance: () => isTextChannelInstance,
|
|
235
|
+
isURL: () => isURL,
|
|
236
|
+
isVoiceChannelEmpty: () => isVoiceChannelEmpty,
|
|
237
|
+
parseNumber: () => parseNumber,
|
|
238
|
+
resolveGuildId: () => resolveGuildId,
|
|
239
|
+
resolveHttpSong: () => resolveHttpSong,
|
|
240
|
+
toSecond: () => toSecond,
|
|
241
|
+
validateAudioURL: () => validateAudioURL,
|
|
242
|
+
version: () => version
|
|
243
|
+
});
|
|
244
|
+
module.exports = __toCommonJS(src_exports);
|
|
245
|
+
|
|
246
|
+
// src/type.ts
|
|
247
|
+
var RepeatMode = /* @__PURE__ */ ((RepeatMode2) => {
|
|
248
|
+
RepeatMode2[RepeatMode2["DISABLED"] = 0] = "DISABLED";
|
|
249
|
+
RepeatMode2[RepeatMode2["SONG"] = 1] = "SONG";
|
|
250
|
+
RepeatMode2[RepeatMode2["QUEUE"] = 2] = "QUEUE";
|
|
251
|
+
return RepeatMode2;
|
|
252
|
+
})(RepeatMode || {});
|
|
253
|
+
var PluginType = /* @__PURE__ */ ((PluginType2) => {
|
|
254
|
+
PluginType2["CUSTOM"] = "custom";
|
|
255
|
+
PluginType2["EXTRACTOR"] = "extractor";
|
|
256
|
+
return PluginType2;
|
|
257
|
+
})(PluginType || {});
|
|
258
|
+
var SearchResultType = /* @__PURE__ */ ((SearchResultType2) => {
|
|
259
|
+
SearchResultType2["VIDEO"] = "video";
|
|
260
|
+
SearchResultType2["PLAYLIST"] = "playlist";
|
|
261
|
+
return SearchResultType2;
|
|
262
|
+
})(SearchResultType || {});
|
|
263
|
+
|
|
264
|
+
// src/constant.ts
|
|
265
|
+
var defaultFilters = {
|
|
266
|
+
"3d": "apulsator=hz=0.125",
|
|
267
|
+
bassboost: "bass=g=10",
|
|
268
|
+
echo: "aecho=0.8:0.9:1000:0.3",
|
|
269
|
+
flanger: "flanger",
|
|
270
|
+
gate: "agate",
|
|
271
|
+
haas: "haas",
|
|
272
|
+
karaoke: "stereotools=mlev=0.1",
|
|
273
|
+
nightcore: "asetrate=48000*1.25,aresample=48000,bass=g=5",
|
|
274
|
+
reverse: "areverse",
|
|
275
|
+
vaporwave: "asetrate=48000*0.8,aresample=48000,atempo=1.1",
|
|
276
|
+
mcompand: "mcompand",
|
|
277
|
+
phaser: "aphaser",
|
|
278
|
+
tremolo: "tremolo",
|
|
279
|
+
surround: "surround",
|
|
280
|
+
earwax: "earwax"
|
|
281
|
+
};
|
|
282
|
+
var defaultOptions = {
|
|
283
|
+
plugins: [],
|
|
284
|
+
emitNewSongOnly: false,
|
|
285
|
+
leaveOnEmpty: true,
|
|
286
|
+
leaveOnFinish: false,
|
|
287
|
+
leaveOnStop: true,
|
|
288
|
+
savePreviousSongs: true,
|
|
289
|
+
searchSongs: 0,
|
|
290
|
+
ytdlOptions: {},
|
|
291
|
+
searchCooldown: 60,
|
|
292
|
+
emptyCooldown: 60,
|
|
293
|
+
nsfw: false,
|
|
294
|
+
emitAddSongWhenCreatingQueue: true,
|
|
295
|
+
emitAddListWhenCreatingQueue: true,
|
|
296
|
+
joinNewVoiceChannel: true
|
|
297
|
+
};
|
|
298
|
+
|
|
299
|
+
// src/struct/DisTubeError.ts
|
|
300
|
+
var import_node_util = require("util");
|
|
301
|
+
var ERROR_MESSAGES = {
|
|
302
|
+
INVALID_TYPE: (expected, got, name) => `Expected ${Array.isArray(expected) ? expected.map((e) => typeof e === "number" ? e : `'${e}'`).join(" or ") : `'${expected}'`}${name ? ` for '${name}'` : ""}, but got ${(0, import_node_util.inspect)(got)}`,
|
|
303
|
+
NUMBER_COMPARE: (name, expected, value) => `'${name}' must be ${expected} ${value}`,
|
|
304
|
+
EMPTY_ARRAY: (name) => `'${name}' is an empty array`,
|
|
305
|
+
EMPTY_FILTERED_ARRAY: (name, type) => `There is no valid '${type}' in the '${name}' array`,
|
|
306
|
+
EMPTY_STRING: (name) => `'${name}' string must not be empty`,
|
|
307
|
+
INVALID_KEY: (obj, key) => `'${key}' does not need to be provided in ${obj}`,
|
|
308
|
+
MISSING_KEY: (obj, key) => `'${key}' needs to be provided in ${obj}`,
|
|
309
|
+
MISSING_KEYS: (obj, key, all) => `${key.map((k) => `'${k}'`).join(all ? " and " : " or ")} need to be provided in ${obj}`,
|
|
310
|
+
MISSING_INTENTS: (i) => `${i} intent must be provided for the Client`,
|
|
311
|
+
DISABLED_OPTION: (o) => `DisTubeOptions.${o} is disabled`,
|
|
312
|
+
ENABLED_OPTION: (o) => `DisTubeOptions.${o} is enabled`,
|
|
313
|
+
NOT_IN_VOICE: "User is not in any voice channel",
|
|
314
|
+
VOICE_FULL: "The voice channel is full",
|
|
315
|
+
VOICE_CONNECT_FAILED: (s) => `Cannot connect to the voice channel after ${s} seconds`,
|
|
316
|
+
VOICE_MISSING_PERMS: "I do not have permission to join this voice channel",
|
|
317
|
+
VOICE_RECONNECT_FAILED: "Cannot reconnect to the voice channel",
|
|
318
|
+
VOICE_DIFFERENT_GUILD: "Cannot join a channel in a different guild",
|
|
319
|
+
NO_QUEUE: "There is no playing queue in this guild",
|
|
320
|
+
QUEUE_EXIST: "This guild has a Queue already",
|
|
321
|
+
PAUSED: "The queue has been paused already",
|
|
322
|
+
RESUMED: "The queue has been playing already",
|
|
323
|
+
NO_PREVIOUS: "There is no previous song in this queue",
|
|
324
|
+
NO_UP_NEXT: "There is no up next song",
|
|
325
|
+
NO_SONG_POSITION: "Does not have any song at this position",
|
|
326
|
+
NO_PLAYING: "There is no playing song in the queue",
|
|
327
|
+
NO_RESULT: "No result found",
|
|
328
|
+
NO_RELATED: "Cannot find any related songs",
|
|
329
|
+
CANNOT_PLAY_RELATED: "Cannot play the related song",
|
|
330
|
+
UNAVAILABLE_VIDEO: "This video is unavailable",
|
|
331
|
+
UNPLAYABLE_FORMATS: "No playable format found",
|
|
332
|
+
NON_NSFW: "Cannot play age-restricted content in non-NSFW channel",
|
|
333
|
+
NOT_SUPPORTED_URL: "This url is not supported",
|
|
334
|
+
CANNOT_RESOLVE_SONG: (t) => `Cannot resolve ${(0, import_node_util.inspect)(t)} to a Song`,
|
|
335
|
+
NO_VALID_SONG: "'songs' array does not have any valid Song, SearchResult or url",
|
|
336
|
+
EMPTY_FILTERED_PLAYLIST: "There is no valid video in the playlist\nMaybe age-restricted contents is filtered because you are in non-NSFW channel",
|
|
337
|
+
EMPTY_PLAYLIST: "There is no valid video in the playlist"
|
|
338
|
+
};
|
|
339
|
+
var haveCode = /* @__PURE__ */ __name((code) => Object.keys(ERROR_MESSAGES).includes(code), "haveCode");
|
|
340
|
+
var parseMessage = /* @__PURE__ */ __name((m, ...args) => typeof m === "string" ? m : m(...args), "parseMessage");
|
|
341
|
+
var getErrorMessage = /* @__PURE__ */ __name((code, ...args) => haveCode(code) ? parseMessage(ERROR_MESSAGES[code], ...args) : args[0], "getErrorMessage");
|
|
342
|
+
var DisTubeError = class extends Error {
|
|
343
|
+
constructor(code, ...args) {
|
|
344
|
+
super(getErrorMessage(code, ...args));
|
|
345
|
+
__publicField(this, "errorCode");
|
|
346
|
+
this.errorCode = code;
|
|
347
|
+
if (Error.captureStackTrace)
|
|
348
|
+
Error.captureStackTrace(this, DisTubeError);
|
|
349
|
+
}
|
|
350
|
+
get name() {
|
|
351
|
+
return `DisTubeError [${this.errorCode}]`;
|
|
352
|
+
}
|
|
353
|
+
get code() {
|
|
354
|
+
return this.errorCode;
|
|
355
|
+
}
|
|
356
|
+
};
|
|
357
|
+
|
|
358
|
+
// src/struct/TaskQueue.ts
|
|
359
|
+
var Task = class {
|
|
360
|
+
constructor(resolveInfo) {
|
|
361
|
+
__publicField(this, "resolve");
|
|
362
|
+
__publicField(this, "promise");
|
|
363
|
+
__publicField(this, "resolveInfo");
|
|
364
|
+
this.resolveInfo = resolveInfo;
|
|
365
|
+
this.promise = new Promise((res) => {
|
|
366
|
+
this.resolve = res;
|
|
367
|
+
});
|
|
368
|
+
}
|
|
369
|
+
};
|
|
370
|
+
var _tasks;
|
|
371
|
+
var TaskQueue = class {
|
|
372
|
+
constructor() {
|
|
373
|
+
__privateAdd(this, _tasks, []);
|
|
374
|
+
}
|
|
375
|
+
queuing(resolveInfo = false) {
|
|
376
|
+
const next = this.remaining ? __privateGet(this, _tasks)[__privateGet(this, _tasks).length - 1].promise : Promise.resolve();
|
|
377
|
+
__privateGet(this, _tasks).push(new Task(resolveInfo));
|
|
378
|
+
return next;
|
|
379
|
+
}
|
|
380
|
+
resolve() {
|
|
381
|
+
__privateGet(this, _tasks).shift()?.resolve();
|
|
382
|
+
}
|
|
383
|
+
get remaining() {
|
|
384
|
+
return __privateGet(this, _tasks).length;
|
|
385
|
+
}
|
|
386
|
+
get hasResolveTask() {
|
|
387
|
+
return !!__privateGet(this, _tasks).find((t) => t.resolveInfo);
|
|
388
|
+
}
|
|
389
|
+
};
|
|
390
|
+
_tasks = new WeakMap();
|
|
391
|
+
|
|
392
|
+
// src/struct/Playlist.ts
|
|
393
|
+
var _metadata, _member;
|
|
394
|
+
var Playlist = class {
|
|
395
|
+
constructor(playlist, options = {}) {
|
|
396
|
+
__publicField(this, "source");
|
|
397
|
+
__publicField(this, "songs");
|
|
398
|
+
__publicField(this, "name");
|
|
399
|
+
__privateAdd(this, _metadata, void 0);
|
|
400
|
+
__privateAdd(this, _member, void 0);
|
|
401
|
+
__publicField(this, "url");
|
|
402
|
+
__publicField(this, "thumbnail");
|
|
403
|
+
const { member, properties, metadata } = options;
|
|
404
|
+
if (typeof playlist !== "object") {
|
|
405
|
+
throw new DisTubeError("INVALID_TYPE", ["Array<Song>", "object"], playlist, "playlist");
|
|
406
|
+
}
|
|
407
|
+
if (typeof properties !== "undefined" && !isRecord(properties)) {
|
|
408
|
+
throw new DisTubeError("INVALID_TYPE", "object", properties, "properties");
|
|
409
|
+
}
|
|
410
|
+
const info = playlist;
|
|
411
|
+
this.source = (info.source || properties?.source || "youtube").toLowerCase();
|
|
412
|
+
this.songs = Array.isArray(info) ? info : info.items || info.songs;
|
|
413
|
+
if (!Array.isArray(this.songs) || !this.songs.length) {
|
|
414
|
+
throw new DisTubeError("EMPTY_PLAYLIST");
|
|
415
|
+
}
|
|
416
|
+
this.songs.map((s) => s.constructor.name === "Song" && (s.playlist = this));
|
|
417
|
+
this.member = member || info.member || void 0;
|
|
418
|
+
this.name = info.name || info.title || (this.songs[0].name ? `${this.songs[0].name} and ${this.songs.length - 1} more songs.` : `${this.songs.length} songs playlist`);
|
|
419
|
+
this.url = info.url || info.webpage_url;
|
|
420
|
+
this.thumbnail = info.thumbnail?.url || info.thumbnail || this.songs[0].thumbnail;
|
|
421
|
+
if (properties)
|
|
422
|
+
for (const [key, value] of Object.entries(properties))
|
|
423
|
+
this[key] = value;
|
|
424
|
+
this.metadata = metadata;
|
|
425
|
+
}
|
|
426
|
+
get duration() {
|
|
427
|
+
return this.songs?.reduce((prev, next) => prev + (next.duration || 0), 0) || 0;
|
|
428
|
+
}
|
|
429
|
+
get formattedDuration() {
|
|
430
|
+
return formatDuration(this.duration);
|
|
431
|
+
}
|
|
432
|
+
get member() {
|
|
433
|
+
return __privateGet(this, _member);
|
|
434
|
+
}
|
|
435
|
+
set member(member) {
|
|
436
|
+
if (!isMemberInstance(member))
|
|
437
|
+
return;
|
|
438
|
+
__privateSet(this, _member, member);
|
|
439
|
+
this.songs.map((s) => s.constructor.name === "Song" && (s.member = this.member));
|
|
440
|
+
}
|
|
441
|
+
get user() {
|
|
442
|
+
return this.member?.user;
|
|
443
|
+
}
|
|
444
|
+
get metadata() {
|
|
445
|
+
return __privateGet(this, _metadata);
|
|
446
|
+
}
|
|
447
|
+
set metadata(metadata) {
|
|
448
|
+
__privateSet(this, _metadata, metadata);
|
|
449
|
+
this.songs.map((s) => s.constructor.name === "Song" && (s.metadata = metadata));
|
|
450
|
+
}
|
|
451
|
+
};
|
|
452
|
+
_metadata = new WeakMap();
|
|
453
|
+
_member = new WeakMap();
|
|
454
|
+
|
|
455
|
+
// src/struct/SearchResult.ts
|
|
456
|
+
var SearchResult = class {
|
|
457
|
+
constructor(info) {
|
|
458
|
+
__publicField(this, "source");
|
|
459
|
+
__publicField(this, "type");
|
|
460
|
+
__publicField(this, "id");
|
|
461
|
+
__publicField(this, "name");
|
|
462
|
+
__publicField(this, "url");
|
|
463
|
+
__publicField(this, "views");
|
|
464
|
+
__publicField(this, "isLive");
|
|
465
|
+
__publicField(this, "duration");
|
|
466
|
+
__publicField(this, "formattedDuration");
|
|
467
|
+
__publicField(this, "thumbnail");
|
|
468
|
+
__publicField(this, "uploader");
|
|
469
|
+
this.source = "youtube";
|
|
470
|
+
this.type = info.type === "video" ? "video" /* VIDEO */ : "playlist" /* PLAYLIST */;
|
|
471
|
+
this.id = info.id;
|
|
472
|
+
this.name = info.name;
|
|
473
|
+
this.url = info.url;
|
|
474
|
+
if (this.type === "video" /* VIDEO */) {
|
|
475
|
+
info = info;
|
|
476
|
+
this.views = info.views;
|
|
477
|
+
this.isLive = info.isLive;
|
|
478
|
+
this.duration = this.isLive ? 0 : toSecond(info.duration);
|
|
479
|
+
this.formattedDuration = this.isLive ? "Live" : formatDuration(this.duration);
|
|
480
|
+
this.thumbnail = info.thumbnail;
|
|
481
|
+
} else if (this.type !== "playlist") {
|
|
482
|
+
throw new DisTubeError("INVALID_TYPE", ["video", "playlist"], this.type, "SearchResult.type");
|
|
483
|
+
}
|
|
484
|
+
this.uploader = {
|
|
485
|
+
name: (info.author || info.owner)?.name,
|
|
486
|
+
url: (info.author || info.owner)?.url
|
|
487
|
+
};
|
|
488
|
+
}
|
|
489
|
+
};
|
|
490
|
+
|
|
491
|
+
// src/struct/Song.ts
|
|
492
|
+
var _metadata2, _member2, _playlist;
|
|
493
|
+
var _Song = class {
|
|
494
|
+
constructor(info, options = {}) {
|
|
495
|
+
__publicField(this, "source");
|
|
496
|
+
__privateAdd(this, _metadata2, void 0);
|
|
497
|
+
__publicField(this, "formats");
|
|
498
|
+
__privateAdd(this, _member2, void 0);
|
|
499
|
+
__publicField(this, "id");
|
|
500
|
+
__publicField(this, "name");
|
|
501
|
+
__publicField(this, "isLive");
|
|
502
|
+
__publicField(this, "duration");
|
|
503
|
+
__publicField(this, "formattedDuration");
|
|
504
|
+
__publicField(this, "url");
|
|
505
|
+
__publicField(this, "streamURL");
|
|
506
|
+
__publicField(this, "thumbnail");
|
|
507
|
+
__publicField(this, "related");
|
|
508
|
+
__publicField(this, "views");
|
|
509
|
+
__publicField(this, "likes");
|
|
510
|
+
__publicField(this, "dislikes");
|
|
511
|
+
__publicField(this, "uploader");
|
|
512
|
+
__publicField(this, "age_restricted");
|
|
513
|
+
__publicField(this, "chapters");
|
|
514
|
+
__publicField(this, "reposts");
|
|
515
|
+
__privateAdd(this, _playlist, void 0);
|
|
516
|
+
const { member, source, metadata } = { source: "youtube", ...options };
|
|
517
|
+
if (typeof source !== "string" || info.src && typeof info.src !== "string") {
|
|
518
|
+
throw new DisTubeError("INVALID_TYPE", "string", source, "source");
|
|
519
|
+
}
|
|
520
|
+
this.source = (info?.src || source).toLowerCase();
|
|
521
|
+
this.metadata = metadata;
|
|
522
|
+
this.member = member;
|
|
523
|
+
if (this.source === "youtube") {
|
|
524
|
+
this._patchYouTube(info);
|
|
525
|
+
} else {
|
|
526
|
+
this._patchOther(info);
|
|
527
|
+
}
|
|
528
|
+
}
|
|
529
|
+
_patchYouTube(i) {
|
|
530
|
+
const info = i;
|
|
531
|
+
if (info.full === true) {
|
|
532
|
+
this.formats = info.formats;
|
|
533
|
+
const err = require("@distube/ytdl-core/lib/utils").playError(info.player_response, [
|
|
534
|
+
"UNPLAYABLE",
|
|
535
|
+
"LIVE_STREAM_OFFLINE",
|
|
536
|
+
"LOGIN_REQUIRED"
|
|
537
|
+
]);
|
|
538
|
+
if (err)
|
|
539
|
+
throw err;
|
|
540
|
+
if (!info.formats?.length)
|
|
541
|
+
throw new DisTubeError("UNAVAILABLE_VIDEO");
|
|
542
|
+
}
|
|
543
|
+
const details = info.videoDetails || info;
|
|
544
|
+
this.id = details.videoId || details.id;
|
|
545
|
+
this.name = details.title || details.name;
|
|
546
|
+
this.isLive = !!details.isLive;
|
|
547
|
+
this.duration = this.isLive ? 0 : toSecond(details.lengthSeconds || details.length_seconds || details.duration);
|
|
548
|
+
this.formattedDuration = this.isLive ? "Live" : formatDuration(this.duration);
|
|
549
|
+
this.url = `https://www.youtube.com/watch?v=${this.id}`;
|
|
550
|
+
this.streamURL = void 0;
|
|
551
|
+
this.thumbnail = details.thumbnails?.sort((a, b) => b.width - a.width)?.[0]?.url || details.thumbnail?.url || details.thumbnail;
|
|
552
|
+
this.related = info?.related_videos || details.related || [];
|
|
553
|
+
if (!Array.isArray(this.related))
|
|
554
|
+
throw new DisTubeError("INVALID_TYPE", "Array", this.related, "Song#related");
|
|
555
|
+
this.related = this.related.map((v) => new _Song(v, { source: this.source, metadata: this.metadata }));
|
|
556
|
+
this.views = parseNumber(details.viewCount || details.view_count || details.views);
|
|
557
|
+
this.likes = parseNumber(details.likes);
|
|
558
|
+
this.dislikes = parseNumber(details.dislikes);
|
|
559
|
+
this.uploader = {
|
|
560
|
+
name: info.uploader?.name || details.author?.name,
|
|
561
|
+
url: info.uploader?.url || details.author?.channel_url || details.author?.url
|
|
562
|
+
};
|
|
563
|
+
this.age_restricted = !!details.age_restricted;
|
|
564
|
+
this.chapters = details.chapters || [];
|
|
565
|
+
this.reposts = 0;
|
|
566
|
+
}
|
|
567
|
+
_patchOther(info) {
|
|
568
|
+
this.id = info.id;
|
|
569
|
+
this.name = info.title || info.name;
|
|
570
|
+
this.isLive = Boolean(info.is_live || info.isLive);
|
|
571
|
+
this.duration = this.isLive ? 0 : toSecond(info._duration_raw || info.duration);
|
|
572
|
+
this.formattedDuration = this.isLive ? "Live" : formatDuration(this.duration);
|
|
573
|
+
this.url = info.webpage_url || info.url;
|
|
574
|
+
this.thumbnail = info.thumbnail;
|
|
575
|
+
this.related = info.related || [];
|
|
576
|
+
if (!Array.isArray(this.related))
|
|
577
|
+
throw new DisTubeError("INVALID_TYPE", "Array", this.related, "Song#related");
|
|
578
|
+
this.related = this.related.map((i) => new _Song(i, { source: this.source, metadata: this.metadata }));
|
|
579
|
+
this.views = parseNumber(info.view_count || info.views);
|
|
580
|
+
this.likes = parseNumber(info.like_count || info.likes);
|
|
581
|
+
this.dislikes = parseNumber(info.dislike_count || info.dislikes);
|
|
582
|
+
this.reposts = parseNumber(info.repost_count || info.reposts);
|
|
583
|
+
if (typeof info.uploader === "string") {
|
|
584
|
+
this.uploader = {
|
|
585
|
+
name: info.uploader,
|
|
586
|
+
url: info.uploader_url
|
|
587
|
+
};
|
|
588
|
+
} else {
|
|
589
|
+
this.uploader = {
|
|
590
|
+
name: info.uploader?.name,
|
|
591
|
+
url: info.uploader?.url
|
|
592
|
+
};
|
|
593
|
+
}
|
|
594
|
+
this.age_restricted = info.age_restricted || !!info.age_limit && parseNumber(info.age_limit) >= 18;
|
|
595
|
+
this.chapters = info.chapters || [];
|
|
596
|
+
}
|
|
597
|
+
get playlist() {
|
|
598
|
+
return __privateGet(this, _playlist);
|
|
599
|
+
}
|
|
600
|
+
set playlist(playlist) {
|
|
601
|
+
if (!(playlist instanceof Playlist))
|
|
602
|
+
throw new DisTubeError("INVALID_TYPE", "Playlist", playlist, "Song#playlist");
|
|
603
|
+
__privateSet(this, _playlist, playlist);
|
|
604
|
+
this.member = playlist.member;
|
|
605
|
+
}
|
|
606
|
+
get member() {
|
|
607
|
+
return __privateGet(this, _member2);
|
|
608
|
+
}
|
|
609
|
+
set member(member) {
|
|
610
|
+
if (isMemberInstance(member))
|
|
611
|
+
__privateSet(this, _member2, member);
|
|
612
|
+
}
|
|
613
|
+
get user() {
|
|
614
|
+
return this.member?.user;
|
|
615
|
+
}
|
|
616
|
+
get metadata() {
|
|
617
|
+
return __privateGet(this, _metadata2);
|
|
618
|
+
}
|
|
619
|
+
set metadata(metadata) {
|
|
620
|
+
__privateSet(this, _metadata2, metadata);
|
|
621
|
+
}
|
|
622
|
+
};
|
|
623
|
+
var Song = _Song;
|
|
624
|
+
_metadata2 = new WeakMap();
|
|
625
|
+
_member2 = new WeakMap();
|
|
626
|
+
_playlist = new WeakMap();
|
|
627
|
+
|
|
628
|
+
// src/core/DisTubeOptions.ts
|
|
629
|
+
var _validateOptions, validateOptions_fn;
|
|
630
|
+
var Options = class {
|
|
631
|
+
constructor(options) {
|
|
632
|
+
__privateAdd(this, _validateOptions);
|
|
633
|
+
__publicField(this, "plugins");
|
|
634
|
+
__publicField(this, "emitNewSongOnly");
|
|
635
|
+
__publicField(this, "leaveOnFinish");
|
|
636
|
+
__publicField(this, "leaveOnStop");
|
|
637
|
+
__publicField(this, "leaveOnEmpty");
|
|
638
|
+
__publicField(this, "emptyCooldown");
|
|
639
|
+
__publicField(this, "savePreviousSongs");
|
|
640
|
+
__publicField(this, "searchSongs");
|
|
641
|
+
__publicField(this, "searchCooldown");
|
|
642
|
+
__publicField(this, "youtubeCookie");
|
|
643
|
+
__publicField(this, "youtubeIdentityToken");
|
|
644
|
+
__publicField(this, "customFilters");
|
|
645
|
+
__publicField(this, "ytdlOptions");
|
|
646
|
+
__publicField(this, "nsfw");
|
|
647
|
+
__publicField(this, "emitAddSongWhenCreatingQueue");
|
|
648
|
+
__publicField(this, "emitAddListWhenCreatingQueue");
|
|
649
|
+
__publicField(this, "joinNewVoiceChannel");
|
|
650
|
+
if (typeof options !== "object" || Array.isArray(options)) {
|
|
651
|
+
throw new DisTubeError("INVALID_TYPE", "object", options, "DisTubeOptions");
|
|
652
|
+
}
|
|
653
|
+
const opts = { ...defaultOptions, ...options };
|
|
654
|
+
this.plugins = opts.plugins;
|
|
655
|
+
this.emitNewSongOnly = opts.emitNewSongOnly;
|
|
656
|
+
this.leaveOnEmpty = opts.leaveOnEmpty;
|
|
657
|
+
this.leaveOnFinish = opts.leaveOnFinish;
|
|
658
|
+
this.leaveOnStop = opts.leaveOnStop;
|
|
659
|
+
this.savePreviousSongs = opts.savePreviousSongs;
|
|
660
|
+
this.searchSongs = opts.searchSongs;
|
|
661
|
+
this.youtubeCookie = opts.youtubeCookie;
|
|
662
|
+
this.youtubeIdentityToken = opts.youtubeIdentityToken;
|
|
663
|
+
this.customFilters = opts.customFilters;
|
|
664
|
+
this.ytdlOptions = opts.ytdlOptions;
|
|
665
|
+
this.searchCooldown = opts.searchCooldown;
|
|
666
|
+
this.emptyCooldown = opts.emptyCooldown;
|
|
667
|
+
this.nsfw = opts.nsfw;
|
|
668
|
+
this.emitAddSongWhenCreatingQueue = opts.emitAddSongWhenCreatingQueue;
|
|
669
|
+
this.emitAddListWhenCreatingQueue = opts.emitAddListWhenCreatingQueue;
|
|
670
|
+
this.joinNewVoiceChannel = opts.joinNewVoiceChannel;
|
|
671
|
+
checkInvalidKey(opts, this, "DisTubeOptions");
|
|
672
|
+
__privateMethod(this, _validateOptions, validateOptions_fn).call(this);
|
|
673
|
+
}
|
|
674
|
+
};
|
|
675
|
+
_validateOptions = new WeakSet();
|
|
676
|
+
validateOptions_fn = /* @__PURE__ */ __name(function(options = this) {
|
|
677
|
+
if (typeof options.emitNewSongOnly !== "boolean") {
|
|
678
|
+
throw new DisTubeError("INVALID_TYPE", "boolean", options.emitNewSongOnly, "DisTubeOptions.emitNewSongOnly");
|
|
679
|
+
}
|
|
680
|
+
if (typeof options.leaveOnEmpty !== "boolean") {
|
|
681
|
+
throw new DisTubeError("INVALID_TYPE", "boolean", options.leaveOnEmpty, "DisTubeOptions.leaveOnEmpty");
|
|
682
|
+
}
|
|
683
|
+
if (typeof options.leaveOnFinish !== "boolean") {
|
|
684
|
+
throw new DisTubeError("INVALID_TYPE", "boolean", options.leaveOnFinish, "DisTubeOptions.leaveOnFinish");
|
|
685
|
+
}
|
|
686
|
+
if (typeof options.leaveOnStop !== "boolean") {
|
|
687
|
+
throw new DisTubeError("INVALID_TYPE", "boolean", options.leaveOnStop, "DisTubeOptions.leaveOnStop");
|
|
688
|
+
}
|
|
689
|
+
if (typeof options.savePreviousSongs !== "boolean") {
|
|
690
|
+
throw new DisTubeError("INVALID_TYPE", "boolean", options.savePreviousSongs, "DisTubeOptions.savePreviousSongs");
|
|
691
|
+
}
|
|
692
|
+
if (typeof options.joinNewVoiceChannel !== "boolean") {
|
|
693
|
+
throw new DisTubeError("INVALID_TYPE", "boolean", options.joinNewVoiceChannel, "DisTubeOptions.joinNewVoiceChannel");
|
|
694
|
+
}
|
|
695
|
+
if (typeof options.youtubeCookie !== "undefined" && typeof options.youtubeCookie !== "string") {
|
|
696
|
+
throw new DisTubeError("INVALID_TYPE", "string", options.youtubeCookie, "DisTubeOptions.youtubeCookie");
|
|
697
|
+
}
|
|
698
|
+
if (typeof options.youtubeIdentityToken !== "undefined" && typeof options.youtubeIdentityToken !== "string") {
|
|
699
|
+
throw new DisTubeError("INVALID_TYPE", "string", options.youtubeIdentityToken, "DisTubeOptions.youtubeIdentityToken");
|
|
700
|
+
}
|
|
701
|
+
if (typeof options.customFilters !== "undefined" && typeof options.customFilters !== "object" || Array.isArray(options.customFilters)) {
|
|
702
|
+
throw new DisTubeError("INVALID_TYPE", "object", options.customFilters, "DisTubeOptions.customFilters");
|
|
703
|
+
}
|
|
704
|
+
if (typeof options.ytdlOptions !== "object" || Array.isArray(options.ytdlOptions)) {
|
|
705
|
+
throw new DisTubeError("INVALID_TYPE", "object", options.ytdlOptions, "DisTubeOptions.ytdlOptions");
|
|
706
|
+
}
|
|
707
|
+
if (typeof options.searchCooldown !== "number" || isNaN(options.searchCooldown)) {
|
|
708
|
+
throw new DisTubeError("INVALID_TYPE", "number", options.searchCooldown, "DisTubeOptions.searchCooldown");
|
|
709
|
+
}
|
|
710
|
+
if (typeof options.emptyCooldown !== "number" || isNaN(options.emptyCooldown)) {
|
|
711
|
+
throw new DisTubeError("INVALID_TYPE", "number", options.emptyCooldown, "DisTubeOptions.emptyCooldown");
|
|
712
|
+
}
|
|
713
|
+
if (typeof options.searchSongs !== "number" || isNaN(options.searchSongs)) {
|
|
714
|
+
throw new DisTubeError("INVALID_TYPE", "number", options.searchSongs, "DisTubeOptions.searchSongs");
|
|
715
|
+
}
|
|
716
|
+
if (!Array.isArray(options.plugins)) {
|
|
717
|
+
throw new DisTubeError("INVALID_TYPE", "Array<Plugin>", options.plugins, "DisTubeOptions.plugins");
|
|
718
|
+
}
|
|
719
|
+
if (typeof options.nsfw !== "boolean") {
|
|
720
|
+
throw new DisTubeError("INVALID_TYPE", "boolean", options.nsfw, "DisTubeOptions.nsfw");
|
|
721
|
+
}
|
|
722
|
+
if (typeof options.emitAddSongWhenCreatingQueue !== "boolean") {
|
|
723
|
+
throw new DisTubeError("INVALID_TYPE", "boolean", options.emitAddSongWhenCreatingQueue, "DisTubeOptions.emitAddSongWhenCreatingQueue");
|
|
724
|
+
}
|
|
725
|
+
if (typeof options.emitAddListWhenCreatingQueue !== "boolean") {
|
|
726
|
+
throw new DisTubeError("INVALID_TYPE", "boolean", options.emitAddListWhenCreatingQueue, "DisTubeOptions.emitAddListWhenCreatingQueue");
|
|
727
|
+
}
|
|
728
|
+
}, "#validateOptions");
|
|
729
|
+
|
|
730
|
+
// src/core/DisTubeBase.ts
|
|
731
|
+
var DisTubeBase = class {
|
|
732
|
+
constructor(distube) {
|
|
733
|
+
__publicField(this, "distube");
|
|
734
|
+
this.distube = distube;
|
|
735
|
+
}
|
|
736
|
+
emit(eventName, ...args) {
|
|
737
|
+
return this.distube.emit(eventName, ...args);
|
|
738
|
+
}
|
|
739
|
+
emitError(error, channel) {
|
|
740
|
+
this.distube.emitError(error, channel);
|
|
741
|
+
}
|
|
742
|
+
get queues() {
|
|
743
|
+
return this.distube.queues;
|
|
744
|
+
}
|
|
745
|
+
get voices() {
|
|
746
|
+
return this.distube.voices;
|
|
747
|
+
}
|
|
748
|
+
get client() {
|
|
749
|
+
return this.distube.client;
|
|
750
|
+
}
|
|
751
|
+
get options() {
|
|
752
|
+
return this.distube.options;
|
|
753
|
+
}
|
|
754
|
+
get handler() {
|
|
755
|
+
return this.distube.handler;
|
|
756
|
+
}
|
|
757
|
+
};
|
|
758
|
+
|
|
759
|
+
// src/core/DisTubeStream.ts
|
|
760
|
+
var import_prism_media = require("prism-media");
|
|
761
|
+
var import_voice = require("@discordjs/voice");
|
|
762
|
+
var chooseBestVideoFormat = /* @__PURE__ */ __name((formats, isLive = false) => {
|
|
763
|
+
let filter = /* @__PURE__ */ __name((format) => format.hasAudio, "filter");
|
|
764
|
+
if (isLive)
|
|
765
|
+
filter = /* @__PURE__ */ __name((format) => format.hasAudio && format.isHLS, "filter");
|
|
766
|
+
formats = formats.filter(filter).sort((a, b) => Number(b.audioBitrate) - Number(a.audioBitrate) || Number(a.bitrate) - Number(b.bitrate));
|
|
767
|
+
return formats.find((format) => !format.hasVideo) || formats.sort((a, b) => Number(a.bitrate) - Number(b.bitrate))[0];
|
|
768
|
+
}, "chooseBestVideoFormat");
|
|
769
|
+
var DisTubeStream = class {
|
|
770
|
+
constructor(url, options) {
|
|
771
|
+
__publicField(this, "type");
|
|
772
|
+
__publicField(this, "stream");
|
|
773
|
+
__publicField(this, "url");
|
|
774
|
+
this.url = url;
|
|
775
|
+
this.type = import_voice.StreamType.Raw;
|
|
776
|
+
const args = [
|
|
777
|
+
"-reconnect",
|
|
778
|
+
"1",
|
|
779
|
+
"-reconnect_streamed",
|
|
780
|
+
"1",
|
|
781
|
+
"-reconnect_delay_max",
|
|
782
|
+
"5",
|
|
783
|
+
"-i",
|
|
784
|
+
url,
|
|
785
|
+
"-analyzeduration",
|
|
786
|
+
"0",
|
|
787
|
+
"-loglevel",
|
|
788
|
+
"0",
|
|
789
|
+
"-ar",
|
|
790
|
+
"48000",
|
|
791
|
+
"-ac",
|
|
792
|
+
"2",
|
|
793
|
+
"-f",
|
|
794
|
+
"s16le"
|
|
795
|
+
];
|
|
796
|
+
if (typeof options.seek === "number" && options.seek > 0) {
|
|
797
|
+
args.unshift("-ss", options.seek.toString());
|
|
798
|
+
}
|
|
799
|
+
if (Array.isArray(options.ffmpegArgs)) {
|
|
800
|
+
args.push(...options.ffmpegArgs);
|
|
801
|
+
}
|
|
802
|
+
this.stream = new import_prism_media.FFmpeg({ args, shell: false });
|
|
803
|
+
}
|
|
804
|
+
static YouTube(formats, options = {}) {
|
|
805
|
+
if (!formats || !formats.length)
|
|
806
|
+
throw new DisTubeError("UNAVAILABLE_VIDEO");
|
|
807
|
+
if (!options || typeof options !== "object" || Array.isArray(options)) {
|
|
808
|
+
throw new DisTubeError("INVALID_TYPE", "object", options, "options");
|
|
809
|
+
}
|
|
810
|
+
const bestFormat = chooseBestVideoFormat(formats, options.isLive);
|
|
811
|
+
if (!bestFormat)
|
|
812
|
+
throw new DisTubeError("UNPLAYABLE_FORMATS");
|
|
813
|
+
return new DisTubeStream(bestFormat.url, options);
|
|
814
|
+
}
|
|
815
|
+
static DirectLink(url, options = {}) {
|
|
816
|
+
if (!options || typeof options !== "object" || Array.isArray(options)) {
|
|
817
|
+
throw new DisTubeError("INVALID_TYPE", "object", options, "options");
|
|
818
|
+
}
|
|
819
|
+
if (typeof url !== "string" || !isURL(url)) {
|
|
820
|
+
throw new DisTubeError("INVALID_TYPE", "an URL", url);
|
|
821
|
+
}
|
|
822
|
+
return new DisTubeStream(url, options);
|
|
823
|
+
}
|
|
824
|
+
};
|
|
825
|
+
|
|
826
|
+
// src/core/manager/BaseManager.ts
|
|
827
|
+
var import_discord = require("discord.js");
|
|
828
|
+
var BaseManager = class extends DisTubeBase {
|
|
829
|
+
constructor() {
|
|
830
|
+
super(...arguments);
|
|
831
|
+
__publicField(this, "collection", new import_discord.Collection());
|
|
832
|
+
}
|
|
833
|
+
get size() {
|
|
834
|
+
return this.collection.size;
|
|
835
|
+
}
|
|
836
|
+
};
|
|
837
|
+
|
|
838
|
+
// src/core/manager/GuildIdManager.ts
|
|
839
|
+
var GuildIdManager = class extends BaseManager {
|
|
840
|
+
add(idOrInstance, data) {
|
|
841
|
+
const id = resolveGuildId(idOrInstance);
|
|
842
|
+
const existing = this.get(id);
|
|
843
|
+
if (existing)
|
|
844
|
+
return this;
|
|
845
|
+
return this.collection.set(id, data);
|
|
846
|
+
}
|
|
847
|
+
get(idOrInstance) {
|
|
848
|
+
return this.collection.get(resolveGuildId(idOrInstance));
|
|
849
|
+
}
|
|
850
|
+
remove(idOrInstance) {
|
|
851
|
+
return this.collection.delete(resolveGuildId(idOrInstance));
|
|
852
|
+
}
|
|
853
|
+
has(idOrInstance) {
|
|
854
|
+
return this.collection.has(resolveGuildId(idOrInstance));
|
|
855
|
+
}
|
|
856
|
+
};
|
|
857
|
+
|
|
858
|
+
// src/core/manager/QueueManager.ts
|
|
859
|
+
var _voiceEventHandler, voiceEventHandler_fn, _handleSongFinish, handleSongFinish_fn, _handlePlayingError, handlePlayingError_fn, _emitPlaySong, emitPlaySong_fn;
|
|
860
|
+
var QueueManager = class extends GuildIdManager {
|
|
861
|
+
constructor() {
|
|
862
|
+
super(...arguments);
|
|
863
|
+
__privateAdd(this, _voiceEventHandler);
|
|
864
|
+
__privateAdd(this, _handleSongFinish);
|
|
865
|
+
__privateAdd(this, _handlePlayingError);
|
|
866
|
+
__privateAdd(this, _emitPlaySong);
|
|
867
|
+
}
|
|
868
|
+
async create(channel, song, textChannel) {
|
|
869
|
+
if (this.has(channel.guildId))
|
|
870
|
+
throw new DisTubeError("QUEUE_EXIST");
|
|
871
|
+
const voice = this.voices.create(channel);
|
|
872
|
+
const queue = new Queue(this.distube, voice, song, textChannel);
|
|
873
|
+
await queue._taskQueue.queuing();
|
|
874
|
+
try {
|
|
875
|
+
await voice.join();
|
|
876
|
+
__privateMethod(this, _voiceEventHandler, voiceEventHandler_fn).call(this, queue);
|
|
877
|
+
this.add(queue.id, queue);
|
|
878
|
+
this.emit("initQueue", queue);
|
|
879
|
+
const err = await this.playSong(queue);
|
|
880
|
+
return err || queue;
|
|
881
|
+
} finally {
|
|
882
|
+
queue._taskQueue.resolve();
|
|
883
|
+
}
|
|
884
|
+
}
|
|
885
|
+
createStream(queue) {
|
|
886
|
+
const { duration, formats, isLive, source, streamURL } = queue.songs[0];
|
|
887
|
+
const ffmpegArgs = queue.filters.size ? ["-af", queue.filters.values.join(",")] : void 0;
|
|
888
|
+
const seek = duration ? queue.beginTime : void 0;
|
|
889
|
+
const streamOptions = { ffmpegArgs, seek, isLive };
|
|
890
|
+
if (source === "youtube")
|
|
891
|
+
return DisTubeStream.YouTube(formats, streamOptions);
|
|
892
|
+
return DisTubeStream.DirectLink(streamURL, streamOptions);
|
|
893
|
+
}
|
|
894
|
+
async playSong(queue) {
|
|
895
|
+
if (!queue)
|
|
896
|
+
return true;
|
|
897
|
+
if (!queue.songs.length) {
|
|
898
|
+
queue.stop();
|
|
899
|
+
return true;
|
|
900
|
+
}
|
|
901
|
+
if (queue.stopped)
|
|
902
|
+
return false;
|
|
903
|
+
const song = queue.songs[0];
|
|
904
|
+
try {
|
|
905
|
+
const { url, source, formats, streamURL } = song;
|
|
906
|
+
if (source === "youtube" && !formats)
|
|
907
|
+
song._patchYouTube(await this.handler.getYouTubeInfo(url));
|
|
908
|
+
if (source !== "youtube" && !streamURL) {
|
|
909
|
+
for (const plugin of [...this.distube.extractorPlugins, ...this.distube.customPlugins]) {
|
|
910
|
+
if (await plugin.validate(url)) {
|
|
911
|
+
const info = [plugin.getStreamURL(url), plugin.getRelatedSongs(url)];
|
|
912
|
+
const result = await Promise.all(info);
|
|
913
|
+
song.streamURL = result[0];
|
|
914
|
+
song.related = result[1];
|
|
915
|
+
break;
|
|
916
|
+
}
|
|
917
|
+
}
|
|
918
|
+
}
|
|
919
|
+
const stream = this.createStream(queue);
|
|
920
|
+
queue.voice.play(stream);
|
|
921
|
+
song.streamURL = stream.url;
|
|
922
|
+
if (queue.stopped)
|
|
923
|
+
queue.stop();
|
|
924
|
+
else if (queue.paused)
|
|
925
|
+
queue.voice.pause();
|
|
926
|
+
return false;
|
|
927
|
+
} catch (e) {
|
|
928
|
+
__privateMethod(this, _handlePlayingError, handlePlayingError_fn).call(this, queue, e);
|
|
929
|
+
return true;
|
|
930
|
+
}
|
|
931
|
+
}
|
|
932
|
+
};
|
|
933
|
+
_voiceEventHandler = new WeakSet();
|
|
934
|
+
voiceEventHandler_fn = /* @__PURE__ */ __name(function(queue) {
|
|
935
|
+
queue._listeners = {
|
|
936
|
+
disconnect: (error) => {
|
|
937
|
+
queue.remove();
|
|
938
|
+
this.emit("disconnect", queue);
|
|
939
|
+
if (error)
|
|
940
|
+
this.emitError(error, queue.textChannel);
|
|
941
|
+
},
|
|
942
|
+
error: (error) => __privateMethod(this, _handlePlayingError, handlePlayingError_fn).call(this, queue, error),
|
|
943
|
+
finish: () => __privateMethod(this, _handleSongFinish, handleSongFinish_fn).call(this, queue)
|
|
944
|
+
};
|
|
945
|
+
for (const event of Object.keys(queue._listeners)) {
|
|
946
|
+
queue.voice.on(event, queue._listeners[event]);
|
|
947
|
+
}
|
|
948
|
+
}, "#voiceEventHandler");
|
|
949
|
+
_handleSongFinish = new WeakSet();
|
|
950
|
+
handleSongFinish_fn = /* @__PURE__ */ __name(async function(queue) {
|
|
951
|
+
this.emit("finishSong", queue, queue.songs[0]);
|
|
952
|
+
await queue._taskQueue.queuing();
|
|
953
|
+
try {
|
|
954
|
+
if (queue.stopped)
|
|
955
|
+
return;
|
|
956
|
+
if (queue.repeatMode === 2 /* QUEUE */ && !queue._prev)
|
|
957
|
+
queue.songs.push(queue.songs[0]);
|
|
958
|
+
if (queue._prev) {
|
|
959
|
+
if (queue.repeatMode === 2 /* QUEUE */)
|
|
960
|
+
queue.songs.unshift(queue.songs.pop());
|
|
961
|
+
else
|
|
962
|
+
queue.songs.unshift(queue.previousSongs.pop());
|
|
963
|
+
}
|
|
964
|
+
if (queue.songs.length <= 1 && (queue._next || queue.repeatMode === 0 /* DISABLED */)) {
|
|
965
|
+
if (queue.autoplay) {
|
|
966
|
+
try {
|
|
967
|
+
await queue.addRelatedSong();
|
|
968
|
+
} catch {
|
|
969
|
+
this.emit("noRelated", queue);
|
|
970
|
+
}
|
|
971
|
+
}
|
|
972
|
+
if (queue.songs.length <= 1) {
|
|
973
|
+
if (this.options.leaveOnFinish)
|
|
974
|
+
queue.voice.leave();
|
|
975
|
+
if (!queue.autoplay)
|
|
976
|
+
this.emit("finish", queue);
|
|
977
|
+
queue.remove();
|
|
978
|
+
return;
|
|
979
|
+
}
|
|
980
|
+
}
|
|
981
|
+
const emitPlaySong = __privateMethod(this, _emitPlaySong, emitPlaySong_fn).call(this, queue);
|
|
982
|
+
if (!queue._prev && (queue.repeatMode !== 1 /* SONG */ || queue._next)) {
|
|
983
|
+
const prev = queue.songs.shift();
|
|
984
|
+
delete prev.formats;
|
|
985
|
+
delete prev.streamURL;
|
|
986
|
+
if (this.options.savePreviousSongs)
|
|
987
|
+
queue.previousSongs.push(prev);
|
|
988
|
+
else
|
|
989
|
+
queue.previousSongs.push({ id: prev.id });
|
|
990
|
+
}
|
|
991
|
+
queue._next = queue._prev = false;
|
|
992
|
+
queue.beginTime = 0;
|
|
993
|
+
const err = await this.playSong(queue);
|
|
994
|
+
if (!err && emitPlaySong)
|
|
995
|
+
this.emit("playSong", queue, queue.songs[0]);
|
|
996
|
+
} finally {
|
|
997
|
+
queue._taskQueue.resolve();
|
|
998
|
+
}
|
|
999
|
+
}, "#handleSongFinish");
|
|
1000
|
+
_handlePlayingError = new WeakSet();
|
|
1001
|
+
handlePlayingError_fn = /* @__PURE__ */ __name(function(queue, error) {
|
|
1002
|
+
const song = queue.songs.shift();
|
|
1003
|
+
try {
|
|
1004
|
+
error.name = "PlayingError";
|
|
1005
|
+
error.message = `${error.message}
|
|
1006
|
+
Id: ${song.id}
|
|
1007
|
+
Name: ${song.name}`;
|
|
1008
|
+
} catch {
|
|
1009
|
+
}
|
|
1010
|
+
this.emitError(error, queue.textChannel);
|
|
1011
|
+
if (queue.songs.length > 0) {
|
|
1012
|
+
this.playSong(queue).then((e) => {
|
|
1013
|
+
if (!e)
|
|
1014
|
+
this.emit("playSong", queue, queue.songs[0]);
|
|
1015
|
+
});
|
|
1016
|
+
} else {
|
|
1017
|
+
queue.stop();
|
|
1018
|
+
}
|
|
1019
|
+
}, "#handlePlayingError");
|
|
1020
|
+
_emitPlaySong = new WeakSet();
|
|
1021
|
+
emitPlaySong_fn = /* @__PURE__ */ __name(function(queue) {
|
|
1022
|
+
return !this.options.emitNewSongOnly || queue.repeatMode === 1 /* SONG */ && queue._next || queue.repeatMode !== 1 /* SONG */ && queue.songs[0]?.id !== queue.songs[1]?.id;
|
|
1023
|
+
}, "#emitPlaySong");
|
|
1024
|
+
|
|
1025
|
+
// src/core/manager/FilterManager.ts
|
|
1026
|
+
var _validate, validate_fn, _resolveName, resolveName_fn, _resolveValue, resolveValue_fn, _apply, apply_fn;
|
|
1027
|
+
var FilterManager = class extends BaseManager {
|
|
1028
|
+
constructor(queue) {
|
|
1029
|
+
super(queue.distube);
|
|
1030
|
+
__privateAdd(this, _validate);
|
|
1031
|
+
__privateAdd(this, _resolveName);
|
|
1032
|
+
__privateAdd(this, _resolveValue);
|
|
1033
|
+
__privateAdd(this, _apply);
|
|
1034
|
+
__publicField(this, "queue");
|
|
1035
|
+
this.queue = queue;
|
|
1036
|
+
}
|
|
1037
|
+
add(filterOrFilters, override = false) {
|
|
1038
|
+
if (Array.isArray(filterOrFilters)) {
|
|
1039
|
+
const resolvedFilters = filterOrFilters.map((f) => __privateMethod(this, _validate, validate_fn).call(this, f));
|
|
1040
|
+
const newFilters = resolvedFilters.reduceRight((unique, o) => {
|
|
1041
|
+
if (!unique.some((obj) => obj === o && obj.name === o) && !unique.some((obj) => obj !== o.name && obj.name !== o.name)) {
|
|
1042
|
+
if (!this.has(o))
|
|
1043
|
+
unique.push(o);
|
|
1044
|
+
if (this.has(o) && override) {
|
|
1045
|
+
this.remove(o);
|
|
1046
|
+
unique.push(o);
|
|
1047
|
+
}
|
|
1048
|
+
}
|
|
1049
|
+
return unique;
|
|
1050
|
+
}, []).reverse();
|
|
1051
|
+
return this.set([...this.collection.values(), ...newFilters]);
|
|
1052
|
+
}
|
|
1053
|
+
return this.set([...this.collection.values(), filterOrFilters]);
|
|
1054
|
+
}
|
|
1055
|
+
clear() {
|
|
1056
|
+
return this.set([]);
|
|
1057
|
+
}
|
|
1058
|
+
set(filters) {
|
|
1059
|
+
this.collection.clear();
|
|
1060
|
+
for (const filter of filters) {
|
|
1061
|
+
const resolved = __privateMethod(this, _validate, validate_fn).call(this, filter);
|
|
1062
|
+
this.collection.set(__privateMethod(this, _resolveName, resolveName_fn).call(this, resolved), resolved);
|
|
1063
|
+
}
|
|
1064
|
+
__privateMethod(this, _apply, apply_fn).call(this);
|
|
1065
|
+
return this;
|
|
1066
|
+
}
|
|
1067
|
+
remove(filterOrFilters) {
|
|
1068
|
+
const remove = /* @__PURE__ */ __name((f) => this.collection.delete(__privateMethod(this, _resolveName, resolveName_fn).call(this, __privateMethod(this, _validate, validate_fn).call(this, f))), "remove");
|
|
1069
|
+
if (Array.isArray(filterOrFilters))
|
|
1070
|
+
filterOrFilters.map(remove);
|
|
1071
|
+
else
|
|
1072
|
+
remove(filterOrFilters);
|
|
1073
|
+
__privateMethod(this, _apply, apply_fn).call(this);
|
|
1074
|
+
return this;
|
|
1075
|
+
}
|
|
1076
|
+
has(filter) {
|
|
1077
|
+
return this.collection.has(__privateMethod(this, _resolveName, resolveName_fn).call(this, filter));
|
|
1078
|
+
}
|
|
1079
|
+
get names() {
|
|
1080
|
+
return this.collection.map((f) => __privateMethod(this, _resolveName, resolveName_fn).call(this, f));
|
|
1081
|
+
}
|
|
1082
|
+
get values() {
|
|
1083
|
+
return this.collection.map((f) => __privateMethod(this, _resolveValue, resolveValue_fn).call(this, f));
|
|
1084
|
+
}
|
|
1085
|
+
toString() {
|
|
1086
|
+
return this.names.toString();
|
|
1087
|
+
}
|
|
1088
|
+
};
|
|
1089
|
+
_validate = new WeakSet();
|
|
1090
|
+
validate_fn = /* @__PURE__ */ __name(function(filter) {
|
|
1091
|
+
if (typeof filter === "string" && Object.prototype.hasOwnProperty.call(this.distube.filters, filter) || typeof filter === "object" && typeof filter.name === "string" && typeof filter.value === "string") {
|
|
1092
|
+
return filter;
|
|
1093
|
+
}
|
|
1094
|
+
throw new DisTubeError("INVALID_TYPE", "FilterResolvable", filter, "filter");
|
|
1095
|
+
}, "#validate");
|
|
1096
|
+
_resolveName = new WeakSet();
|
|
1097
|
+
resolveName_fn = /* @__PURE__ */ __name(function(filter) {
|
|
1098
|
+
return typeof filter === "string" ? filter : filter.name;
|
|
1099
|
+
}, "#resolveName");
|
|
1100
|
+
_resolveValue = new WeakSet();
|
|
1101
|
+
resolveValue_fn = /* @__PURE__ */ __name(function(filter) {
|
|
1102
|
+
return typeof filter === "string" ? this.distube.filters[filter] : filter.value;
|
|
1103
|
+
}, "#resolveValue");
|
|
1104
|
+
_apply = new WeakSet();
|
|
1105
|
+
apply_fn = /* @__PURE__ */ __name(function() {
|
|
1106
|
+
this.queue.beginTime = this.queue.currentTime;
|
|
1107
|
+
this.queues.playSong(this.queue);
|
|
1108
|
+
}, "#apply");
|
|
1109
|
+
|
|
1110
|
+
// src/core/voice/DisTubeVoice.ts
|
|
1111
|
+
var import_tiny_typed_emitter = require("tiny-typed-emitter");
|
|
1112
|
+
var import_voice2 = require("@discordjs/voice");
|
|
1113
|
+
var _channel, _volume, _br, br_fn, _join, join_fn;
|
|
1114
|
+
var DisTubeVoice = class extends import_tiny_typed_emitter.TypedEmitter {
|
|
1115
|
+
constructor(voiceManager, channel) {
|
|
1116
|
+
super();
|
|
1117
|
+
__privateAdd(this, _br);
|
|
1118
|
+
__privateAdd(this, _join);
|
|
1119
|
+
__publicField(this, "id");
|
|
1120
|
+
__publicField(this, "voices");
|
|
1121
|
+
__publicField(this, "audioPlayer");
|
|
1122
|
+
__publicField(this, "connection");
|
|
1123
|
+
__publicField(this, "audioResource");
|
|
1124
|
+
__publicField(this, "emittedError");
|
|
1125
|
+
__publicField(this, "isDisconnected", false);
|
|
1126
|
+
__privateAdd(this, _channel, void 0);
|
|
1127
|
+
__privateAdd(this, _volume, 100);
|
|
1128
|
+
this.id = channel.guildId;
|
|
1129
|
+
this.channel = channel;
|
|
1130
|
+
this.voices = voiceManager;
|
|
1131
|
+
this.voices.add(this.id, this);
|
|
1132
|
+
this.audioPlayer = (0, import_voice2.createAudioPlayer)().on(import_voice2.AudioPlayerStatus.Idle, (oldState) => {
|
|
1133
|
+
if (oldState.status !== import_voice2.AudioPlayerStatus.Idle) {
|
|
1134
|
+
delete this.audioResource;
|
|
1135
|
+
this.emit("finish");
|
|
1136
|
+
}
|
|
1137
|
+
}).on(import_voice2.AudioPlayerStatus.Playing, () => __privateMethod(this, _br, br_fn).call(this)).on("error", (error) => {
|
|
1138
|
+
if (this.emittedError)
|
|
1139
|
+
return;
|
|
1140
|
+
this.emittedError = true;
|
|
1141
|
+
this.emit("error", error);
|
|
1142
|
+
});
|
|
1143
|
+
this.connection.on(import_voice2.VoiceConnectionStatus.Disconnected, (_, newState) => {
|
|
1144
|
+
if (newState.reason === import_voice2.VoiceConnectionDisconnectReason.Manual) {
|
|
1145
|
+
this.leave();
|
|
1146
|
+
} else if (newState.reason === import_voice2.VoiceConnectionDisconnectReason.WebSocketClose && newState.closeCode === 4014) {
|
|
1147
|
+
entersState(this.connection, import_voice2.VoiceConnectionStatus.Connecting, 5e3).catch(() => {
|
|
1148
|
+
if (![import_voice2.VoiceConnectionStatus.Ready, import_voice2.VoiceConnectionStatus.Connecting].includes(this.connection.state.status)) {
|
|
1149
|
+
this.leave();
|
|
1150
|
+
}
|
|
1151
|
+
});
|
|
1152
|
+
} else if (this.connection.rejoinAttempts < 5) {
|
|
1153
|
+
setTimeout(() => {
|
|
1154
|
+
this.connection.rejoin();
|
|
1155
|
+
}, (this.connection.rejoinAttempts + 1) * 5e3).unref();
|
|
1156
|
+
} else if (this.connection.state.status !== import_voice2.VoiceConnectionStatus.Destroyed) {
|
|
1157
|
+
this.leave(new DisTubeError("VOICE_RECONNECT_FAILED"));
|
|
1158
|
+
}
|
|
1159
|
+
}).on(import_voice2.VoiceConnectionStatus.Destroyed, () => {
|
|
1160
|
+
this.leave(new DisTubeError("VOICE_RECONNECT_FAILED"));
|
|
1161
|
+
}).on("error", () => void 0);
|
|
1162
|
+
this.connection.subscribe(this.audioPlayer);
|
|
1163
|
+
}
|
|
1164
|
+
get channel() {
|
|
1165
|
+
return __privateGet(this, _channel);
|
|
1166
|
+
}
|
|
1167
|
+
set channel(channel) {
|
|
1168
|
+
if (!isSupportedVoiceChannel(channel)) {
|
|
1169
|
+
throw new DisTubeError("INVALID_TYPE", "BaseGuildVoiceChannel", channel, "DisTubeVoice#channel");
|
|
1170
|
+
}
|
|
1171
|
+
if (channel.guildId !== this.id)
|
|
1172
|
+
throw new DisTubeError("VOICE_DIFFERENT_GUILD");
|
|
1173
|
+
if (channel.id === __privateGet(this, _channel)?.id)
|
|
1174
|
+
return;
|
|
1175
|
+
if (!channel.joinable) {
|
|
1176
|
+
if (channel.full)
|
|
1177
|
+
throw new DisTubeError("VOICE_FULL");
|
|
1178
|
+
else
|
|
1179
|
+
throw new DisTubeError("VOICE_MISSING_PERMS");
|
|
1180
|
+
}
|
|
1181
|
+
this.connection = __privateMethod(this, _join, join_fn).call(this, channel);
|
|
1182
|
+
__privateSet(this, _channel, channel);
|
|
1183
|
+
__privateMethod(this, _br, br_fn).call(this);
|
|
1184
|
+
}
|
|
1185
|
+
async join(channel) {
|
|
1186
|
+
const TIMEOUT = 3e4;
|
|
1187
|
+
if (channel)
|
|
1188
|
+
this.channel = channel;
|
|
1189
|
+
try {
|
|
1190
|
+
await entersState(this.connection, import_voice2.VoiceConnectionStatus.Ready, TIMEOUT);
|
|
1191
|
+
} catch {
|
|
1192
|
+
if (this.connection.state.status === import_voice2.VoiceConnectionStatus.Ready)
|
|
1193
|
+
return this;
|
|
1194
|
+
if (this.connection.state.status !== import_voice2.VoiceConnectionStatus.Destroyed)
|
|
1195
|
+
this.connection.destroy();
|
|
1196
|
+
this.voices.remove(this.id);
|
|
1197
|
+
throw new DisTubeError("VOICE_CONNECT_FAILED", TIMEOUT / 1e3);
|
|
1198
|
+
}
|
|
1199
|
+
return this;
|
|
1200
|
+
}
|
|
1201
|
+
leave(error) {
|
|
1202
|
+
this.stop(true);
|
|
1203
|
+
if (!this.isDisconnected) {
|
|
1204
|
+
this.emit("disconnect", error);
|
|
1205
|
+
this.isDisconnected = true;
|
|
1206
|
+
}
|
|
1207
|
+
if (this.connection.state.status !== import_voice2.VoiceConnectionStatus.Destroyed)
|
|
1208
|
+
this.connection.destroy();
|
|
1209
|
+
this.voices.remove(this.id);
|
|
1210
|
+
}
|
|
1211
|
+
stop(force = false) {
|
|
1212
|
+
this.audioPlayer.stop(force);
|
|
1213
|
+
}
|
|
1214
|
+
play(stream) {
|
|
1215
|
+
this.emittedError = false;
|
|
1216
|
+
stream.stream.on("error", (error) => {
|
|
1217
|
+
if (this.emittedError || error.code === "ERR_STREAM_PREMATURE_CLOSE")
|
|
1218
|
+
return;
|
|
1219
|
+
this.emittedError = true;
|
|
1220
|
+
this.emit("error", error);
|
|
1221
|
+
});
|
|
1222
|
+
this.audioResource = (0, import_voice2.createAudioResource)(stream.stream, {
|
|
1223
|
+
inputType: stream.type,
|
|
1224
|
+
inlineVolume: true
|
|
1225
|
+
});
|
|
1226
|
+
this.volume = __privateGet(this, _volume);
|
|
1227
|
+
this.audioPlayer.play(this.audioResource);
|
|
1228
|
+
}
|
|
1229
|
+
set volume(volume) {
|
|
1230
|
+
if (typeof volume !== "number" || isNaN(volume)) {
|
|
1231
|
+
throw new DisTubeError("INVALID_TYPE", "number", volume, "volume");
|
|
1232
|
+
}
|
|
1233
|
+
if (volume < 0) {
|
|
1234
|
+
throw new DisTubeError("NUMBER_COMPARE", "Volume", "bigger or equal to", 0);
|
|
1235
|
+
}
|
|
1236
|
+
__privateSet(this, _volume, volume);
|
|
1237
|
+
this.audioResource?.volume?.setVolume(Math.pow(__privateGet(this, _volume) / 100, 0.5 / Math.log10(2)));
|
|
1238
|
+
}
|
|
1239
|
+
get volume() {
|
|
1240
|
+
return __privateGet(this, _volume);
|
|
1241
|
+
}
|
|
1242
|
+
get playbackDuration() {
|
|
1243
|
+
return (this.audioResource?.playbackDuration ?? 0) / 1e3;
|
|
1244
|
+
}
|
|
1245
|
+
pause() {
|
|
1246
|
+
this.audioPlayer.pause();
|
|
1247
|
+
}
|
|
1248
|
+
unpause() {
|
|
1249
|
+
this.audioPlayer.unpause();
|
|
1250
|
+
}
|
|
1251
|
+
get selfDeaf() {
|
|
1252
|
+
return this.connection.joinConfig.selfDeaf;
|
|
1253
|
+
}
|
|
1254
|
+
get selfMute() {
|
|
1255
|
+
return this.connection.joinConfig.selfMute;
|
|
1256
|
+
}
|
|
1257
|
+
setSelfDeaf(selfDeaf) {
|
|
1258
|
+
if (typeof selfDeaf !== "boolean") {
|
|
1259
|
+
throw new DisTubeError("INVALID_TYPE", "boolean", selfDeaf, "selfDeaf");
|
|
1260
|
+
}
|
|
1261
|
+
return this.connection.rejoin({
|
|
1262
|
+
...this.connection.joinConfig,
|
|
1263
|
+
selfDeaf
|
|
1264
|
+
});
|
|
1265
|
+
}
|
|
1266
|
+
setSelfMute(selfMute) {
|
|
1267
|
+
if (typeof selfMute !== "boolean") {
|
|
1268
|
+
throw new DisTubeError("INVALID_TYPE", "boolean", selfMute, "selfMute");
|
|
1269
|
+
}
|
|
1270
|
+
return this.connection.rejoin({
|
|
1271
|
+
...this.connection.joinConfig,
|
|
1272
|
+
selfMute
|
|
1273
|
+
});
|
|
1274
|
+
}
|
|
1275
|
+
get voiceState() {
|
|
1276
|
+
return this.channel?.guild?.me?.voice;
|
|
1277
|
+
}
|
|
1278
|
+
};
|
|
1279
|
+
_channel = new WeakMap();
|
|
1280
|
+
_volume = new WeakMap();
|
|
1281
|
+
_br = new WeakSet();
|
|
1282
|
+
br_fn = /* @__PURE__ */ __name(function() {
|
|
1283
|
+
if (this.audioResource?.encoder?.encoder)
|
|
1284
|
+
this.audioResource.encoder.setBitrate(this.channel.bitrate);
|
|
1285
|
+
}, "#br");
|
|
1286
|
+
_join = new WeakSet();
|
|
1287
|
+
join_fn = /* @__PURE__ */ __name(function(channel) {
|
|
1288
|
+
return (0, import_voice2.joinVoiceChannel)({
|
|
1289
|
+
channelId: channel.id,
|
|
1290
|
+
guildId: this.id,
|
|
1291
|
+
adapterCreator: channel.guild.voiceAdapterCreator,
|
|
1292
|
+
group: channel.client.user?.id
|
|
1293
|
+
});
|
|
1294
|
+
}, "#join");
|
|
1295
|
+
|
|
1296
|
+
// src/core/voice/DisTubeVoiceManager.ts
|
|
1297
|
+
var import_voice3 = require("@discordjs/voice");
|
|
1298
|
+
var DisTubeVoiceManager = class extends GuildIdManager {
|
|
1299
|
+
create(channel) {
|
|
1300
|
+
const existing = this.get(channel.guildId);
|
|
1301
|
+
if (existing) {
|
|
1302
|
+
existing.channel = channel;
|
|
1303
|
+
return existing;
|
|
1304
|
+
}
|
|
1305
|
+
return new DisTubeVoice(this, channel);
|
|
1306
|
+
}
|
|
1307
|
+
join(channel) {
|
|
1308
|
+
const existing = this.get(channel.guildId);
|
|
1309
|
+
if (existing)
|
|
1310
|
+
return existing.join(channel);
|
|
1311
|
+
return this.create(channel).join();
|
|
1312
|
+
}
|
|
1313
|
+
leave(guild) {
|
|
1314
|
+
const voice = this.get(guild);
|
|
1315
|
+
if (voice) {
|
|
1316
|
+
voice.leave();
|
|
1317
|
+
} else {
|
|
1318
|
+
const connection = (0, import_voice3.getVoiceConnection)(resolveGuildId(guild), this.client.user?.id) ?? (0, import_voice3.getVoiceConnection)(resolveGuildId(guild));
|
|
1319
|
+
if (connection && connection.state.status !== import_voice3.VoiceConnectionStatus.Destroyed) {
|
|
1320
|
+
connection.destroy();
|
|
1321
|
+
}
|
|
1322
|
+
}
|
|
1323
|
+
}
|
|
1324
|
+
};
|
|
1325
|
+
|
|
1326
|
+
// src/core/DisTubeHandler.ts
|
|
1327
|
+
var import_ytdl_core = __toESM(require("@distube/ytdl-core"));
|
|
1328
|
+
var import_ytpl = __toESM(require("@distube/ytpl"));
|
|
1329
|
+
var DisTubeHandler = class extends DisTubeBase {
|
|
1330
|
+
constructor(distube) {
|
|
1331
|
+
super(distube);
|
|
1332
|
+
const client = this.client;
|
|
1333
|
+
if (this.options.leaveOnEmpty) {
|
|
1334
|
+
client.on("voiceStateUpdate", (oldState) => {
|
|
1335
|
+
if (!oldState?.channel)
|
|
1336
|
+
return;
|
|
1337
|
+
const queue = this.queues.get(oldState);
|
|
1338
|
+
if (!queue) {
|
|
1339
|
+
if (isVoiceChannelEmpty(oldState)) {
|
|
1340
|
+
setTimeout(() => {
|
|
1341
|
+
if (!this.queues.get(oldState) && isVoiceChannelEmpty(oldState))
|
|
1342
|
+
this.voices.leave(oldState);
|
|
1343
|
+
}, this.options.emptyCooldown * 1e3).unref();
|
|
1344
|
+
}
|
|
1345
|
+
return;
|
|
1346
|
+
}
|
|
1347
|
+
if (queue._emptyTimeout) {
|
|
1348
|
+
clearTimeout(queue._emptyTimeout);
|
|
1349
|
+
delete queue._emptyTimeout;
|
|
1350
|
+
}
|
|
1351
|
+
if (isVoiceChannelEmpty(oldState)) {
|
|
1352
|
+
queue._emptyTimeout = setTimeout(() => {
|
|
1353
|
+
delete queue._emptyTimeout;
|
|
1354
|
+
if (isVoiceChannelEmpty(oldState)) {
|
|
1355
|
+
queue.voice.leave();
|
|
1356
|
+
this.emit("empty", queue);
|
|
1357
|
+
if (queue.stopped)
|
|
1358
|
+
queue.remove();
|
|
1359
|
+
}
|
|
1360
|
+
}, this.options.emptyCooldown * 1e3).unref();
|
|
1361
|
+
}
|
|
1362
|
+
});
|
|
1363
|
+
}
|
|
1364
|
+
}
|
|
1365
|
+
get ytdlOptions() {
|
|
1366
|
+
const options = this.options.ytdlOptions;
|
|
1367
|
+
if (this.options.youtubeCookie) {
|
|
1368
|
+
if (!options.requestOptions)
|
|
1369
|
+
options.requestOptions = {};
|
|
1370
|
+
if (!options.requestOptions.headers)
|
|
1371
|
+
options.requestOptions.headers = {};
|
|
1372
|
+
options.requestOptions.headers.cookie = this.options.youtubeCookie;
|
|
1373
|
+
if (this.options.youtubeIdentityToken) {
|
|
1374
|
+
options.requestOptions.headers["x-youtube-identity-token"] = this.options.youtubeIdentityToken;
|
|
1375
|
+
}
|
|
1376
|
+
}
|
|
1377
|
+
return options;
|
|
1378
|
+
}
|
|
1379
|
+
getYouTubeInfo(url, basic = false) {
|
|
1380
|
+
if (basic)
|
|
1381
|
+
return import_ytdl_core.default.getBasicInfo(url, this.ytdlOptions);
|
|
1382
|
+
return import_ytdl_core.default.getInfo(url, this.ytdlOptions);
|
|
1383
|
+
}
|
|
1384
|
+
async resolve(song, options = {}) {
|
|
1385
|
+
if (song instanceof Song || song instanceof Playlist) {
|
|
1386
|
+
if ("metadata" in options)
|
|
1387
|
+
song.metadata = options.metadata;
|
|
1388
|
+
if ("member" in options)
|
|
1389
|
+
song.member = options.member;
|
|
1390
|
+
return song;
|
|
1391
|
+
}
|
|
1392
|
+
if (song instanceof SearchResult) {
|
|
1393
|
+
if (song.type === "video" /* VIDEO */)
|
|
1394
|
+
return new Song(song, options);
|
|
1395
|
+
return this.resolvePlaylist(song.url, options);
|
|
1396
|
+
}
|
|
1397
|
+
if (isObject(song))
|
|
1398
|
+
return new Song(song, options);
|
|
1399
|
+
if (import_ytpl.default.validateID(song))
|
|
1400
|
+
return this.resolvePlaylist(song, options);
|
|
1401
|
+
if (import_ytdl_core.default.validateURL(song))
|
|
1402
|
+
return new Song(await this.getYouTubeInfo(song), options);
|
|
1403
|
+
if (isURL(song)) {
|
|
1404
|
+
for (const plugin of this.distube.extractorPlugins) {
|
|
1405
|
+
if (await plugin.validate(song))
|
|
1406
|
+
return plugin.resolve(song, options);
|
|
1407
|
+
}
|
|
1408
|
+
throw new DisTubeError("NOT_SUPPORTED_URL");
|
|
1409
|
+
}
|
|
1410
|
+
throw new DisTubeError("CANNOT_RESOLVE_SONG", song);
|
|
1411
|
+
}
|
|
1412
|
+
async resolvePlaylist(playlist, options = {}) {
|
|
1413
|
+
const { member, source, metadata } = { source: "youtube", ...options };
|
|
1414
|
+
if (playlist instanceof Playlist) {
|
|
1415
|
+
if ("metadata" in options)
|
|
1416
|
+
playlist.metadata = metadata;
|
|
1417
|
+
if ("member" in options)
|
|
1418
|
+
playlist.member = member;
|
|
1419
|
+
return playlist;
|
|
1420
|
+
}
|
|
1421
|
+
let solvablePlaylist;
|
|
1422
|
+
if (typeof playlist === "string") {
|
|
1423
|
+
solvablePlaylist = await (0, import_ytpl.default)(playlist, { limit: Infinity });
|
|
1424
|
+
solvablePlaylist.items = solvablePlaylist.items.filter((v) => !v.thumbnail.includes("no_thumbnail")).map((v) => new Song(v, { member, metadata }));
|
|
1425
|
+
} else {
|
|
1426
|
+
solvablePlaylist = playlist;
|
|
1427
|
+
}
|
|
1428
|
+
return new Playlist(solvablePlaylist, { member, properties: { source }, metadata });
|
|
1429
|
+
}
|
|
1430
|
+
async searchSong(message, query) {
|
|
1431
|
+
if (!isMessageInstance(message))
|
|
1432
|
+
throw new DisTubeError("INVALID_TYPE", "Discord.Message", message, "message");
|
|
1433
|
+
if (typeof query !== "string")
|
|
1434
|
+
throw new DisTubeError("INVALID_TYPE", "string", query, "query");
|
|
1435
|
+
if (query.length === 0)
|
|
1436
|
+
throw new DisTubeError("EMPTY_STRING", "query");
|
|
1437
|
+
const limit = this.options.searchSongs > 1 ? this.options.searchSongs : 1;
|
|
1438
|
+
const results = await this.distube.search(query, {
|
|
1439
|
+
limit,
|
|
1440
|
+
safeSearch: this.options.nsfw ? false : !message.channel?.nsfw
|
|
1441
|
+
}).catch(() => {
|
|
1442
|
+
if (!this.emit("searchNoResult", message, query)) {
|
|
1443
|
+
console.warn("searchNoResult event does not have any listeners! Emits `error` event instead.");
|
|
1444
|
+
throw new DisTubeError("NO_RESULT");
|
|
1445
|
+
}
|
|
1446
|
+
});
|
|
1447
|
+
if (!results)
|
|
1448
|
+
return null;
|
|
1449
|
+
return this.createSearchMessageCollector(message, results, query);
|
|
1450
|
+
}
|
|
1451
|
+
async createSearchMessageCollector(message, results, query) {
|
|
1452
|
+
if (!isMessageInstance(message))
|
|
1453
|
+
throw new DisTubeError("INVALID_TYPE", "Discord.Message", message, "message");
|
|
1454
|
+
if (!Array.isArray(results) || results.length == 0) {
|
|
1455
|
+
throw new DisTubeError("INVALID_TYPE", "Array<SearchResult|Song|Playlist>", results, "results");
|
|
1456
|
+
}
|
|
1457
|
+
if (this.options.searchSongs > 1) {
|
|
1458
|
+
const searchEvents = [
|
|
1459
|
+
"searchNoResult",
|
|
1460
|
+
"searchResult",
|
|
1461
|
+
"searchCancel",
|
|
1462
|
+
"searchInvalidAnswer",
|
|
1463
|
+
"searchDone"
|
|
1464
|
+
];
|
|
1465
|
+
for (const evn of searchEvents) {
|
|
1466
|
+
if (this.distube.listenerCount(evn) === 0) {
|
|
1467
|
+
console.warn(`"searchSongs" option is disabled due to missing "${evn}" listener.`);
|
|
1468
|
+
console.warn(`If you don't want to use "${evn}" event, simply add an empty listener (not recommended):
|
|
1469
|
+
<DisTube>.on("${evn}", () => {})`);
|
|
1470
|
+
this.options.searchSongs = 0;
|
|
1471
|
+
}
|
|
1472
|
+
}
|
|
1473
|
+
}
|
|
1474
|
+
const limit = this.options.searchSongs > 1 ? this.options.searchSongs : 1;
|
|
1475
|
+
let result = results[0];
|
|
1476
|
+
if (limit > 1) {
|
|
1477
|
+
results.splice(limit);
|
|
1478
|
+
this.emit("searchResult", message, results, query);
|
|
1479
|
+
const c = message.channel;
|
|
1480
|
+
const answers = await c.awaitMessages({
|
|
1481
|
+
filter: (m) => m.author.id === message.author.id,
|
|
1482
|
+
max: 1,
|
|
1483
|
+
time: this.options.searchCooldown * 1e3,
|
|
1484
|
+
errors: ["time"]
|
|
1485
|
+
}).catch(() => void 0);
|
|
1486
|
+
const ans = answers?.first();
|
|
1487
|
+
if (!ans) {
|
|
1488
|
+
this.emit("searchCancel", message, query);
|
|
1489
|
+
return null;
|
|
1490
|
+
}
|
|
1491
|
+
const index = parseInt(ans.content, 10);
|
|
1492
|
+
if (isNaN(index) || index > results.length || index < 1) {
|
|
1493
|
+
this.emit("searchInvalidAnswer", message, ans, query);
|
|
1494
|
+
return null;
|
|
1495
|
+
}
|
|
1496
|
+
this.emit("searchDone", message, ans, query);
|
|
1497
|
+
result = results[index - 1];
|
|
1498
|
+
}
|
|
1499
|
+
return result;
|
|
1500
|
+
}
|
|
1501
|
+
async playPlaylist(voiceChannel, playlist, options = {}) {
|
|
1502
|
+
const { textChannel, skip } = { skip: false, ...options };
|
|
1503
|
+
const position = Number(options.position) || (skip ? 1 : 0);
|
|
1504
|
+
if (!(playlist instanceof Playlist))
|
|
1505
|
+
throw new DisTubeError("INVALID_TYPE", "Playlist", playlist, "playlist");
|
|
1506
|
+
const queue = this.queues.get(voiceChannel);
|
|
1507
|
+
if (!this.options.nsfw && !(queue?.textChannel || textChannel)?.nsfw) {
|
|
1508
|
+
playlist.songs = playlist.songs.filter((s) => !s.age_restricted);
|
|
1509
|
+
}
|
|
1510
|
+
if (!playlist.songs.length) {
|
|
1511
|
+
if (!this.options.nsfw && !textChannel?.nsfw) {
|
|
1512
|
+
throw new DisTubeError("EMPTY_FILTERED_PLAYLIST");
|
|
1513
|
+
}
|
|
1514
|
+
throw new DisTubeError("EMPTY_PLAYLIST");
|
|
1515
|
+
}
|
|
1516
|
+
if (queue) {
|
|
1517
|
+
if (this.options.joinNewVoiceChannel)
|
|
1518
|
+
queue.voice.channel = voiceChannel;
|
|
1519
|
+
queue.addToQueue(playlist.songs, position);
|
|
1520
|
+
if (skip)
|
|
1521
|
+
queue.skip();
|
|
1522
|
+
else
|
|
1523
|
+
this.emit("addList", queue, playlist);
|
|
1524
|
+
} else {
|
|
1525
|
+
const newQueue = await this.queues.create(voiceChannel, playlist.songs, textChannel);
|
|
1526
|
+
if (newQueue instanceof Queue) {
|
|
1527
|
+
if (this.options.emitAddListWhenCreatingQueue)
|
|
1528
|
+
this.emit("addList", newQueue, playlist);
|
|
1529
|
+
this.emit("playSong", newQueue, newQueue.songs[0]);
|
|
1530
|
+
}
|
|
1531
|
+
}
|
|
1532
|
+
}
|
|
1533
|
+
async playSong(voiceChannel, song, options = {}) {
|
|
1534
|
+
if (!(song instanceof Song))
|
|
1535
|
+
throw new DisTubeError("INVALID_TYPE", "Song", song, "song");
|
|
1536
|
+
const { textChannel, skip } = { skip: false, ...options };
|
|
1537
|
+
const position = Number(options.position) || (skip ? 1 : 0);
|
|
1538
|
+
const queue = this.queues.get(voiceChannel);
|
|
1539
|
+
if (!this.options.nsfw && song.age_restricted && !(queue?.textChannel || textChannel)?.nsfw) {
|
|
1540
|
+
throw new DisTubeError("NON_NSFW");
|
|
1541
|
+
}
|
|
1542
|
+
if (queue) {
|
|
1543
|
+
if (this.options.joinNewVoiceChannel)
|
|
1544
|
+
queue.voice.channel = voiceChannel;
|
|
1545
|
+
queue.addToQueue(song, position);
|
|
1546
|
+
if (skip)
|
|
1547
|
+
queue.skip();
|
|
1548
|
+
else
|
|
1549
|
+
this.emit("addSong", queue, song);
|
|
1550
|
+
} else {
|
|
1551
|
+
const newQueue = await this.queues.create(voiceChannel, song, textChannel);
|
|
1552
|
+
if (newQueue instanceof Queue) {
|
|
1553
|
+
if (this.options.emitAddSongWhenCreatingQueue)
|
|
1554
|
+
this.emit("addSong", newQueue, song);
|
|
1555
|
+
this.emit("playSong", newQueue, song);
|
|
1556
|
+
}
|
|
1557
|
+
}
|
|
1558
|
+
}
|
|
1559
|
+
};
|
|
1560
|
+
|
|
1561
|
+
// src/struct/Queue.ts
|
|
1562
|
+
var _filters;
|
|
1563
|
+
var Queue = class extends DisTubeBase {
|
|
1564
|
+
constructor(distube, voice, song, textChannel) {
|
|
1565
|
+
super(distube);
|
|
1566
|
+
__publicField(this, "id");
|
|
1567
|
+
__publicField(this, "voice");
|
|
1568
|
+
__publicField(this, "songs");
|
|
1569
|
+
__publicField(this, "previousSongs");
|
|
1570
|
+
__publicField(this, "stopped");
|
|
1571
|
+
__publicField(this, "_next");
|
|
1572
|
+
__publicField(this, "_prev");
|
|
1573
|
+
__publicField(this, "playing");
|
|
1574
|
+
__publicField(this, "paused");
|
|
1575
|
+
__publicField(this, "repeatMode");
|
|
1576
|
+
__publicField(this, "autoplay");
|
|
1577
|
+
__privateAdd(this, _filters, void 0);
|
|
1578
|
+
__publicField(this, "beginTime");
|
|
1579
|
+
__publicField(this, "textChannel");
|
|
1580
|
+
__publicField(this, "_emptyTimeout");
|
|
1581
|
+
__publicField(this, "clientMember");
|
|
1582
|
+
__publicField(this, "_taskQueue");
|
|
1583
|
+
__publicField(this, "_listeners");
|
|
1584
|
+
this.clientMember = voice.channel.guild?.me ?? (() => {
|
|
1585
|
+
throw new DisTubeError("INVALID_TYPE", "GuildMember", null, "<VoiceChannel>.guild.me");
|
|
1586
|
+
})();
|
|
1587
|
+
this.voice = voice;
|
|
1588
|
+
this.id = voice.id;
|
|
1589
|
+
this.volume = 50;
|
|
1590
|
+
this.songs = Array.isArray(song) ? [...song] : [song];
|
|
1591
|
+
this.previousSongs = [];
|
|
1592
|
+
this.stopped = false;
|
|
1593
|
+
this._next = false;
|
|
1594
|
+
this._prev = false;
|
|
1595
|
+
this.playing = true;
|
|
1596
|
+
this.paused = false;
|
|
1597
|
+
this.repeatMode = 0 /* DISABLED */;
|
|
1598
|
+
this.autoplay = false;
|
|
1599
|
+
__privateSet(this, _filters, new FilterManager(this));
|
|
1600
|
+
this.beginTime = 0;
|
|
1601
|
+
this.textChannel = textChannel;
|
|
1602
|
+
this._emptyTimeout = void 0;
|
|
1603
|
+
this._taskQueue = new TaskQueue();
|
|
1604
|
+
this._listeners = void 0;
|
|
1605
|
+
}
|
|
1606
|
+
get filters() {
|
|
1607
|
+
return __privateGet(this, _filters);
|
|
1608
|
+
}
|
|
1609
|
+
get formattedDuration() {
|
|
1610
|
+
return formatDuration(this.duration);
|
|
1611
|
+
}
|
|
1612
|
+
get duration() {
|
|
1613
|
+
return this.songs.length ? this.songs.reduce((prev, next) => prev + next.duration, 0) : 0;
|
|
1614
|
+
}
|
|
1615
|
+
get currentTime() {
|
|
1616
|
+
return this.voice.playbackDuration + this.beginTime;
|
|
1617
|
+
}
|
|
1618
|
+
get formattedCurrentTime() {
|
|
1619
|
+
return formatDuration(this.currentTime);
|
|
1620
|
+
}
|
|
1621
|
+
get voiceChannel() {
|
|
1622
|
+
return this.clientMember.voice.channel;
|
|
1623
|
+
}
|
|
1624
|
+
get volume() {
|
|
1625
|
+
return this.voice.volume;
|
|
1626
|
+
}
|
|
1627
|
+
set volume(value) {
|
|
1628
|
+
this.voice.volume = value;
|
|
1629
|
+
}
|
|
1630
|
+
addToQueue(song, position = 0) {
|
|
1631
|
+
if (!song || Array.isArray(song) && !song.length) {
|
|
1632
|
+
throw new DisTubeError("INVALID_TYPE", ["Song", "Array<Song>"], song, "song");
|
|
1633
|
+
}
|
|
1634
|
+
if (typeof position !== "number" || !Number.isInteger(position)) {
|
|
1635
|
+
throw new DisTubeError("INVALID_TYPE", "integer", position, "position");
|
|
1636
|
+
}
|
|
1637
|
+
if (position <= 0) {
|
|
1638
|
+
if (Array.isArray(song))
|
|
1639
|
+
this.songs.push(...song);
|
|
1640
|
+
else
|
|
1641
|
+
this.songs.push(song);
|
|
1642
|
+
} else if (Array.isArray(song)) {
|
|
1643
|
+
this.songs.splice(position, 0, ...song);
|
|
1644
|
+
} else {
|
|
1645
|
+
this.songs.splice(position, 0, song);
|
|
1646
|
+
}
|
|
1647
|
+
if (Array.isArray(song))
|
|
1648
|
+
song.map((s) => delete s.formats);
|
|
1649
|
+
else
|
|
1650
|
+
delete song.formats;
|
|
1651
|
+
return this;
|
|
1652
|
+
}
|
|
1653
|
+
pause() {
|
|
1654
|
+
if (this.paused)
|
|
1655
|
+
throw new DisTubeError("PAUSED");
|
|
1656
|
+
this.playing = false;
|
|
1657
|
+
this.paused = true;
|
|
1658
|
+
this.voice.pause();
|
|
1659
|
+
return this;
|
|
1660
|
+
}
|
|
1661
|
+
resume() {
|
|
1662
|
+
if (this.playing)
|
|
1663
|
+
throw new DisTubeError("RESUMED");
|
|
1664
|
+
this.playing = true;
|
|
1665
|
+
this.paused = false;
|
|
1666
|
+
this.voice.unpause();
|
|
1667
|
+
return this;
|
|
1668
|
+
}
|
|
1669
|
+
setVolume(percent) {
|
|
1670
|
+
this.volume = percent;
|
|
1671
|
+
return this;
|
|
1672
|
+
}
|
|
1673
|
+
async skip() {
|
|
1674
|
+
await this._taskQueue.queuing();
|
|
1675
|
+
try {
|
|
1676
|
+
if (this.songs.length <= 1) {
|
|
1677
|
+
if (this.autoplay)
|
|
1678
|
+
await this.addRelatedSong();
|
|
1679
|
+
else
|
|
1680
|
+
throw new DisTubeError("NO_UP_NEXT");
|
|
1681
|
+
}
|
|
1682
|
+
const song = this.songs[1];
|
|
1683
|
+
this._next = true;
|
|
1684
|
+
this.voice.stop();
|
|
1685
|
+
return song;
|
|
1686
|
+
} finally {
|
|
1687
|
+
this._taskQueue.resolve();
|
|
1688
|
+
}
|
|
1689
|
+
}
|
|
1690
|
+
async previous() {
|
|
1691
|
+
await this._taskQueue.queuing();
|
|
1692
|
+
try {
|
|
1693
|
+
if (!this.options.savePreviousSongs)
|
|
1694
|
+
throw new DisTubeError("DISABLED_OPTION", "savePreviousSongs");
|
|
1695
|
+
if (this.previousSongs?.length === 0 && this.repeatMode !== 2 /* QUEUE */) {
|
|
1696
|
+
throw new DisTubeError("NO_PREVIOUS");
|
|
1697
|
+
}
|
|
1698
|
+
const song = this.repeatMode === 2 ? this.songs[this.songs.length - 1] : this.previousSongs[this.previousSongs.length - 1];
|
|
1699
|
+
this._prev = true;
|
|
1700
|
+
this.voice.stop();
|
|
1701
|
+
return song;
|
|
1702
|
+
} finally {
|
|
1703
|
+
this._taskQueue.resolve();
|
|
1704
|
+
}
|
|
1705
|
+
}
|
|
1706
|
+
async shuffle() {
|
|
1707
|
+
await this._taskQueue.queuing();
|
|
1708
|
+
try {
|
|
1709
|
+
const playing = this.songs.shift();
|
|
1710
|
+
if (playing === void 0)
|
|
1711
|
+
return this;
|
|
1712
|
+
for (let i = this.songs.length - 1; i > 0; i--) {
|
|
1713
|
+
const j = Math.floor(Math.random() * (i + 1));
|
|
1714
|
+
[this.songs[i], this.songs[j]] = [this.songs[j], this.songs[i]];
|
|
1715
|
+
}
|
|
1716
|
+
this.songs.unshift(playing);
|
|
1717
|
+
return this;
|
|
1718
|
+
} finally {
|
|
1719
|
+
this._taskQueue.resolve();
|
|
1720
|
+
}
|
|
1721
|
+
}
|
|
1722
|
+
async jump(position) {
|
|
1723
|
+
await this._taskQueue.queuing();
|
|
1724
|
+
try {
|
|
1725
|
+
if (typeof position !== "number")
|
|
1726
|
+
throw new DisTubeError("INVALID_TYPE", "number", position, "position");
|
|
1727
|
+
if (!position || position > this.songs.length || -position > this.previousSongs.length) {
|
|
1728
|
+
throw new DisTubeError("NO_SONG_POSITION");
|
|
1729
|
+
}
|
|
1730
|
+
let nextSong;
|
|
1731
|
+
if (position > 0) {
|
|
1732
|
+
const nextSongs = this.songs.splice(position - 1);
|
|
1733
|
+
if (this.options.savePreviousSongs) {
|
|
1734
|
+
this.previousSongs.push(...this.songs);
|
|
1735
|
+
} else {
|
|
1736
|
+
this.previousSongs.push(...this.songs.map((s) => ({ id: s.id })));
|
|
1737
|
+
}
|
|
1738
|
+
this.songs = nextSongs;
|
|
1739
|
+
this._next = true;
|
|
1740
|
+
nextSong = nextSongs[1];
|
|
1741
|
+
} else if (!this.options.savePreviousSongs) {
|
|
1742
|
+
throw new DisTubeError("DISABLED_OPTION", "savePreviousSongs");
|
|
1743
|
+
} else {
|
|
1744
|
+
this._prev = true;
|
|
1745
|
+
if (position !== -1)
|
|
1746
|
+
this.songs.unshift(...this.previousSongs.splice(position + 1));
|
|
1747
|
+
nextSong = this.previousSongs[this.previousSongs.length - 1];
|
|
1748
|
+
}
|
|
1749
|
+
this.voice.stop();
|
|
1750
|
+
return nextSong;
|
|
1751
|
+
} finally {
|
|
1752
|
+
this._taskQueue.resolve();
|
|
1753
|
+
}
|
|
1754
|
+
}
|
|
1755
|
+
setRepeatMode(mode) {
|
|
1756
|
+
if (mode !== void 0 && !Object.values(RepeatMode).includes(mode)) {
|
|
1757
|
+
throw new DisTubeError("INVALID_TYPE", ["RepeatMode", "undefined"], mode, "mode");
|
|
1758
|
+
}
|
|
1759
|
+
if (mode === void 0)
|
|
1760
|
+
this.repeatMode = (this.repeatMode + 1) % 3;
|
|
1761
|
+
else if (this.repeatMode === mode)
|
|
1762
|
+
this.repeatMode = 0 /* DISABLED */;
|
|
1763
|
+
else
|
|
1764
|
+
this.repeatMode = mode;
|
|
1765
|
+
return this.repeatMode;
|
|
1766
|
+
}
|
|
1767
|
+
seek(time) {
|
|
1768
|
+
if (typeof time !== "number")
|
|
1769
|
+
throw new DisTubeError("INVALID_TYPE", "number", time, "time");
|
|
1770
|
+
if (isNaN(time) || time < 0)
|
|
1771
|
+
throw new DisTubeError("NUMBER_COMPARE", "time", "bigger or equal to", 0);
|
|
1772
|
+
this.beginTime = time;
|
|
1773
|
+
this.queues.playSong(this);
|
|
1774
|
+
return this;
|
|
1775
|
+
}
|
|
1776
|
+
async addRelatedSong() {
|
|
1777
|
+
if (!this.songs?.[0])
|
|
1778
|
+
throw new DisTubeError("NO_PLAYING");
|
|
1779
|
+
const related = this.songs[0].related.find((v) => !this.previousSongs.map((s) => s.id).includes(v.id));
|
|
1780
|
+
if (!related || !(related instanceof Song))
|
|
1781
|
+
throw new DisTubeError("NO_RELATED");
|
|
1782
|
+
const song = await this.handler.resolve(related, { member: this.clientMember, metadata: related.metadata });
|
|
1783
|
+
if (!(song instanceof Song))
|
|
1784
|
+
throw new DisTubeError("CANNOT_PLAY_RELATED");
|
|
1785
|
+
this.addToQueue(song);
|
|
1786
|
+
return song;
|
|
1787
|
+
}
|
|
1788
|
+
async stop() {
|
|
1789
|
+
await this._taskQueue.queuing();
|
|
1790
|
+
try {
|
|
1791
|
+
this.playing = false;
|
|
1792
|
+
this.paused = false;
|
|
1793
|
+
this.stopped = true;
|
|
1794
|
+
if (this.options.leaveOnStop)
|
|
1795
|
+
this.voice.leave();
|
|
1796
|
+
else
|
|
1797
|
+
this.voice.stop();
|
|
1798
|
+
this.remove();
|
|
1799
|
+
} finally {
|
|
1800
|
+
this._taskQueue.resolve();
|
|
1801
|
+
}
|
|
1802
|
+
}
|
|
1803
|
+
remove() {
|
|
1804
|
+
this.stopped = true;
|
|
1805
|
+
this.songs = [];
|
|
1806
|
+
this.previousSongs = [];
|
|
1807
|
+
if (this._listeners) {
|
|
1808
|
+
for (const event of Object.keys(this._listeners)) {
|
|
1809
|
+
this.voice.removeListener(event, this._listeners[event]);
|
|
1810
|
+
}
|
|
1811
|
+
}
|
|
1812
|
+
this.queues.remove(this.id);
|
|
1813
|
+
this.emit("deleteQueue", this);
|
|
1814
|
+
}
|
|
1815
|
+
toggleAutoplay() {
|
|
1816
|
+
this.autoplay = !this.autoplay;
|
|
1817
|
+
return this.autoplay;
|
|
1818
|
+
}
|
|
1819
|
+
};
|
|
1820
|
+
_filters = new WeakMap();
|
|
1821
|
+
|
|
1822
|
+
// src/struct/Plugin.ts
|
|
1823
|
+
var Plugin = class {
|
|
1824
|
+
constructor() {
|
|
1825
|
+
__publicField(this, "distube");
|
|
1826
|
+
}
|
|
1827
|
+
init(distube) {
|
|
1828
|
+
this.distube = distube;
|
|
1829
|
+
}
|
|
1830
|
+
emit(eventName, ...args) {
|
|
1831
|
+
return this.distube.emit(eventName, ...args);
|
|
1832
|
+
}
|
|
1833
|
+
emitError(error, channel) {
|
|
1834
|
+
this.distube.emitError(error, channel);
|
|
1835
|
+
}
|
|
1836
|
+
get queues() {
|
|
1837
|
+
return this.distube.queues;
|
|
1838
|
+
}
|
|
1839
|
+
get voices() {
|
|
1840
|
+
return this.distube.voices;
|
|
1841
|
+
}
|
|
1842
|
+
get client() {
|
|
1843
|
+
return this.distube.client;
|
|
1844
|
+
}
|
|
1845
|
+
get options() {
|
|
1846
|
+
return this.distube.options;
|
|
1847
|
+
}
|
|
1848
|
+
get handler() {
|
|
1849
|
+
return this.distube.handler;
|
|
1850
|
+
}
|
|
1851
|
+
validate(_string) {
|
|
1852
|
+
return false;
|
|
1853
|
+
}
|
|
1854
|
+
getStreamURL(url) {
|
|
1855
|
+
return url;
|
|
1856
|
+
}
|
|
1857
|
+
getRelatedSongs(_url) {
|
|
1858
|
+
return [];
|
|
1859
|
+
}
|
|
1860
|
+
};
|
|
1861
|
+
|
|
1862
|
+
// src/struct/CustomPlugin.ts
|
|
1863
|
+
var CustomPlugin = class extends Plugin {
|
|
1864
|
+
constructor() {
|
|
1865
|
+
super(...arguments);
|
|
1866
|
+
__publicField(this, "type", "custom" /* CUSTOM */);
|
|
1867
|
+
}
|
|
1868
|
+
};
|
|
1869
|
+
|
|
1870
|
+
// src/struct/ExtractorPlugin.ts
|
|
1871
|
+
var ExtractorPlugin = class extends Plugin {
|
|
1872
|
+
constructor() {
|
|
1873
|
+
super(...arguments);
|
|
1874
|
+
__publicField(this, "type", "extractor" /* EXTRACTOR */);
|
|
1875
|
+
}
|
|
1876
|
+
};
|
|
1877
|
+
|
|
1878
|
+
// src/util.ts
|
|
1879
|
+
var import_url = require("url");
|
|
1880
|
+
var import_discord2 = require("discord.js");
|
|
1881
|
+
var formatInt = /* @__PURE__ */ __name((int) => int < 10 ? `0${int}` : int, "formatInt");
|
|
1882
|
+
function formatDuration(sec) {
|
|
1883
|
+
if (!sec || !Number(sec))
|
|
1884
|
+
return "00:00";
|
|
1885
|
+
const seconds = Math.round(sec % 60);
|
|
1886
|
+
const minutes = Math.floor(sec % 3600 / 60);
|
|
1887
|
+
const hours = Math.floor(sec / 3600);
|
|
1888
|
+
if (hours > 0)
|
|
1889
|
+
return `${formatInt(hours)}:${formatInt(minutes)}:${formatInt(seconds)}`;
|
|
1890
|
+
if (minutes > 0)
|
|
1891
|
+
return `${formatInt(minutes)}:${formatInt(seconds)}`;
|
|
1892
|
+
return `00:${formatInt(seconds)}`;
|
|
1893
|
+
}
|
|
1894
|
+
function toSecond(input) {
|
|
1895
|
+
if (!input)
|
|
1896
|
+
return 0;
|
|
1897
|
+
if (typeof input !== "string")
|
|
1898
|
+
return Number(input) || 0;
|
|
1899
|
+
if (input.match(/:/g)) {
|
|
1900
|
+
const time = input.split(":").reverse();
|
|
1901
|
+
let s = 0;
|
|
1902
|
+
for (let i = 0; i < 3; i++)
|
|
1903
|
+
if (time[i])
|
|
1904
|
+
s += Number(time[i].replace(/[^\d.]+/g, "")) * Math.pow(60, i);
|
|
1905
|
+
if (time.length > 3)
|
|
1906
|
+
s += Number(time[3].replace(/[^\d.]+/g, "")) * 24 * 60 * 60;
|
|
1907
|
+
return s;
|
|
1908
|
+
} else {
|
|
1909
|
+
return Number(input.replace(/[^\d.]+/g, "")) || 0;
|
|
1910
|
+
}
|
|
1911
|
+
}
|
|
1912
|
+
function parseNumber(input) {
|
|
1913
|
+
if (typeof input === "string")
|
|
1914
|
+
return Number(input.replace(/[^\d.]+/g, "")) || 0;
|
|
1915
|
+
return Number(input) || 0;
|
|
1916
|
+
}
|
|
1917
|
+
function isURL(input) {
|
|
1918
|
+
if (typeof input !== "string" || input.includes(" "))
|
|
1919
|
+
return false;
|
|
1920
|
+
try {
|
|
1921
|
+
const url = new import_url.URL(input);
|
|
1922
|
+
if (!["https:", "http:"].includes(url.protocol) || !url.host)
|
|
1923
|
+
return false;
|
|
1924
|
+
} catch {
|
|
1925
|
+
return false;
|
|
1926
|
+
}
|
|
1927
|
+
return true;
|
|
1928
|
+
}
|
|
1929
|
+
function checkIntents(options) {
|
|
1930
|
+
const intents = new import_discord2.IntentsBitField(options.intents);
|
|
1931
|
+
if (!intents.has(import_discord2.GatewayIntentBits.GuildVoiceStates))
|
|
1932
|
+
throw new DisTubeError("MISSING_INTENTS", "GuildVoiceStates");
|
|
1933
|
+
}
|
|
1934
|
+
function isVoiceChannelEmpty(voiceState) {
|
|
1935
|
+
const voiceChannel = voiceState.guild?.me?.voice?.channel;
|
|
1936
|
+
if (!voiceChannel)
|
|
1937
|
+
return false;
|
|
1938
|
+
const members = voiceChannel.members.filter((m) => !m.user.bot);
|
|
1939
|
+
return !members.size;
|
|
1940
|
+
}
|
|
1941
|
+
function isSnowflake(id) {
|
|
1942
|
+
try {
|
|
1943
|
+
return import_discord2.SnowflakeUtil.deconstruct(id).timestamp > import_discord2.SnowflakeUtil.epoch;
|
|
1944
|
+
} catch {
|
|
1945
|
+
return false;
|
|
1946
|
+
}
|
|
1947
|
+
}
|
|
1948
|
+
function isMemberInstance(member) {
|
|
1949
|
+
return !!member && isSnowflake(member.id) && isSnowflake(member.guild?.id) && isSnowflake(member.user?.id) && member.id === member.user.id;
|
|
1950
|
+
}
|
|
1951
|
+
function isTextChannelInstance(channel) {
|
|
1952
|
+
return !!channel && isSnowflake(channel.id) && isSnowflake(channel.guildId) && typeof channel.name === "string" && import_discord2.Constants.TextBasedChannelTypes.includes(channel.type);
|
|
1953
|
+
}
|
|
1954
|
+
function isMessageInstance(message) {
|
|
1955
|
+
return !!message && isSnowflake(message.id) && isSnowflake(message.guildId) && isMemberInstance(message.member) && isTextChannelInstance(message.channel) && import_discord2.Constants.NonSystemMessageTypes.includes(message.type) && message.member.id === message.author?.id;
|
|
1956
|
+
}
|
|
1957
|
+
function isSupportedVoiceChannel(channel) {
|
|
1958
|
+
return !!channel && isSnowflake(channel.id) && isSnowflake(channel.guildId) && import_discord2.Constants.VoiceBasedChannelTypes.includes(channel.type);
|
|
1959
|
+
}
|
|
1960
|
+
function isGuildInstance(guild) {
|
|
1961
|
+
return !!guild && isSnowflake(guild.id) && isSnowflake(guild.ownerId) && typeof guild.name === "string";
|
|
1962
|
+
}
|
|
1963
|
+
function resolveGuildId(resolvable) {
|
|
1964
|
+
let guildId;
|
|
1965
|
+
if (typeof resolvable === "string") {
|
|
1966
|
+
guildId = resolvable;
|
|
1967
|
+
} else if (isObject(resolvable)) {
|
|
1968
|
+
if ("guildId" in resolvable && resolvable.guildId) {
|
|
1969
|
+
guildId = resolvable.guildId;
|
|
1970
|
+
} else if (resolvable instanceof Queue || resolvable instanceof DisTubeVoice || isGuildInstance(resolvable)) {
|
|
1971
|
+
guildId = resolvable.id;
|
|
1972
|
+
} else if ("guild" in resolvable && isGuildInstance(resolvable.guild)) {
|
|
1973
|
+
guildId = resolvable.guild.id;
|
|
1974
|
+
}
|
|
1975
|
+
}
|
|
1976
|
+
if (!isSnowflake(guildId))
|
|
1977
|
+
throw new DisTubeError("INVALID_TYPE", "GuildIdResolvable", resolvable);
|
|
1978
|
+
return guildId;
|
|
1979
|
+
}
|
|
1980
|
+
function isClientInstance(client) {
|
|
1981
|
+
return !!client && typeof client.login === "function";
|
|
1982
|
+
}
|
|
1983
|
+
function checkInvalidKey(target, source, sourceName) {
|
|
1984
|
+
if (!isObject(target))
|
|
1985
|
+
throw new DisTubeError("INVALID_TYPE", "object", target, sourceName);
|
|
1986
|
+
const sourceKeys = Array.isArray(source) ? source : Object.keys(source);
|
|
1987
|
+
const invalidKey = Object.keys(target).find((key) => !sourceKeys.includes(key));
|
|
1988
|
+
if (invalidKey)
|
|
1989
|
+
throw new DisTubeError("INVALID_KEY", sourceName, invalidKey);
|
|
1990
|
+
}
|
|
1991
|
+
async function waitEvent(target, status, maxTime) {
|
|
1992
|
+
let cleanup = /* @__PURE__ */ __name(() => {
|
|
1993
|
+
}, "cleanup");
|
|
1994
|
+
try {
|
|
1995
|
+
await new Promise((resolve, reject) => {
|
|
1996
|
+
const timeout = setTimeout(() => reject(new Error(`Didn't trigger ${status} within ${maxTime}ms`)), maxTime);
|
|
1997
|
+
target.once(status, resolve);
|
|
1998
|
+
target.once("error", reject);
|
|
1999
|
+
cleanup = /* @__PURE__ */ __name(() => {
|
|
2000
|
+
clearTimeout(timeout);
|
|
2001
|
+
target.off(status, resolve);
|
|
2002
|
+
target.off("error", reject);
|
|
2003
|
+
}, "cleanup");
|
|
2004
|
+
if (target?.state?.status === status)
|
|
2005
|
+
resolve(0);
|
|
2006
|
+
});
|
|
2007
|
+
return target;
|
|
2008
|
+
} finally {
|
|
2009
|
+
cleanup();
|
|
2010
|
+
}
|
|
2011
|
+
}
|
|
2012
|
+
async function entersState(target, status, maxTime) {
|
|
2013
|
+
if (target.state.status === status)
|
|
2014
|
+
return target;
|
|
2015
|
+
return waitEvent(target, status, maxTime);
|
|
2016
|
+
}
|
|
2017
|
+
function isObject(obj) {
|
|
2018
|
+
return typeof obj === "object" && obj !== null && !Array.isArray(obj);
|
|
2019
|
+
}
|
|
2020
|
+
function isRecord(obj) {
|
|
2021
|
+
return isObject(obj);
|
|
2022
|
+
}
|
|
2023
|
+
|
|
2024
|
+
// src/plugin/http.ts
|
|
2025
|
+
var import_http = __toESM(require("http"));
|
|
2026
|
+
var HTTPPlugin = class extends ExtractorPlugin {
|
|
2027
|
+
async validate(url) {
|
|
2028
|
+
return validateAudioURL(import_http.default, "http:", url);
|
|
2029
|
+
}
|
|
2030
|
+
async resolve(url, options = {}) {
|
|
2031
|
+
return resolveHttpSong(url, { ...options, source: "http" });
|
|
2032
|
+
}
|
|
2033
|
+
};
|
|
2034
|
+
|
|
2035
|
+
// src/plugin/https.ts
|
|
2036
|
+
var import_https = __toESM(require("https"));
|
|
2037
|
+
var import_url2 = require("url");
|
|
2038
|
+
var getResponseHeaders = /* @__PURE__ */ __name(async (httpModule, url) => new Promise((resolve, reject) => {
|
|
2039
|
+
httpModule.get(url).on("response", (res) => {
|
|
2040
|
+
resolve(res.headers);
|
|
2041
|
+
}).on("error", reject);
|
|
2042
|
+
}), "getResponseHeaders");
|
|
2043
|
+
var validateAudioURL = /* @__PURE__ */ __name(async (httpModule, protocol, url) => {
|
|
2044
|
+
if (new import_url2.URL(url).protocol.toLowerCase() !== protocol) {
|
|
2045
|
+
return false;
|
|
2046
|
+
}
|
|
2047
|
+
const headers = await getResponseHeaders(httpModule, url), type = headers["content-type"];
|
|
2048
|
+
if (type?.startsWith("audio")) {
|
|
2049
|
+
return true;
|
|
2050
|
+
}
|
|
2051
|
+
return false;
|
|
2052
|
+
}, "validateAudioURL");
|
|
2053
|
+
var resolveHttpSong = /* @__PURE__ */ __name(async (url, options) => {
|
|
2054
|
+
url = url.replace(/\/+$/, "");
|
|
2055
|
+
return new Song({
|
|
2056
|
+
name: url.substring(url.lastIndexOf("/") + 1).replace(/((\?|#).*)?$/, "") || url,
|
|
2057
|
+
url
|
|
2058
|
+
}, options);
|
|
2059
|
+
}, "resolveHttpSong");
|
|
2060
|
+
var HTTPSPlugin = class extends ExtractorPlugin {
|
|
2061
|
+
async validate(url) {
|
|
2062
|
+
return validateAudioURL(import_https.default, "https:", url);
|
|
2063
|
+
}
|
|
2064
|
+
async resolve(url, options = {}) {
|
|
2065
|
+
return resolveHttpSong(url, { ...options, source: "https" });
|
|
2066
|
+
}
|
|
2067
|
+
};
|
|
2068
|
+
|
|
2069
|
+
// src/DisTube.ts
|
|
2070
|
+
var import_ytsr = __toESM(require("@distube/ytsr"));
|
|
2071
|
+
var import_tiny_typed_emitter2 = require("tiny-typed-emitter");
|
|
2072
|
+
var { version } = require_package();
|
|
2073
|
+
var DisTube = class extends import_tiny_typed_emitter2.TypedEmitter {
|
|
2074
|
+
constructor(client, otp = {}) {
|
|
2075
|
+
super();
|
|
2076
|
+
__publicField(this, "handler");
|
|
2077
|
+
__publicField(this, "options");
|
|
2078
|
+
__publicField(this, "client");
|
|
2079
|
+
__publicField(this, "queues");
|
|
2080
|
+
__publicField(this, "voices");
|
|
2081
|
+
__publicField(this, "extractorPlugins");
|
|
2082
|
+
__publicField(this, "customPlugins");
|
|
2083
|
+
__publicField(this, "filters");
|
|
2084
|
+
this.setMaxListeners(1);
|
|
2085
|
+
if (!isClientInstance(client))
|
|
2086
|
+
throw new DisTubeError("INVALID_TYPE", "Discord.Client", client, "client");
|
|
2087
|
+
this.client = client;
|
|
2088
|
+
checkIntents(client.options);
|
|
2089
|
+
this.options = new Options(otp);
|
|
2090
|
+
this.voices = new DisTubeVoiceManager(this);
|
|
2091
|
+
this.handler = new DisTubeHandler(this);
|
|
2092
|
+
this.queues = new QueueManager(this);
|
|
2093
|
+
this.filters = { ...defaultFilters, ...this.options.customFilters };
|
|
2094
|
+
this.options.plugins.push(new HTTPPlugin(), new HTTPSPlugin());
|
|
2095
|
+
this.options.plugins.map((p) => p.init(this));
|
|
2096
|
+
this.extractorPlugins = this.options.plugins.filter((p) => p.type === "extractor");
|
|
2097
|
+
this.customPlugins = this.options.plugins.filter((p) => p.type === "custom");
|
|
2098
|
+
}
|
|
2099
|
+
static get version() {
|
|
2100
|
+
return version;
|
|
2101
|
+
}
|
|
2102
|
+
get version() {
|
|
2103
|
+
return version;
|
|
2104
|
+
}
|
|
2105
|
+
async play(voiceChannel, song, options = {}) {
|
|
2106
|
+
if (!isSupportedVoiceChannel(voiceChannel)) {
|
|
2107
|
+
throw new DisTubeError("INVALID_TYPE", "BaseGuildVoiceChannel", voiceChannel, "voiceChannel");
|
|
2108
|
+
}
|
|
2109
|
+
if (!isObject(options))
|
|
2110
|
+
throw new DisTubeError("INVALID_TYPE", "object", options, "options");
|
|
2111
|
+
const { textChannel, member, skip, message, metadata } = {
|
|
2112
|
+
member: voiceChannel.guild.me ?? void 0,
|
|
2113
|
+
textChannel: options?.message?.channel,
|
|
2114
|
+
skip: false,
|
|
2115
|
+
...options
|
|
2116
|
+
};
|
|
2117
|
+
const position = Number(options.position) || (skip ? 1 : 0);
|
|
2118
|
+
if (message && !isMessageInstance(message)) {
|
|
2119
|
+
throw new DisTubeError("INVALID_TYPE", ["Discord.Message", "a falsy value"], message, "options.message");
|
|
2120
|
+
}
|
|
2121
|
+
if (textChannel && !isTextChannelInstance(textChannel)) {
|
|
2122
|
+
throw new DisTubeError("INVALID_TYPE", "Discord.GuildTextBasedChannel", textChannel, "options.textChannel");
|
|
2123
|
+
}
|
|
2124
|
+
if (member && !isMemberInstance(member)) {
|
|
2125
|
+
throw new DisTubeError("INVALID_TYPE", "Discord.GuildMember", member, "options.member");
|
|
2126
|
+
}
|
|
2127
|
+
const queue = this.getQueue(voiceChannel);
|
|
2128
|
+
const queuing = !!queue && !queue._taskQueue.hasResolveTask;
|
|
2129
|
+
if (queuing)
|
|
2130
|
+
await queue?._taskQueue.queuing(true);
|
|
2131
|
+
try {
|
|
2132
|
+
if (typeof song === "string") {
|
|
2133
|
+
for (const plugin of this.customPlugins) {
|
|
2134
|
+
if (await plugin.validate(song)) {
|
|
2135
|
+
await plugin.play(voiceChannel, song, options);
|
|
2136
|
+
return;
|
|
2137
|
+
}
|
|
2138
|
+
}
|
|
2139
|
+
}
|
|
2140
|
+
if (typeof song === "string" && !isURL(song)) {
|
|
2141
|
+
if (!message) {
|
|
2142
|
+
song = (await this.search(song, { limit: 1 }))[0];
|
|
2143
|
+
} else {
|
|
2144
|
+
const result = await this.handler.searchSong(message, song);
|
|
2145
|
+
if (!result)
|
|
2146
|
+
return;
|
|
2147
|
+
song = result;
|
|
2148
|
+
}
|
|
2149
|
+
}
|
|
2150
|
+
song = await this.handler.resolve(song, { member, metadata });
|
|
2151
|
+
if (song instanceof Playlist) {
|
|
2152
|
+
await this.handler.playPlaylist(voiceChannel, song, { textChannel, skip, position });
|
|
2153
|
+
} else {
|
|
2154
|
+
await this.handler.playSong(voiceChannel, song, { textChannel, skip, position });
|
|
2155
|
+
}
|
|
2156
|
+
} catch (e) {
|
|
2157
|
+
if (!(e instanceof DisTubeError)) {
|
|
2158
|
+
try {
|
|
2159
|
+
e.name = "PlayError";
|
|
2160
|
+
e.message = `${song?.url || song}
|
|
2161
|
+
${e.message}`;
|
|
2162
|
+
} catch {
|
|
2163
|
+
}
|
|
2164
|
+
}
|
|
2165
|
+
this.emitError(e, textChannel);
|
|
2166
|
+
} finally {
|
|
2167
|
+
if (queuing)
|
|
2168
|
+
queue?._taskQueue.resolve();
|
|
2169
|
+
}
|
|
2170
|
+
}
|
|
2171
|
+
async createCustomPlaylist(songs, options = {}) {
|
|
2172
|
+
const { member, properties, parallel, metadata } = { parallel: true, ...options };
|
|
2173
|
+
if (!Array.isArray(songs))
|
|
2174
|
+
throw new DisTubeError("INVALID_TYPE", "Array", songs, "songs");
|
|
2175
|
+
if (!songs.length)
|
|
2176
|
+
throw new DisTubeError("EMPTY_ARRAY", "songs");
|
|
2177
|
+
const filteredSongs = songs.filter((song) => song instanceof Song || song instanceof SearchResult && song.type === "video" || isURL(song));
|
|
2178
|
+
if (!filteredSongs.length)
|
|
2179
|
+
throw new DisTubeError("NO_VALID_SONG");
|
|
2180
|
+
if (member && !isMemberInstance(member)) {
|
|
2181
|
+
throw new DisTubeError("INVALID_TYPE", "Discord.Member", member, "options.member");
|
|
2182
|
+
}
|
|
2183
|
+
if (!filteredSongs.length)
|
|
2184
|
+
throw new DisTubeError("NO_VALID_SONG");
|
|
2185
|
+
let resolvedSongs;
|
|
2186
|
+
if (parallel) {
|
|
2187
|
+
const promises = filteredSongs.map((song) => this.handler.resolve(song, { member, metadata }).catch(() => void 0));
|
|
2188
|
+
resolvedSongs = (await Promise.all(promises)).filter((s) => !!s);
|
|
2189
|
+
} else {
|
|
2190
|
+
const resolved = [];
|
|
2191
|
+
for (const song of filteredSongs) {
|
|
2192
|
+
resolved.push(await this.handler.resolve(song, { member, metadata }).catch(() => void 0));
|
|
2193
|
+
}
|
|
2194
|
+
resolvedSongs = resolved.filter((s) => !!s);
|
|
2195
|
+
}
|
|
2196
|
+
return new Playlist(resolvedSongs, { member, properties, metadata });
|
|
2197
|
+
}
|
|
2198
|
+
async search(string, options = {}) {
|
|
2199
|
+
const opts = { type: "video", limit: 10, safeSearch: false, ...options };
|
|
2200
|
+
if (typeof opts.type !== "string" || !["video", "playlist"].includes(opts.type)) {
|
|
2201
|
+
throw new DisTubeError("INVALID_TYPE", ["video", "playlist"], opts.type, "options.type");
|
|
2202
|
+
}
|
|
2203
|
+
if (typeof opts.limit !== "number")
|
|
2204
|
+
throw new DisTubeError("INVALID_TYPE", "number", opts.limit, "options.limit");
|
|
2205
|
+
if (opts.limit < 1)
|
|
2206
|
+
throw new DisTubeError("NUMBER_COMPARE", "option.limit", "bigger or equal to", 1);
|
|
2207
|
+
if (typeof opts.safeSearch !== "boolean") {
|
|
2208
|
+
throw new DisTubeError("INVALID_TYPE", "boolean", opts.safeSearch, "options.safeSearch");
|
|
2209
|
+
}
|
|
2210
|
+
try {
|
|
2211
|
+
const search = await (0, import_ytsr.default)(string, opts);
|
|
2212
|
+
const results = search.items.map((i) => new SearchResult(i));
|
|
2213
|
+
if (results.length === 0)
|
|
2214
|
+
throw new DisTubeError("NO_RESULT");
|
|
2215
|
+
return results;
|
|
2216
|
+
} catch (e) {
|
|
2217
|
+
if (options.retried)
|
|
2218
|
+
throw e;
|
|
2219
|
+
options.retried = true;
|
|
2220
|
+
return this.search(string, options);
|
|
2221
|
+
}
|
|
2222
|
+
}
|
|
2223
|
+
getQueue(guild) {
|
|
2224
|
+
return this.queues.get(guild);
|
|
2225
|
+
}
|
|
2226
|
+
pause(guild) {
|
|
2227
|
+
const q = this.getQueue(guild);
|
|
2228
|
+
if (!q)
|
|
2229
|
+
throw new DisTubeError("NO_QUEUE");
|
|
2230
|
+
return q.pause();
|
|
2231
|
+
}
|
|
2232
|
+
resume(guild) {
|
|
2233
|
+
const q = this.getQueue(guild);
|
|
2234
|
+
if (!q)
|
|
2235
|
+
throw new DisTubeError("NO_QUEUE");
|
|
2236
|
+
return q.resume();
|
|
2237
|
+
}
|
|
2238
|
+
stop(guild) {
|
|
2239
|
+
const q = this.getQueue(guild);
|
|
2240
|
+
if (!q)
|
|
2241
|
+
throw new DisTubeError("NO_QUEUE");
|
|
2242
|
+
return q.stop();
|
|
2243
|
+
}
|
|
2244
|
+
setVolume(guild, percent) {
|
|
2245
|
+
const q = this.getQueue(guild);
|
|
2246
|
+
if (!q)
|
|
2247
|
+
throw new DisTubeError("NO_QUEUE");
|
|
2248
|
+
return q.setVolume(percent);
|
|
2249
|
+
}
|
|
2250
|
+
skip(guild) {
|
|
2251
|
+
const q = this.getQueue(guild);
|
|
2252
|
+
if (!q)
|
|
2253
|
+
throw new DisTubeError("NO_QUEUE");
|
|
2254
|
+
return q.skip();
|
|
2255
|
+
}
|
|
2256
|
+
previous(guild) {
|
|
2257
|
+
const q = this.getQueue(guild);
|
|
2258
|
+
if (!q)
|
|
2259
|
+
throw new DisTubeError("NO_QUEUE");
|
|
2260
|
+
return q.previous();
|
|
2261
|
+
}
|
|
2262
|
+
shuffle(guild) {
|
|
2263
|
+
const q = this.getQueue(guild);
|
|
2264
|
+
if (!q)
|
|
2265
|
+
throw new DisTubeError("NO_QUEUE");
|
|
2266
|
+
return q.shuffle();
|
|
2267
|
+
}
|
|
2268
|
+
jump(guild, num) {
|
|
2269
|
+
const q = this.getQueue(guild);
|
|
2270
|
+
if (!q)
|
|
2271
|
+
throw new DisTubeError("NO_QUEUE");
|
|
2272
|
+
return q.jump(num);
|
|
2273
|
+
}
|
|
2274
|
+
setRepeatMode(guild, mode) {
|
|
2275
|
+
const q = this.getQueue(guild);
|
|
2276
|
+
if (!q)
|
|
2277
|
+
throw new DisTubeError("NO_QUEUE");
|
|
2278
|
+
return q.setRepeatMode(mode);
|
|
2279
|
+
}
|
|
2280
|
+
toggleAutoplay(guild) {
|
|
2281
|
+
const q = this.getQueue(guild);
|
|
2282
|
+
if (!q)
|
|
2283
|
+
throw new DisTubeError("NO_QUEUE");
|
|
2284
|
+
q.autoplay = !q.autoplay;
|
|
2285
|
+
return q.autoplay;
|
|
2286
|
+
}
|
|
2287
|
+
addRelatedSong(guild) {
|
|
2288
|
+
const q = this.getQueue(guild);
|
|
2289
|
+
if (!q)
|
|
2290
|
+
throw new DisTubeError("NO_QUEUE");
|
|
2291
|
+
return q.addRelatedSong();
|
|
2292
|
+
}
|
|
2293
|
+
seek(guild, time) {
|
|
2294
|
+
const q = this.getQueue(guild);
|
|
2295
|
+
if (!q)
|
|
2296
|
+
throw new DisTubeError("NO_QUEUE");
|
|
2297
|
+
return q.seek(time);
|
|
2298
|
+
}
|
|
2299
|
+
emitError(error, channel) {
|
|
2300
|
+
if (this.listeners("error").length) {
|
|
2301
|
+
this.emit("error", channel, error);
|
|
2302
|
+
} else {
|
|
2303
|
+
console.error(error);
|
|
2304
|
+
console.warn("Unhandled 'error' event.");
|
|
2305
|
+
console.warn("See: https://distube.js.org/#/docs/DisTube/stable/class/DisTube?scrollTo=e-error and https://nodejs.org/api/events.html#events_error_events");
|
|
2306
|
+
}
|
|
2307
|
+
}
|
|
2308
|
+
};
|
|
2309
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
2310
|
+
0 && (module.exports = {
|
|
2311
|
+
BaseManager,
|
|
2312
|
+
CustomPlugin,
|
|
2313
|
+
DisTube,
|
|
2314
|
+
DisTubeBase,
|
|
2315
|
+
DisTubeError,
|
|
2316
|
+
DisTubeHandler,
|
|
2317
|
+
DisTubeStream,
|
|
2318
|
+
DisTubeVoice,
|
|
2319
|
+
DisTubeVoiceManager,
|
|
2320
|
+
ExtractorPlugin,
|
|
2321
|
+
FilterManager,
|
|
2322
|
+
GuildIdManager,
|
|
2323
|
+
HTTPPlugin,
|
|
2324
|
+
HTTPSPlugin,
|
|
2325
|
+
Options,
|
|
2326
|
+
Playlist,
|
|
2327
|
+
Plugin,
|
|
2328
|
+
PluginType,
|
|
2329
|
+
Queue,
|
|
2330
|
+
QueueManager,
|
|
2331
|
+
RepeatMode,
|
|
2332
|
+
SearchResult,
|
|
2333
|
+
SearchResultType,
|
|
2334
|
+
Song,
|
|
2335
|
+
TaskQueue,
|
|
2336
|
+
checkIntents,
|
|
2337
|
+
checkInvalidKey,
|
|
2338
|
+
chooseBestVideoFormat,
|
|
2339
|
+
defaultFilters,
|
|
2340
|
+
defaultOptions,
|
|
2341
|
+
entersState,
|
|
2342
|
+
formatDuration,
|
|
2343
|
+
getResponseHeaders,
|
|
2344
|
+
isClientInstance,
|
|
2345
|
+
isGuildInstance,
|
|
2346
|
+
isMemberInstance,
|
|
2347
|
+
isMessageInstance,
|
|
2348
|
+
isObject,
|
|
2349
|
+
isRecord,
|
|
2350
|
+
isSnowflake,
|
|
2351
|
+
isSupportedVoiceChannel,
|
|
2352
|
+
isTextChannelInstance,
|
|
2353
|
+
isURL,
|
|
2354
|
+
isVoiceChannelEmpty,
|
|
2355
|
+
parseNumber,
|
|
2356
|
+
resolveGuildId,
|
|
2357
|
+
resolveHttpSong,
|
|
2358
|
+
toSecond,
|
|
2359
|
+
validateAudioURL,
|
|
2360
|
+
version
|
|
2361
|
+
});
|
|
24
2362
|
//# sourceMappingURL=index.js.map
|