distube 3.3.0 → 3.3.1-1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/DisTube.d.ts +4 -4
- package/dist/DisTube.d.ts.map +1 -1
- package/dist/DisTube.js +23 -22
- package/dist/DisTube.js.map +1 -1
- package/dist/constant.d.ts +0 -1
- package/dist/constant.d.ts.map +1 -1
- package/dist/constant.js +0 -1
- package/dist/constant.js.map +1 -1
- package/dist/core/DisTubeHandler.d.ts +3 -3
- package/dist/core/DisTubeHandler.d.ts.map +1 -1
- package/dist/core/DisTubeHandler.js +12 -12
- package/dist/core/DisTubeHandler.js.map +1 -1
- package/dist/core/DisTubeOptions.d.ts +1 -1
- package/dist/core/DisTubeOptions.d.ts.map +1 -1
- package/dist/core/DisTubeOptions.js +3 -4
- package/dist/core/DisTubeOptions.js.map +1 -1
- package/dist/core/DisTubeStream.d.ts +1 -1
- package/dist/core/DisTubeStream.d.ts.map +1 -1
- package/dist/core/DisTubeStream.js.map +1 -1
- package/dist/struct/CustomPlugin.d.ts +32 -26
- package/dist/struct/CustomPlugin.d.ts.map +1 -1
- package/dist/struct/CustomPlugin.js +32 -24
- package/dist/struct/CustomPlugin.js.map +1 -1
- package/dist/struct/DisTubeError.d.ts +1 -1
- package/dist/struct/DisTubeError.d.ts.map +1 -1
- package/dist/struct/DisTubeError.js +1 -1
- package/dist/struct/DisTubeError.js.map +1 -1
- package/dist/struct/ExtractorPlugin.d.ts +21 -15
- package/dist/struct/ExtractorPlugin.d.ts.map +1 -1
- package/dist/struct/ExtractorPlugin.js +21 -12
- package/dist/struct/ExtractorPlugin.js.map +1 -1
- package/dist/struct/Playlist.d.ts +15 -12
- package/dist/struct/Playlist.d.ts.map +1 -1
- package/dist/struct/Playlist.js +50 -39
- package/dist/struct/Playlist.js.map +1 -1
- package/dist/struct/Plugin.d.ts +5 -11
- package/dist/struct/Plugin.d.ts.map +1 -1
- package/dist/struct/Plugin.js +4 -12
- package/dist/struct/Plugin.js.map +1 -1
- package/dist/struct/Song.d.ts +15 -18
- package/dist/struct/Song.d.ts.map +1 -1
- package/dist/struct/Song.js +46 -38
- package/dist/struct/Song.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/type.d.ts +1 -2
- package/dist/type.d.ts.map +1 -1
- package/dist/type.js.map +1 -1
- package/dist/util.d.ts +2 -0
- package/dist/util.d.ts.map +1 -1
- package/dist/util.js +11 -4
- package/dist/util.js.map +1 -1
- package/package.json +1 -1
|
@@ -8,6 +8,7 @@ const ytdl_core_1 = __importDefault(require("@distube/ytdl-core"));
|
|
|
8
8
|
const ytpl_1 = __importDefault(require("@distube/ytpl"));
|
|
9
9
|
const _1 = require(".");
|
|
10
10
|
const __1 = require("..");
|
|
11
|
+
const util_1 = require("../util");
|
|
11
12
|
/**
|
|
12
13
|
* DisTube's Handler
|
|
13
14
|
* @extends DisTubeBase
|
|
@@ -16,7 +17,6 @@ const __1 = require("..");
|
|
|
16
17
|
class DisTubeHandler extends _1.DisTubeBase {
|
|
17
18
|
constructor(distube) {
|
|
18
19
|
super(distube);
|
|
19
|
-
this.ytdlOptions = this.options.ytdlOptions;
|
|
20
20
|
if (this.options.youtubeCookie) {
|
|
21
21
|
const requestOptions = {
|
|
22
22
|
headers: {
|
|
@@ -61,6 +61,9 @@ class DisTubeHandler extends _1.DisTubeBase {
|
|
|
61
61
|
});
|
|
62
62
|
}
|
|
63
63
|
}
|
|
64
|
+
get ytdlOptions() {
|
|
65
|
+
return this.options.ytdlOptions;
|
|
66
|
+
}
|
|
64
67
|
/**
|
|
65
68
|
* Create a new guild queue
|
|
66
69
|
* @param {Discord.Message|Discord.VoiceChannel|Discord.StageChannel} message A user message | a voice channel
|
|
@@ -105,13 +108,11 @@ class DisTubeHandler extends _1.DisTubeBase {
|
|
|
105
108
|
* @returns {Promise<Song|Playlist|null>} Resolved
|
|
106
109
|
*/
|
|
107
110
|
async resolveSong(song, options = {}) {
|
|
108
|
-
if (!song)
|
|
109
|
-
return null;
|
|
110
111
|
if (song instanceof __1.Song || song instanceof __1.Playlist) {
|
|
111
|
-
if (options
|
|
112
|
-
song.
|
|
113
|
-
if (options
|
|
114
|
-
song.
|
|
112
|
+
if ("metadata" in options)
|
|
113
|
+
song.metadata = options.metadata;
|
|
114
|
+
if ("member" in options)
|
|
115
|
+
song.member = options.member;
|
|
115
116
|
return song;
|
|
116
117
|
}
|
|
117
118
|
if (song instanceof __1.SearchResult) {
|
|
@@ -119,7 +120,7 @@ class DisTubeHandler extends _1.DisTubeBase {
|
|
|
119
120
|
return new __1.Song(song, options);
|
|
120
121
|
return this.resolvePlaylist(song.url, options);
|
|
121
122
|
}
|
|
122
|
-
if (
|
|
123
|
+
if ((0, util_1.isObject)(song))
|
|
123
124
|
return new __1.Song(song, options);
|
|
124
125
|
if (ytdl_core_1.default.validateURL(song))
|
|
125
126
|
return new __1.Song(await this.getYouTubeInfo(song), options);
|
|
@@ -130,7 +131,7 @@ class DisTubeHandler extends _1.DisTubeBase {
|
|
|
130
131
|
}
|
|
131
132
|
throw new __1.DisTubeError("NOT_SUPPORTED_URL");
|
|
132
133
|
}
|
|
133
|
-
throw new __1.DisTubeError("CANNOT_RESOLVE_SONG",
|
|
134
|
+
throw new __1.DisTubeError("CANNOT_RESOLVE_SONG", song);
|
|
134
135
|
}
|
|
135
136
|
/**
|
|
136
137
|
* Resolve Song[] or url to a Playlist
|
|
@@ -142,7 +143,7 @@ class DisTubeHandler extends _1.DisTubeBase {
|
|
|
142
143
|
* @returns {Promise<Playlist>}
|
|
143
144
|
*/
|
|
144
145
|
async resolvePlaylist(playlist, options = {}) {
|
|
145
|
-
const { member, source, metadata } =
|
|
146
|
+
const { member, source, metadata } = { source: "youtube", ...options };
|
|
146
147
|
if (playlist instanceof __1.Playlist) {
|
|
147
148
|
if (metadata)
|
|
148
149
|
playlist._patchMetadata(metadata);
|
|
@@ -182,7 +183,7 @@ class DisTubeHandler extends _1.DisTubeBase {
|
|
|
182
183
|
});
|
|
183
184
|
}
|
|
184
185
|
async handlePlaylist(voice, playlist, options = {}) {
|
|
185
|
-
const { textChannel, skip, unshift } =
|
|
186
|
+
const { textChannel, skip, unshift } = { skip: false, unshift: false, ...options };
|
|
186
187
|
let position = Number(options.position);
|
|
187
188
|
if (!position) {
|
|
188
189
|
if (skip && position !== 0)
|
|
@@ -330,7 +331,6 @@ class DisTubeHandler extends _1.DisTubeBase {
|
|
|
330
331
|
const ffmpegArgs = queue.filters?.length ? ["-af", filterArgs.join(",")] : undefined;
|
|
331
332
|
const seek = duration ? queue.beginTime : undefined;
|
|
332
333
|
const streamOptions = { ffmpegArgs, seek, isLive };
|
|
333
|
-
Object.assign(streamOptions, this.ytdlOptions);
|
|
334
334
|
if (source === "youtube")
|
|
335
335
|
return _1.DisTubeStream.YouTube(formats, streamOptions);
|
|
336
336
|
return _1.DisTubeStream.DirectLink(streamURL, streamOptions);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DisTubeHandler.js","sourceRoot":"","sources":["../../src/core/DisTubeHandler.ts"],"names":[],"mappings":";;;;;;AAAA,mEAAsC;AACtC,yDAAiC;AACjC,wBAA+C;AAC/C,0BAUY;AAGZ;;;;GAIG;AACH,MAAa,cAAe,SAAQ,cAAW;IAE7C,YAAY,OAAgB;QAC1B,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC;QAE5C,IAAI,IAAI,CAAC,OAAO,CAAC,aAAa,EAAE;YAC9B,MAAM,cAAc,GAAQ;gBAC1B,OAAO,EAAE;oBACP,MAAM,EAAE,IAAI,CAAC,OAAO,CAAC,aAAa;iBACnC;aACF,CAAC;YACF,IAAI,IAAI,CAAC,OAAO,CAAC,oBAAoB,EAAE;gBACrC,cAAc,CAAC,OAAO,CAAC,0BAA0B,CAAC,GAAG,IAAI,CAAC,OAAO,CAAC,oBAAoB,CAAC;aACxF;YACD,MAAM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AAC;QAChC,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,MAAuB,EAAE,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;QAClG,MAAM,UAAU,GAAG,KAAK,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,KAAK,EAAE,UAAU,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;QACrF,MAAM,IAAI,GAAG,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC;QACpD,MAAM,aAAa,GAAG,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;QACnD,MAAM,CAAC,MAAM,CAAC,aAAa,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC;QAC/C,IAAI,MAAM,KAAK,SAAS;YAAE,OAAO,gBAAa,CAAC,OAAO,CAAC,OAAO,EAAE,aAAa,CAAC,CAAC;QAC/E,OAAO,gBAAa,CAAC,UAAU,CAAC,SAAmB,EAAE,aAAa,CAAC,CAAC;IACtE,CAAC;CACF;AA3XD,wCA2XC","sourcesContent":["import ytdl from \"@distube/ytdl-core\";\nimport ytpl from \"@distube/ytpl\";\nimport { DisTubeBase, DisTubeStream } from \".\";\nimport {\n DisTubeError,\n Playlist,\n Queue,\n SearchResult,\n Song,\n isMessageInstance,\n isSupportedVoiceChannel,\n isURL,\n isVoiceChannelEmpty,\n} from \"..\";\nimport type { DisTube, OtherSongInfo } from \"..\";\nimport type { GuildMember, GuildTextBasedChannel, Message, TextChannel, VoiceBasedChannel } from \"discord.js\";\n/**\n * DisTube's Handler\n * @extends DisTubeBase\n * @private\n */\nexport class DisTubeHandler extends DisTubeBase {\n ytdlOptions: ytdl.downloadOptions;\n constructor(distube: DisTube) {\n super(distube);\n this.ytdlOptions = this.options.ytdlOptions;\n\n if (this.options.youtubeCookie) {\n const requestOptions: any = {\n headers: {\n cookie: this.options.youtubeCookie,\n },\n };\n if (this.options.youtubeIdentityToken) {\n requestOptions.headers[\"x-youtube-identity-token\"] = this.options.youtubeIdentityToken;\n }\n Object.assign(this.ytdlOptions, { requestOptions });\n }\n\n const client = this.client;\n if (this.options.leaveOnEmpty) {\n client.on(\"voiceStateUpdate\", oldState => {\n if (!oldState?.channel) return;\n const queue = this.queues.get(oldState);\n if (!queue) {\n if (isVoiceChannelEmpty(oldState)) {\n setTimeout(() => {\n if (!this.queues.get(oldState) && isVoiceChannelEmpty(oldState)) this.voices.leave(oldState);\n }, this.options.emptyCooldown * 1e3).unref();\n }\n return;\n }\n if (queue.emptyTimeout) {\n clearTimeout(queue.emptyTimeout);\n delete queue.emptyTimeout;\n }\n if (isVoiceChannelEmpty(oldState)) {\n queue.emptyTimeout = setTimeout(() => {\n delete queue.emptyTimeout;\n if (isVoiceChannelEmpty(oldState)) {\n queue.voice.leave();\n this.emit(\"empty\", queue);\n if (queue.stopped) queue.delete();\n }\n }, this.options.emptyCooldown * 1e3).unref();\n }\n });\n }\n }\n\n /**\n * Create a new guild queue\n * @param {Discord.Message|Discord.VoiceChannel|Discord.StageChannel} message A user message | a voice channel\n * @param {Song|Song[]} song Song to play\n * @param {Discord.BaseGuildTextChannel?} textChannel A text channel of the queue\n * @throws {Error}\n * @returns {Promise<Queue|true>} `true` if queue is not generated\n * @deprecated Use {@link QueueManager#create} instead\n */\n async createQueue(\n message: Message<true> | VoiceBasedChannel,\n song: Song | Song[],\n textChannel?: GuildTextBasedChannel,\n ): Promise<Queue | true> {\n process.emitWarning(\n \"DisTubeHandler#createQueue is deprecated, use QueueManager#create instead.\",\n \"DeprecationWarning\",\n );\n let voice: VoiceBasedChannel | undefined;\n if (isMessageInstance(message)) {\n textChannel = message.channel;\n voice = message.member?.voice?.channel ?? undefined;\n } else {\n voice = message;\n }\n if (!voice) throw new DisTubeError(\"NOT_IN_VOICE\");\n if (!isSupportedVoiceChannel(voice)) throw new DisTubeError(\"INVALID_TYPE\", \"BaseGuildVoiceChannel\", voice);\n return this.queues.create(voice, song, textChannel);\n }\n\n /**\n * @param {string} url url\n * @param {boolean} [basic=false] getBasicInfo?\n * @returns {Promise<ytdl.videoInfo>}\n */\n getYouTubeInfo(url: string, basic = false): Promise<ytdl.videoInfo> {\n if (basic) return ytdl.getBasicInfo(url, this.ytdlOptions);\n return ytdl.getInfo(url, this.ytdlOptions);\n }\n\n /**\n * Resolve a Song\n * @param {string|Song|SearchResult|Playlist} song URL | Search string | {@link Song}\n * @param {Object} [options] Optional options\n * @param {Discord.GuildMember} [options.member] Requested user\n * @param {*} [options.metadata] Metadata\n * @returns {Promise<Song|Playlist|null>} Resolved\n */\n async resolveSong(\n song: string | ytdl.videoInfo | Song | Playlist | SearchResult | OtherSongInfo | ytdl.relatedVideo | null,\n options: {\n member?: GuildMember;\n metadata?: any;\n } = {},\n ): Promise<Song | Playlist | null> {\n if (!song) return null;\n if (song instanceof Song || song instanceof Playlist) {\n if (options.metadata) song._patchMetadata(options.metadata);\n if (options.member) song._patchMember(options.member);\n return song;\n }\n if (song instanceof SearchResult) {\n if (song.type === \"video\") return new Song(song, options);\n return this.resolvePlaylist(song.url, options);\n }\n if (typeof song === \"object\") return new Song(song, options);\n if (ytdl.validateURL(song)) return new Song(await this.getYouTubeInfo(song), options);\n if (isURL(song)) {\n for (const plugin of this.distube.extractorPlugins) {\n if (await plugin.validate(song)) return plugin.resolve(song, options);\n }\n throw new DisTubeError(\"NOT_SUPPORTED_URL\");\n }\n throw new DisTubeError(\"CANNOT_RESOLVE_SONG\", typeof song);\n }\n\n /**\n * Resolve Song[] or url to a Playlist\n * @param {Playlist|Song[]|string} playlist Resolvable playlist\n * @param {Object} options Optional options\n * @param {Discord.GuildMember} [options.member] Requested user\n * @param {string} [options.source=\"youtube\"] Playlist source\n * @param {*} [options.metadata] Metadata\n * @returns {Promise<Playlist>}\n */\n async resolvePlaylist(\n playlist: Playlist | Song[] | string,\n options: {\n member?: GuildMember;\n source?: string;\n metadata?: any;\n } = {},\n ): Promise<Playlist> {\n const { member, source, metadata } = Object.assign({ source: \"youtube\" }, options);\n if (playlist instanceof Playlist) {\n if (metadata) playlist._patchMetadata(metadata);\n if (member) playlist._patchMember(member);\n return playlist;\n }\n let solvablePlaylist: Song[] | ytpl.result;\n if (typeof playlist === \"string\") {\n solvablePlaylist = await ytpl(playlist, { limit: Infinity });\n (solvablePlaylist as any).items = solvablePlaylist.items\n .filter(v => !v.thumbnail.includes(\"no_thumbnail\"))\n .map(v => new Song(v as OtherSongInfo, { member, metadata }));\n } else {\n solvablePlaylist = playlist;\n }\n return new Playlist(solvablePlaylist, { member, properties: { source }, metadata });\n }\n\n /**\n * Create a custom playlist\n * @returns {Promise<Playlist>}\n * @param {Discord.Message|Discord.GuildMember} message A message from guild channel | A guild member\n * @param {Array<string|Song|SearchResult>} songs Array of url, Song or SearchResult\n * @param {Object} [properties={}] Additional properties such as `name`\n * @param {boolean} [parallel=true] Whether or not fetch the songs in parallel\n * @param {*} [metadata] Metadata\n * @deprecated Use {@link DisTube#createCustomPlaylist} instead\n */\n async createCustomPlaylist(\n message: Message<true> | GuildMember,\n songs: (string | Song | SearchResult)[],\n properties: any = {},\n parallel = true,\n metadata?: any,\n ): Promise<Playlist> {\n process.emitWarning(\n \"DisTubeHandler#createCustomPlaylist is deprecated, use DisTube#createCustomPlaylist instead.\",\n \"DeprecationWarning\",\n );\n return this.distube.createCustomPlaylist(songs, {\n member: (message as Message<true>).member ?? (message as GuildMember),\n properties,\n parallel,\n metadata,\n });\n }\n\n /**\n * Play / add a playlist\n * @returns {Promise<void>}\n * @param {Discord.BaseGuildVoiceChannel} voice A voice channel\n * @param {Playlist|string} playlist A YouTube playlist url | a Playlist\n * @param {Object} [options] Optional options\n * @param {Discord.BaseGuildTextChannel} [options.textChannel] The default text channel of the queue\n * @param {boolean} [options.skip=false] Skip the playing song (if exists) and play the added playlist instantly\n * @param {boolean} [options.unshift=false] Add the playlist after the playing song if exists\n */\n async handlePlaylist(\n voice: VoiceBasedChannel,\n playlist: Playlist,\n options?: {\n textChannel?: GuildTextBasedChannel;\n skip?: boolean;\n position?: number;\n },\n ): Promise<void>;\n /** @deprecated `options.unshift` is deprecated, use `options.position` instead */\n async handlePlaylist(\n voice: VoiceBasedChannel,\n playlist: Playlist,\n options?: {\n textChannel?: GuildTextBasedChannel;\n skip?: boolean;\n position?: number;\n unshift?: boolean;\n },\n ): Promise<void>;\n async handlePlaylist(\n voice: VoiceBasedChannel,\n playlist: Playlist,\n options: {\n textChannel?: GuildTextBasedChannel;\n skip?: boolean;\n position?: number;\n unshift?: boolean;\n } = {},\n ): Promise<void> {\n const { textChannel, skip, unshift } = Object.assign({ skip: false, unshift: false }, options);\n\n let position = Number(options.position);\n if (!position) {\n if (skip && position !== 0) position = 1;\n else position = 0;\n }\n if (unshift) position = 1;\n\n if (!(playlist instanceof Playlist)) throw new DisTubeError(\"INVALID_TYPE\", \"Playlist\", playlist, \"playlist\");\n if (!this.options.nsfw && !(textChannel as TextChannel)?.nsfw) {\n playlist.songs = playlist.songs.filter(s => !s.age_restricted);\n }\n if (!playlist.songs.length) {\n if (!this.options.nsfw && !(textChannel as TextChannel)?.nsfw) throw new DisTubeError(\"EMPTY_FILTERED_PLAYLIST\");\n throw new DisTubeError(\"EMPTY_PLAYLIST\");\n }\n const songs = playlist.songs;\n const queue = this.queues.get(voice);\n if (queue) {\n queue.addToQueue(songs, position);\n if (skip) queue.skip();\n else this.emit(\"addList\", queue, playlist);\n } else {\n const newQueue = await this.queues.create(voice, songs, textChannel);\n if (newQueue instanceof Queue) {\n if (this.options.emitAddListWhenCreatingQueue) this.emit(\"addList\", newQueue, playlist);\n this.emit(\"playSong\", newQueue, newQueue.songs[0]);\n }\n }\n }\n\n /**\n * Search for a song, fire {@link DisTube#event:error} if not found.\n * @param {Discord.Message} message The original message from an user\n * @param {string} query The query string\n * @returns {Promise<SearchResult?>} Song info\n */\n async searchSong(message: Message<true>, query: string): Promise<SearchResult | null> {\n if (!isMessageInstance(message)) throw new DisTubeError(\"INVALID_TYPE\", \"Discord.Message\", message, \"message\");\n if (typeof query !== \"string\") throw new DisTubeError(\"INVALID_TYPE\", \"string\", query, \"query\");\n if (query.length === 0) throw new DisTubeError(\"EMPTY_STRING\", \"query\");\n const limit = this.options.searchSongs > 1 ? this.options.searchSongs : 1;\n const results = await this.distube\n .search(query, {\n limit,\n safeSearch: this.options.nsfw ? false : !(message.channel as TextChannel)?.nsfw,\n })\n .catch(() => {\n if (!this.emit(\"searchNoResult\", message, query)) {\n // eslint-disable-next-line no-console\n console.warn(\"searchNoResult event does not have any listeners! Emits `error` event instead.\");\n throw new DisTubeError(\"NO_RESULT\");\n }\n });\n if (!results) return null;\n return this.createSearchMessageCollector(message, results, query);\n }\n\n /**\n * Create a message collector for selecting search results.\n *\n * Needed events: {@link DisTube#event:searchResult}, {@link DisTube#event:searchCancel},\n * {@link DisTube#event:searchInvalidAnswer}, {@link DisTube#event:searchDone}.\n * @param {Discord.Message} message The original message from an user\n * @param {Array<SearchResult|Song|Playlist>} results The search results\n * @param {string?} [query] The query string\n * @returns {Promise<SearchResult|Song|Playlist|null>} Selected result\n */\n async createSearchMessageCollector<R extends SearchResult | Song | Playlist>(\n message: Message<true>,\n results: Array<R>,\n query?: string,\n ): Promise<R | null> {\n if (!isMessageInstance(message)) throw new DisTubeError(\"INVALID_TYPE\", \"Discord.Message\", message, \"message\");\n if (!Array.isArray(results) || results.length == 0) {\n throw new DisTubeError(\"INVALID_TYPE\", \"Array<SearchResult|Song|Playlist>\", results, \"results\");\n }\n if (this.options.searchSongs > 1) {\n const searchEvents = [\n \"searchNoResult\",\n \"searchResult\",\n \"searchCancel\",\n \"searchInvalidAnswer\",\n \"searchDone\",\n ] as const;\n for (const evn of searchEvents) {\n if (this.distube.listenerCount(evn) === 0) {\n /* eslint-disable no-console */\n console.warn(`\"searchSongs\" option is disabled due to missing \"${evn}\" listener.`);\n console.warn(\n `If you don't want to use \"${evn}\" event, simply add an empty listener (not recommended):\\n` +\n `<DisTube>.on(\"${evn}\", () => {})`,\n );\n /* eslint-enable no-console */\n this.options.searchSongs = 0;\n }\n }\n }\n const limit = this.options.searchSongs > 1 ? this.options.searchSongs : 1;\n let result = results[0];\n if (limit > 1) {\n results.splice(limit);\n this.emit(\"searchResult\", message, results, query);\n const c = message.channel;\n const answers = await (c.awaitMessages.length === 0\n ? c.awaitMessages({\n filter: (m: Message) => m.author.id === message.author.id,\n max: 1,\n time: this.options.searchCooldown * 1e3,\n errors: [\"time\"],\n })\n : (c.awaitMessages as any)((m: Message) => m.author.id === message.author.id, {\n max: 1,\n time: this.options.searchCooldown * 1e3,\n errors: [\"time\"],\n })\n ).catch(() => undefined);\n const ans = answers?.first();\n if (!ans) {\n this.emit(\"searchCancel\", message, query);\n return null;\n }\n const index = parseInt(ans.content, 10);\n if (isNaN(index) || index > results.length || index < 1) {\n this.emit(\"searchInvalidAnswer\", message, ans, query);\n return null;\n }\n this.emit(\"searchDone\", message, ans, query);\n result = results[index - 1];\n }\n return result;\n }\n\n /**\n * Create a ytdl stream\n * @param {Queue} queue Queue\n * @returns {DisTubeStream}\n */\n createStream(queue: Queue): DisTubeStream {\n const { duration, formats, isLive, source, streamURL } = queue.songs[0];\n const filterArgs: string[] = [];\n queue.filters.forEach((filter: string | number) => filterArgs.push(this.distube.filters[filter]));\n const ffmpegArgs = queue.filters?.length ? [\"-af\", filterArgs.join(\",\")] : undefined;\n const seek = duration ? queue.beginTime : undefined;\n const streamOptions = { ffmpegArgs, seek, isLive };\n Object.assign(streamOptions, this.ytdlOptions);\n if (source === \"youtube\") return DisTubeStream.YouTube(formats, streamOptions);\n return DisTubeStream.DirectLink(streamURL as string, streamOptions);\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"DisTubeHandler.js","sourceRoot":"","sources":["../../src/core/DisTubeHandler.ts"],"names":[],"mappings":";;;;;;AAAA,mEAAsC;AACtC,yDAAiC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isTubeError,\n Playlist,\n Queue,\n SearchResult,\n Song,\n isMessageInstance,\n isSupportedVoiceChannel,\n isURL,\n isVoiceChannelEmpty,\n} from \"..\";\nimport type { DisTube, OtherSongInfo } from \"..\";\nimport type { GuildMember, GuildTextBasedChannel, Message, TextChannel, VoiceBasedChannel } from \"discord.js\";\nimport { isObject } from \"../util\";\n/**\n * DisTube's Handler\n * @extends DisTubeBase\n * @private\n */\nexport class DisTubeHandler extends DisTubeBase {\n constructor(distube: DisTube) {\n super(distube);\n\n if (this.options.youtubeCookie) {\n const requestOptions: any = {\n headers: {\n cookie: this.options.youtubeCookie,\n },\n };\n if (this.options.youtubeIdentityToken) {\n requestOptions.headers[\"x-youtube-identity-token\"] = this.options.youtubeIdentityToken;\n }\n Object.assign(this.ytdlOptions, { requestOptions });\n }\n\n const client = this.client;\n if (this.options.leaveOnEmpty) {\n client.on(\"voiceStateUpdate\", oldState => {\n if (!oldState?.channel) return;\n const queue = this.queues.get(oldState);\n if (!queue) {\n if (isVoiceChannelEmpty(oldState)) {\n setTimeout(() => {\n if (!this.queues.get(oldState) && isVoiceChannelEmpty(oldState)) this.voices.leave(oldState);\n }, this.options.emptyCooldown * 1e3).unref();\n }\n return;\n }\n if (queue.emptyTimeout) {\n clearTimeout(queue.emptyTimeout);\n delete queue.emptyTimeout;\n }\n if (isVoiceChannelEmpty(oldState)) {\n queue.emptyTimeout = setTimeout(() => {\n delete queue.emptyTimeout;\n if (isVoiceChannelEmpty(oldState)) {\n queue.voice.leave();\n this.emit(\"empty\", queue);\n if (queue.stopped) queue.delete();\n }\n }, this.options.emptyCooldown * 1e3).unref();\n }\n });\n }\n }\n\n get ytdlOptions() {\n return this.options.ytdlOptions;\n }\n\n /**\n * Create a new guild queue\n * @param {Discord.Message|Discord.VoiceChannel|Discord.StageChannel} message A user message | a voice channel\n * @param {Song|Song[]} song Song to play\n * @param {Discord.BaseGuildTextChannel?} textChannel A text channel of the queue\n * @throws {Error}\n * @returns {Promise<Queue|true>} `true` if queue is not generated\n * @deprecated Use {@link QueueManager#create} instead\n */\n async createQueue(\n message: Message<true> | VoiceBasedChannel,\n song: Song | Song[],\n textChannel?: GuildTextBasedChannel,\n ): Promise<Queue | true> {\n process.emitWarning(\n \"DisTubeHandler#createQueue is deprecated, use QueueManager#create instead.\",\n \"DeprecationWarning\",\n );\n let voice: VoiceBasedChannel | undefined;\n if (isMessageInstance(message)) {\n textChannel = message.channel;\n voice = message.member?.voice?.channel ?? undefined;\n } else {\n voice = message;\n }\n if (!voice) throw new DisTubeError(\"NOT_IN_VOICE\");\n if (!isSupportedVoiceChannel(voice)) throw new DisTubeError(\"INVALID_TYPE\", \"BaseGuildVoiceChannel\", voice);\n return this.queues.create(voice, song, textChannel);\n }\n\n /**\n * @param {string} url url\n * @param {boolean} [basic=false] getBasicInfo?\n * @returns {Promise<ytdl.videoInfo>}\n */\n getYouTubeInfo(url: string, basic = false): Promise<ytdl.videoInfo> {\n if (basic) return ytdl.getBasicInfo(url, this.ytdlOptions);\n return ytdl.getInfo(url, this.ytdlOptions);\n }\n\n /**\n * Resolve a Song\n * @param {string|Song|SearchResult|Playlist} song URL | Search string | {@link Song}\n * @param {Object} [options] Optional options\n * @param {Discord.GuildMember} [options.member] Requested user\n * @param {*} [options.metadata] Metadata\n * @returns {Promise<Song|Playlist|null>} Resolved\n */\n async resolveSong(\n song: string | ytdl.videoInfo | Song | Playlist | SearchResult | OtherSongInfo | ytdl.relatedVideo,\n options: {\n member?: GuildMember;\n metadata?: any;\n } = {},\n ): Promise<Song | Playlist> {\n if (song instanceof Song || song instanceof Playlist) {\n if (\"metadata\" in options) song.metadata = options.metadata;\n if (\"member\" in options) song.member = options.member;\n return song;\n }\n if (song instanceof SearchResult) {\n if (song.type === \"video\") return new Song(song, options);\n return this.resolvePlaylist(song.url, options);\n }\n if (isObject(song)) return new Song(song, options);\n if (ytdl.validateURL(song)) return new Song(await this.getYouTubeInfo(song), options);\n if (isURL(song)) {\n for (const plugin of this.distube.extractorPlugins) {\n if (await plugin.validate(song)) return plugin.resolve(song, options);\n }\n throw new DisTubeError(\"NOT_SUPPORTED_URL\");\n }\n throw new DisTubeError(\"CANNOT_RESOLVE_SONG\", song);\n }\n\n /**\n * Resolve Song[] or url to a Playlist\n * @param {Playlist|Song[]|string} playlist Resolvable playlist\n * @param {Object} options Optional options\n * @param {Discord.GuildMember} [options.member] Requested user\n * @param {string} [options.source=\"youtube\"] Playlist source\n * @param {*} [options.metadata] Metadata\n * @returns {Promise<Playlist>}\n */\n async resolvePlaylist(\n playlist: Playlist | Song[] | string,\n options: {\n member?: GuildMember;\n source?: string;\n metadata?: any;\n } = {},\n ): Promise<Playlist> {\n const { member, source, metadata } = { source: \"youtube\", ...options };\n if (playlist instanceof Playlist) {\n if (metadata) playlist._patchMetadata(metadata);\n if (member) playlist._patchMember(member);\n return playlist;\n }\n let solvablePlaylist: Song[] | ytpl.result;\n if (typeof playlist === \"string\") {\n solvablePlaylist = await ytpl(playlist, { limit: Infinity });\n (solvablePlaylist as any).items = solvablePlaylist.items\n .filter(v => !v.thumbnail.includes(\"no_thumbnail\"))\n .map(v => new Song(v as OtherSongInfo, { member, metadata }));\n } else {\n solvablePlaylist = playlist;\n }\n return new Playlist(solvablePlaylist, { member, properties: { source }, metadata });\n }\n\n /**\n * Create a custom playlist\n * @returns {Promise<Playlist>}\n * @param {Discord.Message|Discord.GuildMember} message A message from guild channel | A guild member\n * @param {Array<string|Song|SearchResult>} songs Array of url, Song or SearchResult\n * @param {Object} [properties={}] Additional properties such as `name`\n * @param {boolean} [parallel=true] Whether or not fetch the songs in parallel\n * @param {*} [metadata] Metadata\n * @deprecated Use {@link DisTube#createCustomPlaylist} instead\n */\n async createCustomPlaylist(\n message: Message<true> | GuildMember,\n songs: (string | Song | SearchResult)[],\n properties: any = {},\n parallel = true,\n metadata?: any,\n ): Promise<Playlist> {\n process.emitWarning(\n \"DisTubeHandler#createCustomPlaylist is deprecated, use DisTube#createCustomPlaylist instead.\",\n \"DeprecationWarning\",\n );\n return this.distube.createCustomPlaylist(songs, {\n member: (message as Message<true>).member ?? (message as GuildMember),\n properties,\n parallel,\n metadata,\n });\n }\n\n /**\n * Play / add a playlist\n * @returns {Promise<void>}\n * @param {Discord.BaseGuildVoiceChannel} voice A voice channel\n * @param {Playlist|string} playlist A YouTube playlist url | a Playlist\n * @param {Object} [options] Optional options\n * @param {Discord.BaseGuildTextChannel} [options.textChannel] The default text channel of the queue\n * @param {boolean} [options.skip=false] Skip the playing song (if exists) and play the added playlist instantly\n * @param {boolean} [options.unshift=false] Add the playlist after the playing song if exists\n */\n async handlePlaylist(\n voice: VoiceBasedChannel,\n playlist: Playlist,\n options?: {\n textChannel?: GuildTextBasedChannel;\n skip?: boolean;\n position?: number;\n },\n ): Promise<void>;\n /** @deprecated `options.unshift` is deprecated, use `options.position` instead */\n async handlePlaylist(\n voice: VoiceBasedChannel,\n playlist: Playlist,\n options?: {\n textChannel?: GuildTextBasedChannel;\n skip?: boolean;\n position?: number;\n unshift?: boolean;\n },\n ): Promise<void>;\n async handlePlaylist(\n voice: VoiceBasedChannel,\n playlist: Playlist,\n options: {\n textChannel?: GuildTextBasedChannel;\n skip?: boolean;\n position?: number;\n unshift?: boolean;\n } = {},\n ): Promise<void> {\n const { textChannel, skip, unshift } = { skip: false, unshift: false, ...options };\n\n let position = Number(options.position);\n if (!position) {\n if (skip && position !== 0) position = 1;\n else position = 0;\n }\n if (unshift) position = 1;\n\n if (!(playlist instanceof Playlist)) throw new DisTubeError(\"INVALID_TYPE\", \"Playlist\", playlist, \"playlist\");\n if (!this.options.nsfw && !(textChannel as TextChannel)?.nsfw) {\n playlist.songs = playlist.songs.filter(s => !s.age_restricted);\n }\n if (!playlist.songs.length) {\n if (!this.options.nsfw && !(textChannel as TextChannel)?.nsfw) throw new DisTubeError(\"EMPTY_FILTERED_PLAYLIST\");\n throw new DisTubeError(\"EMPTY_PLAYLIST\");\n }\n const songs = playlist.songs;\n const queue = this.queues.get(voice);\n if (queue) {\n queue.addToQueue(songs, position);\n if (skip) queue.skip();\n else this.emit(\"addList\", queue, playlist);\n } else {\n const newQueue = await this.queues.create(voice, songs, textChannel);\n if (newQueue instanceof Queue) {\n if (this.options.emitAddListWhenCreatingQueue) this.emit(\"addList\", newQueue, playlist);\n this.emit(\"playSong\", newQueue, newQueue.songs[0]);\n }\n }\n }\n\n /**\n * Search for a song, fire {@link DisTube#event:error} if not found.\n * @param {Discord.Message} message The original message from an user\n * @param {string} query The query string\n * @returns {Promise<SearchResult?>} Song info\n */\n async searchSong(message: Message<true>, query: string): Promise<SearchResult | null> {\n if (!isMessageInstance(message)) throw new DisTubeError(\"INVALID_TYPE\", \"Discord.Message\", message, \"message\");\n if (typeof query !== \"string\") throw new DisTubeError(\"INVALID_TYPE\", \"string\", query, \"query\");\n if (query.length === 0) throw new DisTubeError(\"EMPTY_STRING\", \"query\");\n const limit = this.options.searchSongs > 1 ? this.options.searchSongs : 1;\n const results = await this.distube\n .search(query, {\n limit,\n safeSearch: this.options.nsfw ? false : !(message.channel as TextChannel)?.nsfw,\n })\n .catch(() => {\n if (!this.emit(\"searchNoResult\", message, query)) {\n // eslint-disable-next-line no-console\n console.warn(\"searchNoResult event does not have any listeners! Emits `error` event instead.\");\n throw new DisTubeError(\"NO_RESULT\");\n }\n });\n if (!results) return null;\n return this.createSearchMessageCollector(message, results, query);\n }\n\n /**\n * Create a message collector for selecting search results.\n *\n * Needed events: {@link DisTube#event:searchResult}, {@link DisTube#event:searchCancel},\n * {@link DisTube#event:searchInvalidAnswer}, {@link DisTube#event:searchDone}.\n * @param {Discord.Message} message The original message from an user\n * @param {Array<SearchResult|Song|Playlist>} results The search results\n * @param {string?} [query] The query string\n * @returns {Promise<SearchResult|Song|Playlist|null>} Selected result\n */\n async createSearchMessageCollector<R extends SearchResult | Song | Playlist>(\n message: Message<true>,\n results: Array<R>,\n query?: string,\n ): Promise<R | null> {\n if (!isMessageInstance(message)) throw new DisTubeError(\"INVALID_TYPE\", \"Discord.Message\", message, \"message\");\n if (!Array.isArray(results) || results.length == 0) {\n throw new DisTubeError(\"INVALID_TYPE\", \"Array<SearchResult|Song|Playlist>\", results, \"results\");\n }\n if (this.options.searchSongs > 1) {\n const searchEvents = [\n \"searchNoResult\",\n \"searchResult\",\n \"searchCancel\",\n \"searchInvalidAnswer\",\n \"searchDone\",\n ] as const;\n for (const evn of searchEvents) {\n if (this.distube.listenerCount(evn) === 0) {\n /* eslint-disable no-console */\n console.warn(`\"searchSongs\" option is disabled due to missing \"${evn}\" listener.`);\n console.warn(\n `If you don't want to use \"${evn}\" event, simply add an empty listener (not recommended):\\n` +\n `<DisTube>.on(\"${evn}\", () => {})`,\n );\n /* eslint-enable no-console */\n this.options.searchSongs = 0;\n }\n }\n }\n const limit = this.options.searchSongs > 1 ? this.options.searchSongs : 1;\n let result = results[0];\n if (limit > 1) {\n results.splice(limit);\n this.emit(\"searchResult\", message, results, query);\n const c = message.channel;\n const answers = await (c.awaitMessages.length === 0\n ? c.awaitMessages({\n filter: (m: Message) => m.author.id === message.author.id,\n max: 1,\n time: this.options.searchCooldown * 1e3,\n errors: [\"time\"],\n })\n : (c.awaitMessages as any)((m: Message) => m.author.id === message.author.id, {\n max: 1,\n time: this.options.searchCooldown * 1e3,\n errors: [\"time\"],\n })\n ).catch(() => undefined);\n const ans = answers?.first();\n if (!ans) {\n this.emit(\"searchCancel\", message, query);\n return null;\n }\n const index = parseInt(ans.content, 10);\n if (isNaN(index) || index > results.length || index < 1) {\n this.emit(\"searchInvalidAnswer\", message, ans, query);\n return null;\n }\n this.emit(\"searchDone\", message, ans, query);\n result = results[index - 1];\n }\n return result;\n }\n\n /**\n * Create a ytdl stream\n * @param {Queue} queue Queue\n * @returns {DisTubeStream}\n */\n createStream(queue: Queue): DisTubeStream {\n const { duration, formats, isLive, source, streamURL } = queue.songs[0];\n const filterArgs: string[] = [];\n queue.filters.forEach((filter: string | number) => filterArgs.push(this.distube.filters[filter]));\n const ffmpegArgs = queue.filters?.length ? [\"-af\", filterArgs.join(\",\")] : undefined;\n const seek = duration ? queue.beginTime : undefined;\n const streamOptions = { ffmpegArgs, seek, isLive };\n if (source === \"youtube\") return DisTubeStream.YouTube(formats, streamOptions);\n return DisTubeStream.DirectLink(streamURL as string, streamOptions);\n }\n}\n"]}
|
|
@@ -15,7 +15,7 @@ export declare class Options {
|
|
|
15
15
|
youtubeIdentityToken?: string;
|
|
16
16
|
youtubeDL: boolean;
|
|
17
17
|
updateYouTubeDL: boolean;
|
|
18
|
-
customFilters
|
|
18
|
+
customFilters?: Filters;
|
|
19
19
|
ytdlOptions: ytdl.getInfoOptions;
|
|
20
20
|
nsfw: boolean;
|
|
21
21
|
emitAddSongWhenCreatingQueue: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DisTubeOptions.d.ts","sourceRoot":"","sources":["../../src/core/DisTubeOptions.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,IAAI,MAAM,oBAAoB,CAAC;AAC3C,OAAO,KAAK,EAAE,YAAY,EAAE,cAAc,EAAE,eAAe,EAAE,OAAO,EAAE,MAAM,IAAI,CAAC;AAEjF,qBAAa,OAAO;;IAClB,OAAO,EAAE,CAAC,YAAY,GAAG,eAAe,CAAC,EAAE,CAAC;IAC5C,eAAe,EAAE,OAAO,CAAC;IACzB,aAAa,EAAE,OAAO,CAAC;IACvB,WAAW,EAAE,OAAO,CAAC;IACrB,YAAY,EAAE,OAAO,CAAC;IACtB,aAAa,EAAE,MAAM,CAAC;IACtB,iBAAiB,EAAE,OAAO,CAAC;IAC3B,WAAW,EAAE,MAAM,CAAC;IACpB,cAAc,EAAE,MAAM,CAAC;IACvB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,SAAS,EAAE,OAAO,CAAC;IACnB,eAAe,EAAE,OAAO,CAAC;IACzB,aAAa,EAAE,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"DisTubeOptions.d.ts","sourceRoot":"","sources":["../../src/core/DisTubeOptions.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,IAAI,MAAM,oBAAoB,CAAC;AAC3C,OAAO,KAAK,EAAE,YAAY,EAAE,cAAc,EAAE,eAAe,EAAE,OAAO,EAAE,MAAM,IAAI,CAAC;AAEjF,qBAAa,OAAO;;IAClB,OAAO,EAAE,CAAC,YAAY,GAAG,eAAe,CAAC,EAAE,CAAC;IAC5C,eAAe,EAAE,OAAO,CAAC;IACzB,aAAa,EAAE,OAAO,CAAC;IACvB,WAAW,EAAE,OAAO,CAAC;IACrB,YAAY,EAAE,OAAO,CAAC;IACtB,aAAa,EAAE,MAAM,CAAC;IACtB,iBAAiB,EAAE,OAAO,CAAC;IAC3B,WAAW,EAAE,MAAM,CAAC;IACpB,cAAc,EAAE,MAAM,CAAC;IACvB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,SAAS,EAAE,OAAO,CAAC;IACnB,eAAe,EAAE,OAAO,CAAC;IACzB,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,WAAW,EAAE,IAAI,CAAC,cAAc,CAAC;IACjC,IAAI,EAAE,OAAO,CAAC;IACd,4BAA4B,EAAE,OAAO,CAAC;IACtC,4BAA4B,EAAE,OAAO,CAAC;gBAC1B,OAAO,EAAE,cAAc;CA6GpC"}
|
|
@@ -14,9 +14,7 @@ class Options {
|
|
|
14
14
|
if (typeof options !== "object" || Array.isArray(options)) {
|
|
15
15
|
throw new __1.DisTubeError("INVALID_TYPE", "object", options, "DisTubeOptions");
|
|
16
16
|
}
|
|
17
|
-
const
|
|
18
|
-
// Object.assign(this, defaultOptions, options);
|
|
19
|
-
const opts = Object.assign({}, def, options);
|
|
17
|
+
const opts = { ...__1.defaultOptions, ...options };
|
|
20
18
|
this.plugins = opts.plugins;
|
|
21
19
|
this.emitNewSongOnly = opts.emitNewSongOnly;
|
|
22
20
|
this.leaveOnEmpty = opts.leaveOnEmpty;
|
|
@@ -73,7 +71,8 @@ _Options_instances = new WeakSet(), _Options_validateOptions = function _Options
|
|
|
73
71
|
if (typeof options.youtubeIdentityToken !== "undefined" && typeof options.youtubeIdentityToken !== "string") {
|
|
74
72
|
throw new __1.DisTubeError("INVALID_TYPE", "string", options.youtubeIdentityToken, "DisTubeOptions.youtubeIdentityToken");
|
|
75
73
|
}
|
|
76
|
-
if (typeof options.customFilters !== "
|
|
74
|
+
if ((typeof options.customFilters !== "undefined" && typeof options.customFilters !== "object") ||
|
|
75
|
+
Array.isArray(options.customFilters)) {
|
|
77
76
|
throw new __1.DisTubeError("INVALID_TYPE", "object", options.customFilters, "DisTubeOptions.customFilters");
|
|
78
77
|
}
|
|
79
78
|
if (typeof options.ytdlOptions !== "object" || Array.isArray(options.ytdlOptions)) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DisTubeOptions.js","sourceRoot":"","sources":["../../src/core/DisTubeOptions.ts"],"names":[],"mappings":";;;;;;;;;AAAA,0BAAmE;AAInE,MAAa,OAAO;IAmBlB,YAAY,OAAuB;;QACjC,IAAI,OAAO,OAAO,KAAK,QAAQ,IAAI,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE;YACzD,MAAM,IAAI,gBAAY,CAAC,cAAc,EAAE,QAAQ,EAAE,OAAO,EAAE,gBAAgB,CAAC,CAAC;SAC7E;QACD,MAAM,GAAG,GAAG,EAAE,GAAG,kBAAc,EAAE,CAAC;QAClC,gDAAgD;QAChD,MAAM,IAAI,GAAG,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,GAAG,EAAE,OAAO,CAAC,CAAC;QAC7C,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC;QAC5B,IAAI,CAAC,eAAe,GAAG,IAAI,CAAC,eAAe,CAAC;QAC5C,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC,YAAY,CAAC;QACtC,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC,aAAa,CA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,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE;QACnC,MAAM,IAAI,gBAAY,CAAC,cAAc,EAAE,eAAe,EAAE,OAAO,CAAC,OAAO,EAAE,wBAAwB,CAAC,CAAC;KACpG;IACD,IAAI,OAAO,OAAO,CAAC,IAAI,KAAK,SAAS,EAAE;QACrC,MAAM,IAAI,gBAAY,CAAC,cAAc,EAAE,SAAS,EAAE,OAAO,CAAC,IAAI,EAAE,qBAAqB,CAAC,CAAC;KACxF;IACD,IAAI,OAAO,OAAO,CAAC,4BAA4B,KAAK,SAAS,EAAE;QAC7D,MAAM,IAAI,gBAAY,CACpB,cAAc,EACd,SAAS,EACT,OAAO,CAAC,4BAA4B,EACpC,6CAA6C,CAC9C,CAAC;KACH;IACD,IAAI,OAAO,OAAO,CAAC,4BAA4B,KAAK,SAAS,EAAE;QAC7D,MAAM,IAAI,gBAAY,CACpB,cAAc,EACd,SAAS,EACT,OAAO,CAAC,4BAA4B,EACpC,6CAA6C,CAC9C,CAAC;KACH;AACH,CAAC","sourcesContent":["import { DisTubeError, checkInvalidKey, defaultOptions } from \"..\";\nimport type ytdl from \"@distube/ytdl-core\";\nimport type { CustomPlugin, DisTubeOptions, ExtractorPlugin, Filters } from \"..\";\n\nexport class Options {\n plugins: (CustomPlugin | ExtractorPlugin)[];\n emitNewSongOnly: boolean;\n leaveOnFinish: boolean;\n leaveOnStop: boolean;\n leaveOnEmpty: boolean;\n emptyCooldown: number;\n savePreviousSongs: boolean;\n searchSongs: number;\n searchCooldown: number;\n youtubeCookie?: string;\n youtubeIdentityToken?: string;\n youtubeDL: boolean;\n updateYouTubeDL: boolean;\n customFilters: Filters;\n ytdlOptions: ytdl.getInfoOptions;\n nsfw: boolean;\n emitAddSongWhenCreatingQueue: boolean;\n emitAddListWhenCreatingQueue: boolean;\n constructor(options: DisTubeOptions) {\n if (typeof options !== \"object\" || Array.isArray(options)) {\n throw new DisTubeError(\"INVALID_TYPE\", \"object\", options, \"DisTubeOptions\");\n }\n const def = { ...defaultOptions };\n // Object.assign(this, defaultOptions, options);\n const opts = Object.assign({}, def, options);\n this.plugins = opts.plugins;\n this.emitNewSongOnly = opts.emitNewSongOnly;\n this.leaveOnEmpty = opts.leaveOnEmpty;\n this.leaveOnFinish = opts.leaveOnFinish;\n this.leaveOnStop = opts.leaveOnStop;\n this.savePreviousSongs = opts.savePreviousSongs;\n /* eslint-disable deprecation/deprecation */\n this.youtubeDL = opts.youtubeDL;\n this.updateYouTubeDL = opts.updateYouTubeDL;\n /* eslint-enable deprecation/deprecation */\n this.searchSongs = opts.searchSongs;\n this.youtubeCookie = opts.youtubeCookie;\n this.youtubeIdentityToken = opts.youtubeIdentityToken;\n this.customFilters = opts.customFilters;\n this.ytdlOptions = opts.ytdlOptions;\n this.searchCooldown = opts.searchCooldown;\n this.emptyCooldown = opts.emptyCooldown;\n this.nsfw = opts.nsfw;\n this.emitAddSongWhenCreatingQueue = opts.emitAddSongWhenCreatingQueue;\n this.emitAddListWhenCreatingQueue = opts.emitAddListWhenCreatingQueue;\n checkInvalidKey(opts, this, \"DisTubeOptions\");\n this.#validateOptions();\n if (this.youtubeDL) {\n process.emitWarning(\n \"DisTubeOptions.youtubeDL is deprecated, set it to false and use `@distube/yt-dlp` instead.\",\n \"DeprecationWarning\",\n );\n }\n }\n\n #validateOptions(options = this) {\n if (typeof options.emitNewSongOnly !== \"boolean\") {\n throw new DisTubeError(\"INVALID_TYPE\", \"boolean\", options.emitNewSongOnly, \"DisTubeOptions.emitNewSongOnly\");\n }\n if (typeof options.leaveOnEmpty !== \"boolean\") {\n throw new DisTubeError(\"INVALID_TYPE\", \"boolean\", options.leaveOnEmpty, \"DisTubeOptions.leaveOnEmpty\");\n }\n if (typeof options.leaveOnFinish !== \"boolean\") {\n throw new DisTubeError(\"INVALID_TYPE\", \"boolean\", options.leaveOnFinish, \"DisTubeOptions.leaveOnFinish\");\n }\n if (typeof options.leaveOnStop !== \"boolean\") {\n throw new DisTubeError(\"INVALID_TYPE\", \"boolean\", options.leaveOnStop, \"DisTubeOptions.leaveOnStop\");\n }\n if (typeof options.savePreviousSongs !== \"boolean\") {\n throw new DisTubeError(\"INVALID_TYPE\", \"boolean\", options.savePreviousSongs, \"DisTubeOptions.savePreviousSongs\");\n }\n if (typeof options.youtubeDL !== \"boolean\") {\n throw new DisTubeError(\"INVALID_TYPE\", \"boolean\", options.youtubeDL, \"DisTubeOptions.youtubeDL\");\n }\n if (typeof options.updateYouTubeDL !== \"boolean\") {\n throw new DisTubeError(\"INVALID_TYPE\", \"boolean\", options.updateYouTubeDL, \"DisTubeOptions.updateYouTubeDL\");\n }\n if (typeof options.youtubeCookie !== \"undefined\" && typeof options.youtubeCookie !== \"string\") {\n throw new DisTubeError(\"INVALID_TYPE\", \"string\", options.youtubeCookie, \"DisTubeOptions.youtubeCookie\");\n }\n if (typeof options.youtubeIdentityToken !== \"undefined\" && typeof options.youtubeIdentityToken !== \"string\") {\n throw new DisTubeError(\n \"INVALID_TYPE\",\n \"string\",\n options.youtubeIdentityToken,\n \"DisTubeOptions.youtubeIdentityToken\",\n );\n }\n if (typeof options.customFilters !== \"object\" || Array.isArray(options.customFilters)) {\n throw new DisTubeError(\"INVALID_TYPE\", \"object\", options.customFilters, \"DisTubeOptions.customFilters\");\n }\n if (typeof options.ytdlOptions !== \"object\" || Array.isArray(options.ytdlOptions)) {\n throw new DisTubeError(\"INVALID_TYPE\", \"object\", options.ytdlOptions, \"DisTubeOptions.ytdlOptions\");\n }\n if (typeof options.searchCooldown !== \"number\" || isNaN(options.searchCooldown)) {\n throw new DisTubeError(\"INVALID_TYPE\", \"number\", options.searchCooldown, \"DisTubeOptions.searchCooldown\");\n }\n if (typeof options.emptyCooldown !== \"number\" || isNaN(options.emptyCooldown)) {\n throw new DisTubeError(\"INVALID_TYPE\", \"number\", options.emptyCooldown, \"DisTubeOptions.emptyCooldown\");\n }\n if (typeof options.searchSongs !== \"number\" || isNaN(options.searchSongs)) {\n throw new DisTubeError(\"INVALID_TYPE\", \"number\", options.searchSongs, \"DisTubeOptions.searchSongs\");\n }\n if (!Array.isArray(options.plugins)) {\n throw new DisTubeError(\"INVALID_TYPE\", \"Array<Plugin>\", options.plugins, \"DisTubeOptions.plugins\");\n }\n if (typeof options.nsfw !== \"boolean\") {\n throw new DisTubeError(\"INVALID_TYPE\", \"boolean\", options.nsfw, \"DisTubeOptions.nsfw\");\n }\n if (typeof options.emitAddSongWhenCreatingQueue !== \"boolean\") {\n throw new DisTubeError(\n \"INVALID_TYPE\",\n \"boolean\",\n options.emitAddSongWhenCreatingQueue,\n \"DisTubeOptions.emitAddSongWhenCreatingQueue\",\n );\n }\n if (typeof options.emitAddListWhenCreatingQueue !== \"boolean\") {\n throw new DisTubeError(\n \"INVALID_TYPE\",\n \"boolean\",\n options.emitAddListWhenCreatingQueue,\n \"DisTubeOptions.emitAddListWhenCreatingQueue\",\n );\n }\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"DisTubeOptions.js","sourceRoot":"","sources":["../../src/core/DisTubeOptions.ts"],"names":[],"mappings":";;;;;;;;;AAAA,0BAAmE;AAInE,MAAa,OAAO;IAmBlB,YAAY,OAAuB;;QACjC,IAAI,OAAO,OAAO,KAAK,QAAQ,IAAI,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE;YACzD,MAAM,IAAI,gBAAY,CAAC,cAAc,EAAE,QAAQ,EAAE,OAAO,EAAE,gBAAgB,CAAC,CAAC;SAC7E;QACD,MAAM,IAAI,GAAG,EAAE,GAAG,kBAAc,EAAE,GAAG,OAAO,EAAE,CAAC;QAC/C,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC;QAC5B,IAAI,CAAC,eAAe,GAAG,IAAI,CAAC,eAAe,CAAC;QAC5C,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC,YAAY,CAAC;QACtC,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC,aAAa,CAAC;QACxC,IAAI,CA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AE,4BAA4B,CAAC,CAAC;KACrG;IACD,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE;QACnC,MAAM,IAAI,gBAAY,CAAC,cAAc,EAAE,eAAe,EAAE,OAAO,CAAC,OAAO,EAAE,wBAAwB,CAAC,CAAC;KACpG;IACD,IAAI,OAAO,OAAO,CAAC,IAAI,KAAK,SAAS,EAAE;QACrC,MAAM,IAAI,gBAAY,CAAC,cAAc,EAAE,SAAS,EAAE,OAAO,CAAC,IAAI,EAAE,qBAAqB,CAAC,CAAC;KACxF;IACD,IAAI,OAAO,OAAO,CAAC,4BAA4B,KAAK,SAAS,EAAE;QAC7D,MAAM,IAAI,gBAAY,CACpB,cAAc,EACd,SAAS,EACT,OAAO,CAAC,4BAA4B,EACpC,6CAA6C,CAC9C,CAAC;KACH;IACD,IAAI,OAAO,OAAO,CAAC,4BAA4B,KAAK,SAAS,EAAE;QAC7D,MAAM,IAAI,gBAAY,CACpB,cAAc,EACd,SAAS,EACT,OAAO,CAAC,4BAA4B,EACpC,6CAA6C,CAC9C,CAAC;KACH;AACH,CAAC","sourcesContent":["import { DisTubeError, checkInvalidKey, defaultOptions } from \"..\";\nimport type ytdl from \"@distube/ytdl-core\";\nimport type { CustomPlugin, DisTubeOptions, ExtractorPlugin, Filters } from \"..\";\n\nexport class Options {\n plugins: (CustomPlugin | ExtractorPlugin)[];\n emitNewSongOnly: boolean;\n leaveOnFinish: boolean;\n leaveOnStop: boolean;\n leaveOnEmpty: boolean;\n emptyCooldown: number;\n savePreviousSongs: boolean;\n searchSongs: number;\n searchCooldown: number;\n youtubeCookie?: string;\n youtubeIdentityToken?: string;\n youtubeDL: boolean;\n updateYouTubeDL: boolean;\n customFilters?: Filters;\n ytdlOptions: ytdl.getInfoOptions;\n nsfw: boolean;\n emitAddSongWhenCreatingQueue: boolean;\n emitAddListWhenCreatingQueue: boolean;\n constructor(options: DisTubeOptions) {\n if (typeof options !== \"object\" || Array.isArray(options)) {\n throw new DisTubeError(\"INVALID_TYPE\", \"object\", options, \"DisTubeOptions\");\n }\n const opts = { ...defaultOptions, ...options };\n this.plugins = opts.plugins;\n this.emitNewSongOnly = opts.emitNewSongOnly;\n this.leaveOnEmpty = opts.leaveOnEmpty;\n this.leaveOnFinish = opts.leaveOnFinish;\n this.leaveOnStop = opts.leaveOnStop;\n this.savePreviousSongs = opts.savePreviousSongs;\n /* eslint-disable deprecation/deprecation */\n this.youtubeDL = opts.youtubeDL;\n this.updateYouTubeDL = opts.updateYouTubeDL;\n /* eslint-enable deprecation/deprecation */\n this.searchSongs = opts.searchSongs;\n this.youtubeCookie = opts.youtubeCookie;\n this.youtubeIdentityToken = opts.youtubeIdentityToken;\n this.customFilters = opts.customFilters;\n this.ytdlOptions = opts.ytdlOptions;\n this.searchCooldown = opts.searchCooldown;\n this.emptyCooldown = opts.emptyCooldown;\n this.nsfw = opts.nsfw;\n this.emitAddSongWhenCreatingQueue = opts.emitAddSongWhenCreatingQueue;\n this.emitAddListWhenCreatingQueue = opts.emitAddListWhenCreatingQueue;\n checkInvalidKey(opts, this, \"DisTubeOptions\");\n this.#validateOptions();\n if (this.youtubeDL) {\n process.emitWarning(\n \"DisTubeOptions.youtubeDL is deprecated, set it to false and use `@distube/yt-dlp` instead.\",\n \"DeprecationWarning\",\n );\n }\n }\n\n #validateOptions(options = this) {\n if (typeof options.emitNewSongOnly !== \"boolean\") {\n throw new DisTubeError(\"INVALID_TYPE\", \"boolean\", options.emitNewSongOnly, \"DisTubeOptions.emitNewSongOnly\");\n }\n if (typeof options.leaveOnEmpty !== \"boolean\") {\n throw new DisTubeError(\"INVALID_TYPE\", \"boolean\", options.leaveOnEmpty, \"DisTubeOptions.leaveOnEmpty\");\n }\n if (typeof options.leaveOnFinish !== \"boolean\") {\n throw new DisTubeError(\"INVALID_TYPE\", \"boolean\", options.leaveOnFinish, \"DisTubeOptions.leaveOnFinish\");\n }\n if (typeof options.leaveOnStop !== \"boolean\") {\n throw new DisTubeError(\"INVALID_TYPE\", \"boolean\", options.leaveOnStop, \"DisTubeOptions.leaveOnStop\");\n }\n if (typeof options.savePreviousSongs !== \"boolean\") {\n throw new DisTubeError(\"INVALID_TYPE\", \"boolean\", options.savePreviousSongs, \"DisTubeOptions.savePreviousSongs\");\n }\n if (typeof options.youtubeDL !== \"boolean\") {\n throw new DisTubeError(\"INVALID_TYPE\", \"boolean\", options.youtubeDL, \"DisTubeOptions.youtubeDL\");\n }\n if (typeof options.updateYouTubeDL !== \"boolean\") {\n throw new DisTubeError(\"INVALID_TYPE\", \"boolean\", options.updateYouTubeDL, \"DisTubeOptions.updateYouTubeDL\");\n }\n if (typeof options.youtubeCookie !== \"undefined\" && typeof options.youtubeCookie !== \"string\") {\n throw new DisTubeError(\"INVALID_TYPE\", \"string\", options.youtubeCookie, \"DisTubeOptions.youtubeCookie\");\n }\n if (typeof options.youtubeIdentityToken !== \"undefined\" && typeof options.youtubeIdentityToken !== \"string\") {\n throw new DisTubeError(\n \"INVALID_TYPE\",\n \"string\",\n options.youtubeIdentityToken,\n \"DisTubeOptions.youtubeIdentityToken\",\n );\n }\n if (\n (typeof options.customFilters !== \"undefined\" && typeof options.customFilters !== \"object\") ||\n Array.isArray(options.customFilters)\n ) {\n throw new DisTubeError(\"INVALID_TYPE\", \"object\", options.customFilters, \"DisTubeOptions.customFilters\");\n }\n if (typeof options.ytdlOptions !== \"object\" || Array.isArray(options.ytdlOptions)) {\n throw new DisTubeError(\"INVALID_TYPE\", \"object\", options.ytdlOptions, \"DisTubeOptions.ytdlOptions\");\n }\n if (typeof options.searchCooldown !== \"number\" || isNaN(options.searchCooldown)) {\n throw new DisTubeError(\"INVALID_TYPE\", \"number\", options.searchCooldown, \"DisTubeOptions.searchCooldown\");\n }\n if (typeof options.emptyCooldown !== \"number\" || isNaN(options.emptyCooldown)) {\n throw new DisTubeError(\"INVALID_TYPE\", \"number\", options.emptyCooldown, \"DisTubeOptions.emptyCooldown\");\n }\n if (typeof options.searchSongs !== \"number\" || isNaN(options.searchSongs)) {\n throw new DisTubeError(\"INVALID_TYPE\", \"number\", options.searchSongs, \"DisTubeOptions.searchSongs\");\n }\n if (!Array.isArray(options.plugins)) {\n throw new DisTubeError(\"INVALID_TYPE\", \"Array<Plugin>\", options.plugins, \"DisTubeOptions.plugins\");\n }\n if (typeof options.nsfw !== \"boolean\") {\n throw new DisTubeError(\"INVALID_TYPE\", \"boolean\", options.nsfw, \"DisTubeOptions.nsfw\");\n }\n if (typeof options.emitAddSongWhenCreatingQueue !== \"boolean\") {\n throw new DisTubeError(\n \"INVALID_TYPE\",\n \"boolean\",\n options.emitAddSongWhenCreatingQueue,\n \"DisTubeOptions.emitAddSongWhenCreatingQueue\",\n );\n }\n if (typeof options.emitAddListWhenCreatingQueue !== \"boolean\") {\n throw new DisTubeError(\n \"INVALID_TYPE\",\n \"boolean\",\n options.emitAddListWhenCreatingQueue,\n \"DisTubeOptions.emitAddListWhenCreatingQueue\",\n );\n }\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DisTubeStream.d.ts","sourceRoot":"","sources":["../../src/core/DisTubeStream.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAErC,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,KAAK,IAAI,MAAM,oBAAoB,CAAC;AAE3C,UAAU,
|
|
1
|
+
{"version":3,"file":"DisTubeStream.d.ts","sourceRoot":"","sources":["../../src/core/DisTubeStream.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAErC,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,KAAK,IAAI,MAAM,oBAAoB,CAAC;AAE3C,UAAU,aAAa;IACrB;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IACd;;OAEG;IACH,UAAU,CAAC,EAAE,MAAM,EA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from \"..\";\nimport { FFmpeg } from \"prism-media\";\nimport { DisTubeError } from \"../struct\";\nimport { StreamType } from \"@discordjs/voice\";\nimport type ytdl from \"@distube/ytdl-core\";\n\ninterface StreamOptions
|
|
1
|
+
{"version":3,"file":"DisTubeStream.js","sourceRoot":"","sources":["../../src/core/DisTubeStream.ts"],"names":[],"mappings":";;;AAAA,0BAA2B;AAC3B,6CAAqC;AACrC,sCAAyC;AACzC,4CAA8C;AAkBvC,MAAM,qBAAqB,GAAG,CAAC,OAA2B,EAAE,MAAM,GAAG,KAAK,EAAE,EAAE;IACnF,IAAI,MAAM,GAAG,CAAC,MAAwB,EAAE,EAAE,CAAC,MAAM,CAAC,QAAQ,CAAC;IAC3D,IAAI,MAAM;QAAE,MAAM,GAAG,CAAC,MAAwB,EAAE,EAAE,CAAC,MAAM,CAAC,QAAQ,IAAI,MAAM,CAAC,KAAK,CAAC;IACnF,OAAO,GAAG,OAAO;SACd,MAAM,CAAC,MAAM,CAAC;SACd,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC,YAAY,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,YAAY,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC;IAC5G,OAAO,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AACtH,CAAC,CAAC;AAPW,QAAA,qBAAqB,yBAOhC;AAEF;;;GAGG;AACH,MAAa,aAAa;IAoCxB;;;;;OAKG;IACH,YAAY,GAAW,EAA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,IAAA,6BAAqB,EAAC,OAAO,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC;QAClE,IAAI,CAAC,UAAU;YAAE,MAAM,IAAI,qBAAY,CAAC,oBAAoB,CAAC,CAAC;QAC9D,OAAO,IAAI,aAAa,CAAC,UAAU,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;IACpD,CAAC;IACD;;;;;;OAMG;IACH,MAAM,CAAC,UAAU,CAAC,GAAW,EAAE,UAAyB,EAAE;QACxD,IAAI,CAAC,OAAO,IAAI,OAAO,OAAO,KAAK,QAAQ,IAAI,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE;YACrE,MAAM,IAAI,qBAAY,CAAC,cAAc,EAAE,QAAQ,EAAE,OAAO,EAAE,SAAS,CAAC,CAAC;SACtE;QACD,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,CAAC,IAAA,SAAK,EAAC,GAAG,CAAC,EAAE;YAC1C,MAAM,IAAI,qBAAY,CAAC,cAAc,EAAE,QAAQ,EAAE,GAAG,CAAC,CAAC;SACvD;QACD,OAAO,IAAI,aAAa,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;IACzC,CAAC;CAqDF;AArFD,sCAqFC","sourcesContent":["import { isURL } from \"..\";\nimport { FFmpeg } from \"prism-media\";\nimport { DisTubeError } from \"../struct\";\nimport { StreamType } from \"@discordjs/voice\";\nimport type ytdl from \"@distube/ytdl-core\";\n\ninterface StreamOptions {\n /**\n * Time to seek in seconds\n */\n seek?: number;\n /**\n * Additional FFmpeg arguments\n */\n ffmpegArgs?: string[];\n /**\n * If the stream url is live\n */\n isLive?: boolean;\n}\n\nexport const chooseBestVideoFormat = (formats: ytdl.videoFormat[], isLive = false) => {\n let filter = (format: ytdl.videoFormat) => format.hasAudio;\n if (isLive) filter = (format: ytdl.videoFormat) => format.hasAudio && format.isHLS;\n formats = formats\n .filter(filter)\n .sort((a, b) => Number(b.audioBitrate) - Number(a.audioBitrate) || Number(a.bitrate) - Number(b.bitrate));\n return formats.find(format => !format.hasVideo) || formats.sort((a, b) => Number(a.bitrate) - Number(b.bitrate))[0];\n};\n\n/**\n * Create a stream to play with {@link DisTubeVoice}\n * @private\n */\nexport class DisTubeStream {\n /**\n * Create a stream from ytdl video formats\n * @param {ytdl.videoFormat[]} formats ytdl video formats\n * @param {StreamOptions} options options\n * @returns {DisTubeStream}\n * @private\n */\n static YouTube(formats: ytdl.videoFormat[] | undefined, options: StreamOptions = {}): DisTubeStream {\n if (!formats || !formats.length) throw new DisTubeError(\"UNAVAILABLE_VIDEO\");\n if (!options || typeof options !== \"object\" || Array.isArray(options)) {\n throw new DisTubeError(\"INVALID_TYPE\", \"object\", options, \"options\");\n }\n const bestFormat = chooseBestVideoFormat(formats, options.isLive);\n if (!bestFormat) throw new DisTubeError(\"UNPLAYABLE_FORMATS\");\n return new DisTubeStream(bestFormat.url, options);\n }\n /**\n * Create a stream from a stream url\n * @param {string} url stream url\n * @param {StreamOptions} options options\n * @returns {DisTubeStream}\n * @private\n */\n static DirectLink(url: string, options: StreamOptions = {}): DisTubeStream {\n if (!options || typeof options !== \"object\" || Array.isArray(options)) {\n throw new DisTubeError(\"INVALID_TYPE\", \"object\", options, \"options\");\n }\n if (typeof url !== \"string\" || !isURL(url)) {\n throw new DisTubeError(\"INVALID_TYPE\", \"an URL\", url);\n }\n return new DisTubeStream(url, options);\n }\n type: StreamType.Raw;\n stream: FFmpeg;\n url: string;\n /**\n * Create a DisTubeStream to play with {@link DisTubeVoice}\n * @param {string} url Stream URL\n * @param {StreamOptions} options Stream options\n * @private\n */\n constructor(url: string, options: StreamOptions) {\n /**\n * Stream URL\n * @type {string}\n */\n this.url = url;\n /**\n * Stream type\n * @type {DiscordVoice.StreamType.Raw}\n */\n this.type = StreamType.Raw;\n const args = [\n \"-reconnect\",\n \"1\",\n \"-reconnect_streamed\",\n \"1\",\n \"-reconnect_delay_max\",\n \"5\",\n \"-i\",\n url,\n \"-analyzeduration\",\n \"0\",\n \"-loglevel\",\n \"0\",\n \"-ar\",\n \"48000\",\n \"-ac\",\n \"2\",\n \"-f\",\n \"s16le\",\n ];\n if (typeof options.seek === \"number\" && options.seek > 0) {\n args.unshift(\"-ss\", options.seek.toString());\n }\n if (Array.isArray(options.ffmpegArgs)) {\n args.push(...options.ffmpegArgs);\n }\n /**\n * FFmpeg stream (Duplex)\n * @type {FFmpeg}\n */\n this.stream = new FFmpeg({ args, shell: false });\n }\n}\n"]}
|
|
@@ -1,45 +1,51 @@
|
|
|
1
1
|
import { Plugin } from ".";
|
|
2
2
|
import { PluginType } from "..";
|
|
3
|
-
import type { CustomPluginPlayOptions } from "..";
|
|
4
3
|
import type { VoiceBasedChannel } from "discord.js";
|
|
4
|
+
import type { Awaitable, CustomPluginPlayOptions } from "..";
|
|
5
5
|
/**
|
|
6
6
|
* Custom Plugin
|
|
7
7
|
* @extends Plugin
|
|
8
8
|
* @abstract
|
|
9
9
|
*/
|
|
10
10
|
export declare abstract class CustomPlugin extends Plugin {
|
|
11
|
+
type: PluginType;
|
|
11
12
|
/**
|
|
12
|
-
*
|
|
13
|
-
* @param {Discord.GuildMember} [member] Requested user
|
|
14
|
-
* @param {Discord.BaseGuildTextChannel} [textChannel] Default {@link Queue#textChannel}
|
|
15
|
-
* @param {boolean} [skip=false]
|
|
16
|
-
* Skip the playing song (if exists) and play the added song/playlist if `position` is 1.
|
|
17
|
-
* If `position` is defined and not equal to 1, it will skip to the next song instead of the added song
|
|
18
|
-
* @param {number} [position=0] Position of the song/playlist to add to the queue,
|
|
19
|
-
* <= 0 to add to the end of the queue.
|
|
20
|
-
* @param {boolean} [unshift=false] (DEPRECATED) Add the song/playlist to the beginning of the queue
|
|
21
|
-
* (after the playing song if exists)
|
|
22
|
-
* @param {*} [metadata] Metadata
|
|
23
|
-
*/
|
|
24
|
-
/**
|
|
25
|
-
* This method will be executed if the url is validated.
|
|
13
|
+
* This method will be executed if the `song` string is validated.
|
|
26
14
|
* @param {Discord.BaseGuildVoiceChannel} voiceChannel The voice channel will be joined
|
|
27
|
-
* @param {string} song Validated
|
|
15
|
+
* @param {string} song Validated `song`
|
|
28
16
|
* @param {CustomPluginPlayOptions} [options] Optional options
|
|
29
17
|
* @returns {Promise<void>}
|
|
30
18
|
* @abstract
|
|
31
|
-
* @method play
|
|
32
|
-
* @memberof CustomPlugin#
|
|
33
19
|
*/
|
|
34
|
-
|
|
20
|
+
abstract play(voiceChannel: VoiceBasedChannel, song: string, options: CustomPluginPlayOptions): Awaitable<void>;
|
|
35
21
|
/**
|
|
36
|
-
*
|
|
37
|
-
* @param {
|
|
38
|
-
* @
|
|
39
|
-
* @param {CustomPluginPlayOptions} [options] Optional options
|
|
40
|
-
* @returns {Promise<void>}
|
|
41
|
-
* @abstract
|
|
22
|
+
* Check if the {@link DisTube#play} `song` parameter is working with this plugin
|
|
23
|
+
* @param {string} song String need to validate
|
|
24
|
+
* @returns {boolean|Promise<boolean>}
|
|
42
25
|
*/
|
|
43
|
-
|
|
26
|
+
validate(song: string): Awaitable<boolean>;
|
|
44
27
|
}
|
|
28
|
+
/**
|
|
29
|
+
* @typedef {Object} CustomPluginPlayOptions
|
|
30
|
+
* @param {Discord.GuildMember} [member] Requested user
|
|
31
|
+
* @param {Discord.BaseGuildTextChannel} [textChannel] Default {@link Queue#textChannel}
|
|
32
|
+
* @param {boolean} [skip=false]
|
|
33
|
+
* Skip the playing song (if exists) and play the added song/playlist if `position` is 1.
|
|
34
|
+
* If `position` is defined and not equal to 1, it will skip to the next song instead of the added song
|
|
35
|
+
* @param {number} [position=0] Position of the song/playlist to add to the queue,
|
|
36
|
+
* <= 0 to add to the end of the queue.
|
|
37
|
+
* @param {boolean} [unshift=false] (DEPRECATED) Add the song/playlist to the beginning of the queue
|
|
38
|
+
* (after the playing song if exists)
|
|
39
|
+
* @param {*} [metadata] Optional metadata that can be attached to the song/playlist will be played.
|
|
40
|
+
*/
|
|
41
|
+
/**
|
|
42
|
+
* This method will be executed if the url is validated.
|
|
43
|
+
* @param {Discord.BaseGuildVoiceChannel} voiceChannel The voice channel will be joined
|
|
44
|
+
* @param {string} song Validated `song`
|
|
45
|
+
* @param {CustomPluginPlayOptions} [options] Optional options
|
|
46
|
+
* @returns {Promise<void>}
|
|
47
|
+
* @abstract
|
|
48
|
+
* @method play
|
|
49
|
+
* @memberof CustomPlugin#
|
|
50
|
+
*/
|
|
45
51
|
//# sourceMappingURL=CustomPlugin.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CustomPlugin.d.ts","sourceRoot":"","sources":["../../src/struct/CustomPlugin.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"CustomPlugin.d.ts","sourceRoot":"","sources":["../../src/struct/CustomPlugin.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,GAAG,CAAC;AAC3B,OAAO,EAAE,UAAU,EAAE,MAAM,IAAI,CAAC;AAChC,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AACpD,OAAO,KAAK,EAAE,SAAS,EAAE,uBAAuB,EAAgC,MAAM,IAAI,CAAC;AAE3F;;;;GAIG;AACH,8BAAsB,YAAa,SAAQ,MAAM;IAC/C,IAAI,aAAqB;IACzB;;;;;;;OAOG;IACH,QAAQ,CAAC,IAAI,CAAC,YAAY,EAAE,iBAAiB,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,uBAAuB,GAAG,SAAS,CAAC,IAAI,CAAC;IAC/G;;;;OAIG;IACH,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,CAAC,OAAO,CAAC;CAG3C;AAED;;;;;;;;;;;;GAYG;AAEH;;;;;;;;;GASG"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.CustomPlugin = void 0;
|
|
4
|
+
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
4
5
|
const _1 = require(".");
|
|
5
6
|
const __1 = require("..");
|
|
6
|
-
// TODO: Clean parameters on the next major version.
|
|
7
7
|
/**
|
|
8
8
|
* Custom Plugin
|
|
9
9
|
* @extends Plugin
|
|
@@ -12,31 +12,39 @@ const __1 = require("..");
|
|
|
12
12
|
class CustomPlugin extends _1.Plugin {
|
|
13
13
|
constructor() {
|
|
14
14
|
super(...arguments);
|
|
15
|
-
/**
|
|
16
|
-
* @typedef {Object} CustomPluginPlayOptions
|
|
17
|
-
* @param {Discord.GuildMember} [member] Requested user
|
|
18
|
-
* @param {Discord.BaseGuildTextChannel} [textChannel] Default {@link Queue#textChannel}
|
|
19
|
-
* @param {boolean} [skip=false]
|
|
20
|
-
* Skip the playing song (if exists) and play the added song/playlist if `position` is 1.
|
|
21
|
-
* If `position` is defined and not equal to 1, it will skip to the next song instead of the added song
|
|
22
|
-
* @param {number} [position=0] Position of the song/playlist to add to the queue,
|
|
23
|
-
* <= 0 to add to the end of the queue.
|
|
24
|
-
* @param {boolean} [unshift=false] (DEPRECATED) Add the song/playlist to the beginning of the queue
|
|
25
|
-
* (after the playing song if exists)
|
|
26
|
-
* @param {*} [metadata] Metadata
|
|
27
|
-
*/
|
|
28
|
-
/**
|
|
29
|
-
* This method will be executed if the url is validated.
|
|
30
|
-
* @param {Discord.BaseGuildVoiceChannel} voiceChannel The voice channel will be joined
|
|
31
|
-
* @param {string} song Validated url
|
|
32
|
-
* @param {CustomPluginPlayOptions} [options] Optional options
|
|
33
|
-
* @returns {Promise<void>}
|
|
34
|
-
* @abstract
|
|
35
|
-
* @method play
|
|
36
|
-
* @memberof CustomPlugin#
|
|
37
|
-
*/
|
|
38
15
|
this.type = __1.PluginType.CUSTOM;
|
|
39
16
|
}
|
|
17
|
+
/**
|
|
18
|
+
* Check if the {@link DisTube#play} `song` parameter is working with this plugin
|
|
19
|
+
* @param {string} song String need to validate
|
|
20
|
+
* @returns {boolean|Promise<boolean>}
|
|
21
|
+
*/
|
|
22
|
+
validate(song) {
|
|
23
|
+
return false;
|
|
24
|
+
}
|
|
40
25
|
}
|
|
41
26
|
exports.CustomPlugin = CustomPlugin;
|
|
27
|
+
/**
|
|
28
|
+
* @typedef {Object} CustomPluginPlayOptions
|
|
29
|
+
* @param {Discord.GuildMember} [member] Requested user
|
|
30
|
+
* @param {Discord.BaseGuildTextChannel} [textChannel] Default {@link Queue#textChannel}
|
|
31
|
+
* @param {boolean} [skip=false]
|
|
32
|
+
* Skip the playing song (if exists) and play the added song/playlist if `position` is 1.
|
|
33
|
+
* If `position` is defined and not equal to 1, it will skip to the next song instead of the added song
|
|
34
|
+
* @param {number} [position=0] Position of the song/playlist to add to the queue,
|
|
35
|
+
* <= 0 to add to the end of the queue.
|
|
36
|
+
* @param {boolean} [unshift=false] (DEPRECATED) Add the song/playlist to the beginning of the queue
|
|
37
|
+
* (after the playing song if exists)
|
|
38
|
+
* @param {*} [metadata] Optional metadata that can be attached to the song/playlist will be played.
|
|
39
|
+
*/
|
|
40
|
+
/**
|
|
41
|
+
* This method will be executed if the url is validated.
|
|
42
|
+
* @param {Discord.BaseGuildVoiceChannel} voiceChannel The voice channel will be joined
|
|
43
|
+
* @param {string} song Validated `song`
|
|
44
|
+
* @param {CustomPluginPlayOptions} [options] Optional options
|
|
45
|
+
* @returns {Promise<void>}
|
|
46
|
+
* @abstract
|
|
47
|
+
* @method play
|
|
48
|
+
* @memberof CustomPlugin#
|
|
49
|
+
*/
|
|
42
50
|
//# sourceMappingURL=CustomPlugin.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CustomPlugin.js","sourceRoot":"","sources":["../../src/struct/CustomPlugin.ts"],"names":[],"mappings":";;;AAAA,wBAA2B;AAC3B,0BAAgC;AAIhC
|
|
1
|
+
{"version":3,"file":"CustomPlugin.js","sourceRoot":"","sources":["../../src/struct/CustomPlugin.ts"],"names":[],"mappings":";;;AAAA,sDAAsD;AACtD,wBAA2B;AAC3B,0BAAgC;AAIhC;;;;GAIG;AACH,MAAsB,YAAa,SAAQ,SAAM;IAAjD;;QACE,SAAI,GAAG,cAAU,CAAC,MAAM,CAAC;IAkB3B,CAAC;IARC;;;;OAIG;IACH,QAAQ,CAAC,IAAY;QACnB,OAAO,KAAK,CAAC;IACf,CAAC;CACF;AAnBD,oCAmBC;AAED;;;;;;;;;;;;GAYG;AAEH;;;;;;;;;GASG","sourcesContent":["/* eslint-disable @typescript-eslint/no-unused-vars */\nimport { Plugin } from \".\";\nimport { PluginType } from \"..\";\nimport type { VoiceBasedChannel } from \"discord.js\";\nimport type { Awaitable, CustomPluginPlayOptions, Playlist, SearchResult, Song } from \"..\";\n\n/**\n * Custom Plugin\n * @extends Plugin\n * @abstract\n */\nexport abstract class CustomPlugin extends Plugin {\n type = PluginType.CUSTOM;\n /**\n * This method will be executed if the `song` string is validated.\n * @param {Discord.BaseGuildVoiceChannel} voiceChannel The voice channel will be joined\n * @param {string} song Validated `song`\n * @param {CustomPluginPlayOptions} [options] Optional options\n * @returns {Promise<void>}\n * @abstract\n */\n abstract play(voiceChannel: VoiceBasedChannel, song: string, options: CustomPluginPlayOptions): Awaitable<void>;\n /**\n * Check if the {@link DisTube#play} `song` parameter is working with this plugin\n * @param {string} song String need to validate\n * @returns {boolean|Promise<boolean>}\n */\n validate(song: string): Awaitable<boolean> {\n return false;\n }\n}\n\n/**\n * @typedef {Object} CustomPluginPlayOptions\n * @param {Discord.GuildMember} [member] Requested user\n * @param {Discord.BaseGuildTextChannel} [textChannel] Default {@link Queue#textChannel}\n * @param {boolean} [skip=false]\n * Skip the playing song (if exists) and play the added song/playlist if `position` is 1.\n * If `position` is defined and not equal to 1, it will skip to the next song instead of the added song\n * @param {number} [position=0] Position of the song/playlist to add to the queue,\n * <= 0 to add to the end of the queue.\n * @param {boolean} [unshift=false] (DEPRECATED) Add the song/playlist to the beginning of the queue\n * (after the playing song if exists)\n * @param {*} [metadata] Optional metadata that can be attached to the song/playlist will be played.\n */\n\n/**\n * This method will be executed if the url is validated.\n * @param {Discord.BaseGuildVoiceChannel} voiceChannel The voice channel will be joined\n * @param {string} song Validated `song`\n * @param {CustomPluginPlayOptions} [options] Optional options\n * @returns {Promise<void>}\n * @abstract\n * @method play\n * @memberof CustomPlugin#\n */\n"]}
|
|
@@ -32,7 +32,7 @@ declare const ERROR_MESSAGES: {
|
|
|
32
32
|
UNPLAYABLE_FORMATS: string;
|
|
33
33
|
NON_NSFW: string;
|
|
34
34
|
NOT_SUPPORTED_URL: string;
|
|
35
|
-
CANNOT_RESOLVE_SONG: (t:
|
|
35
|
+
CANNOT_RESOLVE_SONG: (t: any) => string;
|
|
36
36
|
NO_VALID_SONG: string;
|
|
37
37
|
EMPTY_FILTERED_PLAYLIST: string;
|
|
38
38
|
EMPTY_PLAYLIST: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DisTubeError.d.ts","sourceRoot":"","sources":["../../src/struct/DisTubeError.ts"],"names":[],"mappings":"AAEA,QAAA,MAAM,cAAc;6BACO,CAAC,MAAM,GAAG,MAAM,CAAC,GAAG,SAAS,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,OAAO,GAAG;2BAI5D,MAAM,YAAY,MAAM,SAAS,MAAM;wBAC1C,MAAM;iCACG,MAAM,QAAQ,MAAM;yBAC5B,MAAM;uBACR,MAAM,OAAO,MAAM;uBACnB,MAAM,OAAO,MAAM;wBAClB,MAAM,OAAO,MAAM,EAAE,OAAO,OAAO;yBAGlC,MAAM;yBACN,MAAM;wBACP,MAAM;;;8BAIA,MAAM;;;;;;;;;;;;;;;;;;;;6BAwBP,
|
|
1
|
+
{"version":3,"file":"DisTubeError.d.ts","sourceRoot":"","sources":["../../src/struct/DisTubeError.ts"],"names":[],"mappings":"AAEA,QAAA,MAAM,cAAc;6BACO,CAAC,MAAM,GAAG,MAAM,CAAC,GAAG,SAAS,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,OAAO,GAAG;2BAI5D,MAAM,YAAY,MAAM,SAAS,MAAM;wBAC1C,MAAM;iCACG,MAAM,QAAQ,MAAM;yBAC5B,MAAM;uBACR,MAAM,OAAO,MAAM;uBACnB,MAAM,OAAO,MAAM;wBAClB,MAAM,OAAO,MAAM,EAAE,OAAO,OAAO;yBAGlC,MAAM;yBACN,MAAM;wBACP,MAAM;;;8BAIA,MAAM;;;;;;;;;;;;;;;;;;;;6BAwBP,GAAG;;;;CAM7B,CAAC;AAEF,aAAK,aAAa,GAAG,OAAO,cAAc,CAAC;AAC3C,aAAK,UAAU,GAAG,MAAM,aAAa,CAAC;AACtC,aAAK,SAAS,GAAG;KAAG,CAAC,IAAI,UAAU,CAAC,CAAC,GAAG,aAAa,CAAC,CAAC,CAAC,SAAS,MAAM,GAAG,CAAC,GAAG,KAAK;CAAE,CAAC,UAAU,CAAC,CAAC;AAClG,aAAK,iBAAiB,GAAG,OAAO,CAAC,MAAM,OAAO,cAAc,EAAE,SAAS,CAAC,CAAC;AAMzE,qBAAa,YAAY,CAAC,CAAC,SAAS,MAAM,CAAE,SAAQ,KAAK;IACvD,SAAS,EAAE,MAAM,CAAC;gBACN,IAAI,EAAE,SAAS;gBACf,IAAI,EAAE,CAAC,SAAS,iBAAiB,GAAG,CAAC,GAAG,KAAK,EAAE,GAAG,IAAI,EAAE,UAAU,CAAC,aAAa,CAAC,OAAO,IAAI,CAAC,CAAC;gBAC9F,IAAI,EAAE,iBAAiB,EAAE,CAAC,EAAE,KAAK;gBACjC,IAAI,EAAE,CAAC,SAAS,UAAU,GAAG,6BAA6B,GAAG,CAAC,EAAE,OAAO,EAAE,MAAM;IAS3F,IAAI,IAAI,WAEP;IAED,IAAI,IAAI,WAEP;CACF"}
|
|
@@ -37,7 +37,7 @@ const ERROR_MESSAGES = {
|
|
|
37
37
|
UNPLAYABLE_FORMATS: "No playable format found",
|
|
38
38
|
NON_NSFW: "Cannot play age-restricted content in non-NSFW channel",
|
|
39
39
|
NOT_SUPPORTED_URL: "This url is not supported",
|
|
40
|
-
CANNOT_RESOLVE_SONG: (t) => `Cannot resolve ${t} to a Song`,
|
|
40
|
+
CANNOT_RESOLVE_SONG: (t) => `Cannot resolve ${(0, node_util_1.inspect)(t)} to a Song`,
|
|
41
41
|
NO_VALID_SONG: "'songs' array does not have any valid Song, SearchResult or url",
|
|
42
42
|
EMPTY_FILTERED_PLAYLIST: "There is no valid video in the playlist\n" +
|
|
43
43
|
"Maybe age-restricted contents is filtered because you are in non-NSFW channel",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DisTubeError.js","sourceRoot":"","sources":["../../src/struct/DisTubeError.ts"],"names":[],"mappings":";;;AAAA,yCAAoC;AAEpC,MAAM,cAAc,GAAG;IACrB,YAAY,EAAE,CAAC,QAA0D,EAAE,GAAQ,EAAE,IAAa,EAAE,EAAE,CACpG,YACE,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,OAAO,CAAC,KAAK,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI,QAAQ,GACjH,GAAG,IAAI,CAAC,CAAC,CAAC,SAAS,IAAI,GAAG,CAAC,CAAC,CAAC,EAAE,aAAa,IAAA,mBAAO,EAAC,GAAG,CAAC,EAAE;IAC5D,cAAc,EAAE,CAAC,IAAY,EAAE,QAAgB,EAAE,KAAa,EAAE,EAAE,CAAC,IAAI,IAAI,aAAa,QAAQ,IAAI,KAAK,EAAE;IAC3G,WAAW,EAAE,CAAC,IAAY,EAAE,EAAE,CAAC,IAAI,IAAI,qBAAqB;IAC5D,oBAAoB,EAAE,CAAC,IAAY,EAAE,IAAY,EAAE,EAAE,CAAC,sBAAsB,IAAI,aAAa,IAAI,SAAS;IAC1G,YAAY,EAAE,CAAC,IAAY,EAAE,EAAE,CAAC,IAAI,IAAI,4BAA4B;IACpE,WAAW,EAA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AC,CAAC,YAAY;IACzE,aAAa,EAAE,iEAAiE;IAChF,uBAAuB,EACrB,2CAA2C;QAC3C,+EAA+E;IACjF,cAAc,EAAE,yCAAyC;CAC1D,CAAC;AAOF,MAAM,MAAM,GAAG,CAAC,GAAqC,EAAE,GAAG,IAAS,EAAE,EAAE,CAAC,CAAC,OAAO,GAAG,KAAK,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC;AAEvH,MAAM,QAAQ,GAAG,CAAC,IAAY,EAAsB,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;AAElG,MAAa,YAA+B,SAAQ,KAAK;IAMvD,YAAY,IAAY,EAAE,GAAG,IAAS;QACpC,IAAI,QAAQ,CAAC,IAAI,CAAC;YAAE,KAAK,CAAC,MAAM,CAAC,cAAc,CAAC,IAAI,CAAC,EAAE,GAAG,IAAI,CAAC,CAAC,CAAC;;YAC5D,KAAK,CAAC,GAAG,IAAI,CAAC,CAAC;QAEpB,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;QACtB,IAAI,KAAK,CAAC,iBAAiB;YAAE,KAAK,CAAC,iBAAiB,CAAC,IAAI,EAAE,YAAY,CAAC,CAAC;IAC3E,CAAC;IAED,IAAI,IAAI;QACN,OAAO,iBAAiB,IAAI,CAAC,SAAS,GAAG,CAAC;IAC5C,CAAC;IAED,IAAI,IAAI;QACN,OAAO,IAAI,CAAC,SAAS,CAAC;IACxB,CAAC;CACF;AArBD,oCAqBC","sourcesContent":["import { inspect } from \"node:util\";\n\nconst ERROR_MESSAGES = {\n INVALID_TYPE: (expected: (number | string) | readonly (number | string)[], got: any, name?: string) =>\n `Expected ${\n Array.isArray(expected) ? expected.map(e => (typeof e === \"number\" ? e : `'${e}'`)).join(\" or \") : `'${expected}'`\n }${name ? ` for '${name}'` : \"\"}, but got ${inspect(got)}`,\n NUMBER_COMPARE: (name: string, expected: string, value: number) => `'${name}' must be ${expected} ${value}`,\n EMPTY_ARRAY: (name: string) => `'${name}' is an empty array`,\n EMPTY_FILTERED_ARRAY: (name: string, type: string) => `There is no valid '${type}' in the '${name}' array`,\n EMPTY_STRING: (name: string) => `'${name}' string must not be empty`,\n INVALID_KEY: (obj: string, key: string) => `'${key}' does not need to be provided in ${obj}`,\n MISSING_KEY: (obj: string, key: string) => `'${key}' needs to be provided in ${obj}`,\n MISSING_KEYS: (obj: string, key: string[], all: boolean) =>\n `${key.map(k => `'${k}'`).join(all ? \" and \" : \" or \")} need to be provided in ${obj}`,\n\n MISSING_INTENTS: (i: string) => `${i} intent must be provided for the Client`,\n DISABLED_OPTION: (o: string) => `DisTubeOptions.${o} is disabled`,\n ENABLED_OPTION: (o: string) => `DisTubeOptions.${o} is enabled`,\n\n NOT_IN_VOICE: \"User is not in any voice channel\",\n VOICE_FULL: \"The voice channel is full\",\n VOICE_CONNECT_FAILED: (s: number) => `Cannot connect to the voice channel after ${s} seconds`,\n VOICE_MISSING_PERMS: \"You do not have permission to join this voice channel\",\n VOICE_RECONNECT_FAILED: \"Cannot reconnect to the voice channel\",\n VOICE_CHANGE_GUILD: \"Cannot join a channel in a different guild\",\n VOICE_DEPRECATED_CONNECTION:\n \"Cannot connect to the voice channel due to a deprecated connection is created.\\n\" +\n \"Read more: https://distube.js.org/guide/additional-info/update.html#voice\",\n\n NO_QUEUE: \"There is no playing queue in this guild\",\n QUEUE_EXIST: \"This guild has a Queue already\",\n PAUSED: \"The queue has been paused already\",\n RESUMED: \"The queue has been playing already\",\n NO_PREVIOUS: \"There is no previous song in this queue\",\n NO_UP_NEXT: \"There is no up next song\",\n NO_SONG_POSITION: \"Does not have any song at this position\",\n NO_PLAYING: \"There is no playing song in the queue\",\n\n NO_RESULT: \"No result found\",\n NO_RELATED: \"Cannot find any related songs\",\n CANNOT_PLAY_RELATED: \"Cannot play the related song\",\n UNAVAILABLE_VIDEO: \"This video is unavailable\",\n UNPLAYABLE_FORMATS: \"No playable format found\",\n NON_NSFW: \"Cannot play age-restricted content in non-NSFW channel\",\n NOT_SUPPORTED_URL: \"This url is not supported\",\n CANNOT_RESOLVE_SONG: (t: any) => `Cannot resolve ${inspect(t)} to a Song`,\n NO_VALID_SONG: \"'songs' array does not have any valid Song, SearchResult or url\",\n EMPTY_FILTERED_PLAYLIST:\n \"There is no valid video in the playlist\\n\" +\n \"Maybe age-restricted contents is filtered because you are in non-NSFW channel\",\n EMPTY_PLAYLIST: \"There is no valid video in the playlist\",\n};\n\ntype ErrorMessages = typeof ERROR_MESSAGES;\ntype ErrorCodes = keyof ErrorMessages;\ntype ErrorCode = { [K in ErrorCodes]-?: ErrorMessages[K] extends string ? K : never }[ErrorCodes];\ntype ErrorCodeTemplate = Exclude<keyof typeof ERROR_MESSAGES, ErrorCode>;\n\nconst errMsg = (msg: string | ((...x: any) => string), ...args: any) => (typeof msg === \"string\" ? msg : msg(...args));\n\nconst haveCode = (code: string): code is ErrorCodes => Object.keys(ERROR_MESSAGES).includes(code);\n\nexport class DisTubeError<T extends string> extends Error {\n errorCode: string;\n constructor(code: ErrorCode);\n constructor(code: T extends ErrorCodeTemplate ? T : never, ...args: Parameters<ErrorMessages[typeof code]>);\n constructor(code: ErrorCodeTemplate, _: never);\n constructor(code: T extends ErrorCodes ? \"This is built-in error code\" : T, message: string);\n constructor(code: string, ...args: any) {\n if (haveCode(code)) super(errMsg(ERROR_MESSAGES[code], ...args));\n else super(...args);\n\n this.errorCode = code;\n if (Error.captureStackTrace) Error.captureStackTrace(this, DisTubeError);\n }\n\n get name() {\n return `DisTubeError [${this.errorCode}]`;\n }\n\n get code() {\n return this.errorCode;\n }\n}\n"]}
|