distube 4.0.6 → 4.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/index.d.ts +1088 -21
- package/dist/index.js +178 -244
- package/dist/index.js.map +1 -1
- package/package.json +28 -26
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import ytdl from '@distube/ytdl-core';
|
|
1
|
+
import * as ytdl from '@distube/ytdl-core';
|
|
2
|
+
import ytdl__default, { Cookie } from '@distube/ytdl-core';
|
|
2
3
|
import * as discord_js from 'discord.js';
|
|
3
4
|
import { GuildTextBasedChannel, Message, Snowflake, VoiceBasedChannel, VoiceState, Guild, GuildMember, Interaction, Client, Collection, ClientOptions } from 'discord.js';
|
|
4
5
|
import ytpl from '@distube/ytpl';
|
|
@@ -35,13 +36,73 @@ type DisTubeEvents = {
|
|
|
35
36
|
type TypedDisTubeEvents = {
|
|
36
37
|
[K in keyof DisTubeEvents]: (...args: DisTubeEvents[K]) => Awaitable;
|
|
37
38
|
};
|
|
39
|
+
/**
|
|
40
|
+
* An FFmpeg audio filter object
|
|
41
|
+
* ```
|
|
42
|
+
* {
|
|
43
|
+
* name: "bassboost",
|
|
44
|
+
* value: "bass=g=10"
|
|
45
|
+
* }
|
|
46
|
+
* ```
|
|
47
|
+
* @typedef {Object} Filter
|
|
48
|
+
* @prop {string} name Name of the filter
|
|
49
|
+
* @prop {string} value FFmpeg audio filter(s)
|
|
50
|
+
*/
|
|
38
51
|
interface Filter {
|
|
39
52
|
name: string;
|
|
40
53
|
value: string;
|
|
41
54
|
}
|
|
55
|
+
/**
|
|
56
|
+
* Data that resolves to give an FFmpeg audio filter. This can be:
|
|
57
|
+
* - A name of a default filters or custom filters (`string`)
|
|
58
|
+
* - A {@link Filter} object
|
|
59
|
+
* @typedef {string|Filter} FilterResolvable
|
|
60
|
+
* @see {@link defaultFilters}
|
|
61
|
+
* @see {@link DisTubeOptions|DisTubeOptions.customFilters}
|
|
62
|
+
*/
|
|
42
63
|
type FilterResolvable = string | Filter;
|
|
64
|
+
/**
|
|
65
|
+
* FFmpeg Filters
|
|
66
|
+
* ```
|
|
67
|
+
* {
|
|
68
|
+
* "Filter Name": "Filter Value",
|
|
69
|
+
* "bassboost": "bass=g=10"
|
|
70
|
+
* }
|
|
71
|
+
* ```
|
|
72
|
+
* @typedef {Object.<string, string>} Filters
|
|
73
|
+
* @see {@link defaultFilters}
|
|
74
|
+
*/
|
|
43
75
|
type Filters = Record<string, string>;
|
|
44
|
-
|
|
76
|
+
/**
|
|
77
|
+
* DisTube options.
|
|
78
|
+
* @typedef {Object} DisTubeOptions
|
|
79
|
+
* @prop {Array<CustomPlugin|ExtractorPlugin>} [plugins] DisTube plugins.
|
|
80
|
+
* @prop {boolean} [emitNewSongOnly=false] Whether or not emitting {@link DisTube#event:playSong} event
|
|
81
|
+
* when looping a song or next song is the same as the previous one
|
|
82
|
+
* @prop {boolean} [leaveOnEmpty=true] Whether or not leaving voice channel
|
|
83
|
+
* if the voice channel is empty after {@link DisTubeOptions}.emptyCooldown seconds.
|
|
84
|
+
* @prop {boolean} [leaveOnFinish=false] Whether or not leaving voice channel when the queue ends.
|
|
85
|
+
* @prop {boolean} [leaveOnStop=true] Whether or not leaving voice channel after using {@link DisTube#stop} function.
|
|
86
|
+
* @prop {boolean} [savePreviousSongs=true] Whether or not saving the previous songs of the queue
|
|
87
|
+
* and enable {@link DisTube#previous} method
|
|
88
|
+
* @prop {number} [searchSongs=0] Limit of search results emits in {@link DisTube#event:searchResult} event
|
|
89
|
+
* when {@link DisTube#play} method executed. If `searchSongs <= 1`, play the first result
|
|
90
|
+
* @prop {Cookie[]|string} [youtubeCookie] YouTube cookies. Guide: {@link https://distube.js.org/#/docs/DisTube/main/general/cookie YouTube Cookies}
|
|
91
|
+
* @prop {Filters} [customFilters] Override {@link defaultFilters} or add more ffmpeg filters.
|
|
92
|
+
* @prop {ytdl.getInfoOptions} [ytdlOptions] `ytdl-core` get info options
|
|
93
|
+
* @prop {number} [searchCooldown=60] Built-in search cooldown in seconds (When searchSongs is bigger than 0)
|
|
94
|
+
* @prop {number} [emptyCooldown=60] Built-in leave on empty cooldown in seconds (When leaveOnEmpty is true)
|
|
95
|
+
* @prop {boolean} [nsfw=false] Whether or not playing age-restricted content
|
|
96
|
+
* and disabling safe search in non-NSFW channel.
|
|
97
|
+
* @prop {boolean} [emitAddListWhenCreatingQueue=true] Whether or not emitting `addList` event when creating a new Queue
|
|
98
|
+
* @prop {boolean} [emitAddSongWhenCreatingQueue=true] Whether or not emitting `addSong` event when creating a new Queue
|
|
99
|
+
* @prop {boolean} [joinNewVoiceChannel=true] Whether or not joining the new voice channel
|
|
100
|
+
* when using {@link DisTube#play} method
|
|
101
|
+
* @prop {StreamType} [streamType=StreamType.OPUS] Decide the {@link DisTubeStream#type} will be used
|
|
102
|
+
* (Not the same as {@link DisTubeStream#type})
|
|
103
|
+
* @prop {boolean} [directLink=true] Whether or not playing a song with direct link
|
|
104
|
+
*/
|
|
105
|
+
type DisTubeOptions = {
|
|
45
106
|
plugins?: (CustomPlugin | ExtractorPlugin)[];
|
|
46
107
|
emitNewSongOnly?: boolean;
|
|
47
108
|
leaveOnFinish?: boolean;
|
|
@@ -51,17 +112,42 @@ interface DisTubeOptions {
|
|
|
51
112
|
savePreviousSongs?: boolean;
|
|
52
113
|
searchSongs?: number;
|
|
53
114
|
searchCooldown?: number;
|
|
54
|
-
youtubeCookie?: string;
|
|
55
|
-
youtubeIdentityToken?: string;
|
|
115
|
+
youtubeCookie?: Cookie[] | string;
|
|
56
116
|
customFilters?: Filters;
|
|
57
|
-
ytdlOptions?:
|
|
117
|
+
ytdlOptions?: ytdl__default.downloadOptions;
|
|
58
118
|
nsfw?: boolean;
|
|
59
119
|
emitAddSongWhenCreatingQueue?: boolean;
|
|
60
120
|
emitAddListWhenCreatingQueue?: boolean;
|
|
61
121
|
joinNewVoiceChannel?: boolean;
|
|
62
122
|
streamType?: StreamType;
|
|
63
123
|
directLink?: boolean;
|
|
64
|
-
}
|
|
124
|
+
};
|
|
125
|
+
/**
|
|
126
|
+
* Data that can be resolved to give a guild id string. This can be:
|
|
127
|
+
* - A guild id string | a guild {@link https://discord.js.org/#/docs/main/stable/class/Snowflake|Snowflake}
|
|
128
|
+
* - A {@link https://discord.js.org/#/docs/main/stable/class/Guild|Guild}
|
|
129
|
+
* - A {@link https://discord.js.org/#/docs/main/stable/class/Message|Message}
|
|
130
|
+
* - A {@link https://discord.js.org/#/docs/main/stable/class/BaseGuildVoiceChannel|BaseGuildVoiceChannel}
|
|
131
|
+
* - A {@link https://discord.js.org/#/docs/main/stable/class/BaseGuildTextChannel|BaseGuildTextChannel}
|
|
132
|
+
* - A {@link https://discord.js.org/#/docs/main/stable/class/VoiceState|VoiceState}
|
|
133
|
+
* - A {@link https://discord.js.org/#/docs/main/stable/class/GuildMember|GuildMember}
|
|
134
|
+
* - A {@link https://discord.js.org/#/docs/main/stable/class/Interaction|Interaction}
|
|
135
|
+
* - A {@link DisTubeVoice}
|
|
136
|
+
* - A {@link Queue}
|
|
137
|
+
* @typedef {
|
|
138
|
+
* Discord.Snowflake|
|
|
139
|
+
* Discord.Guild|
|
|
140
|
+
* Discord.Message|
|
|
141
|
+
* Discord.BaseGuildVoiceChannel|
|
|
142
|
+
* Discord.BaseGuildTextChannel|
|
|
143
|
+
* Discord.VoiceState|
|
|
144
|
+
* Discord.GuildMember|
|
|
145
|
+
* Discord.Interaction|
|
|
146
|
+
* DisTubeVoice|
|
|
147
|
+
* Queue|
|
|
148
|
+
* string
|
|
149
|
+
* } GuildIdResolvable
|
|
150
|
+
*/
|
|
65
151
|
type GuildIdResolvable = Queue | DisTubeVoice | Snowflake | Message | GuildTextBasedChannel | VoiceBasedChannel | VoiceState | Guild | GuildMember | Interaction | string;
|
|
66
152
|
interface OtherSongInfo {
|
|
67
153
|
src: string;
|
|
@@ -104,48 +190,132 @@ interface PlaylistInfo {
|
|
|
104
190
|
name?: string;
|
|
105
191
|
url?: string;
|
|
106
192
|
thumbnail?: string;
|
|
193
|
+
/** @deprecated */
|
|
107
194
|
title?: string;
|
|
195
|
+
/** @deprecated */
|
|
108
196
|
webpage_url?: string;
|
|
109
197
|
}
|
|
110
198
|
type RelatedSong = Omit<Song, "related">;
|
|
199
|
+
/**
|
|
200
|
+
* @typedef {Object} PlayHandlerOptions
|
|
201
|
+
* @prop {Discord.BaseGuildTextChannel} [options.textChannel] The default text channel of the queue
|
|
202
|
+
* @prop {boolean} [options.skip=false] Skip the playing song (if exists) and play the added playlist instantly
|
|
203
|
+
* @prop {number} [options.position=0] Position of the song/playlist to add to the queue,
|
|
204
|
+
* <= 0 to add to the end of the queue.
|
|
205
|
+
*/
|
|
111
206
|
type PlayHandlerOptions = {
|
|
112
207
|
skip?: boolean;
|
|
113
208
|
position?: number;
|
|
114
209
|
textChannel?: GuildTextBasedChannel;
|
|
115
210
|
};
|
|
211
|
+
/**
|
|
212
|
+
* @typedef {Object} PlayOptions
|
|
213
|
+
* @prop {Discord.GuildMember} [member] Requested user (default is your bot)
|
|
214
|
+
* @prop {Discord.BaseGuildTextChannel} [textChannel] Default {@link Queue#textChannel}
|
|
215
|
+
* @prop {boolean} [skip=false]
|
|
216
|
+
* Skip the playing song (if exists) and play the added song/playlist if `position` is 1.
|
|
217
|
+
* If `position` is defined and not equal to 1, it will skip to the next song instead of the added song
|
|
218
|
+
* @prop {number} [position=0] Position of the song/playlist to add to the queue,
|
|
219
|
+
* <= 0 to add to the end of the queue.
|
|
220
|
+
* @prop {Discord.Message} [message] Called message (For built-in search events. If this is a {@link https://developer.mozilla.org/en-US/docs/Glossary/Falsy|falsy value}, it will play the first result instead)
|
|
221
|
+
* @prop {*} [metadata] Optional metadata that can be attached to the song/playlist will be played,
|
|
222
|
+
* This is useful for identification purposes when the song/playlist is passed around in events.
|
|
223
|
+
* See {@link Song#metadata} or {@link Playlist#metadata}
|
|
224
|
+
*/
|
|
116
225
|
interface PlayOptions extends PlayHandlerOptions, ResolveOptions<any> {
|
|
117
226
|
message?: Message;
|
|
118
227
|
}
|
|
228
|
+
/**
|
|
229
|
+
* @typedef {Object} ResolveOptions
|
|
230
|
+
* @prop {Discord.GuildMember} [member] Requested user
|
|
231
|
+
* @prop {*} [metadata] Metadata
|
|
232
|
+
*/
|
|
119
233
|
interface ResolveOptions<T = unknown> {
|
|
120
234
|
member?: GuildMember;
|
|
121
235
|
metadata?: T;
|
|
122
236
|
}
|
|
237
|
+
/**
|
|
238
|
+
* @typedef {ResolveOptions} ResolvePlaylistOptions
|
|
239
|
+
* @prop {string} [source] Source of the playlist
|
|
240
|
+
*/
|
|
123
241
|
interface ResolvePlaylistOptions<T = unknown> extends ResolveOptions<T> {
|
|
124
242
|
source?: string;
|
|
125
243
|
}
|
|
244
|
+
/**
|
|
245
|
+
* @typedef {Object} CustomPlaylistOptions
|
|
246
|
+
* @prop {Discord.GuildMember} [member] A guild member creating the playlist
|
|
247
|
+
* @prop {Object} [properties] Additional properties such as `name`
|
|
248
|
+
* @prop {boolean} [parallel=true] Whether or not fetch the songs in parallel
|
|
249
|
+
* @prop {*} [metadata] Metadata
|
|
250
|
+
*/
|
|
126
251
|
interface CustomPlaylistOptions {
|
|
127
252
|
member?: GuildMember;
|
|
128
253
|
properties?: Record<string, any>;
|
|
129
254
|
parallel?: boolean;
|
|
130
255
|
metadata?: any;
|
|
131
256
|
}
|
|
257
|
+
/**
|
|
258
|
+
* The repeat mode of a {@link Queue}
|
|
259
|
+
* * `DISABLED` = 0
|
|
260
|
+
* * `SONG` = 1
|
|
261
|
+
* * `QUEUE` = 2
|
|
262
|
+
* @typedef {number} RepeatMode
|
|
263
|
+
*/
|
|
132
264
|
declare enum RepeatMode {
|
|
133
265
|
DISABLED = 0,
|
|
134
266
|
SONG = 1,
|
|
135
267
|
QUEUE = 2
|
|
136
268
|
}
|
|
269
|
+
/**
|
|
270
|
+
* All available plugin types:
|
|
271
|
+
* * `CUSTOM` = `"custom"`: {@link CustomPlugin}
|
|
272
|
+
* * `EXTRACTOR` = `"extractor"`: {@link ExtractorPlugin}
|
|
273
|
+
* @typedef {"custom"|"extractor"} PluginType
|
|
274
|
+
*/
|
|
137
275
|
declare enum PluginType {
|
|
138
276
|
CUSTOM = "custom",
|
|
139
277
|
EXTRACTOR = "extractor"
|
|
140
278
|
}
|
|
279
|
+
/**
|
|
280
|
+
* Search result types:
|
|
281
|
+
* * `VIDEO` = `"video"`
|
|
282
|
+
* * `PLAYLIST` = `"playlist"`
|
|
283
|
+
* @typedef {"video"|"playlist"} SearchResultType
|
|
284
|
+
*/
|
|
141
285
|
declare enum SearchResultType {
|
|
142
286
|
VIDEO = "video",
|
|
143
287
|
PLAYLIST = "playlist"
|
|
144
288
|
}
|
|
289
|
+
/**
|
|
290
|
+
* Stream types:
|
|
291
|
+
* * `OPUS` = `0` (Better quality, use more resources - **Recommended**)
|
|
292
|
+
* * `RAW` = `1` (Better performance, use less resources)
|
|
293
|
+
* @typedef {number} StreamType
|
|
294
|
+
* @type {StreamType}
|
|
295
|
+
*/
|
|
145
296
|
declare enum StreamType {
|
|
146
297
|
OPUS = 0,
|
|
147
298
|
RAW = 1
|
|
148
299
|
}
|
|
300
|
+
/**
|
|
301
|
+
* @typedef {Object} Events
|
|
302
|
+
* @prop {string} ERROR error
|
|
303
|
+
* @prop {string} ADD_LIST addList
|
|
304
|
+
* @prop {string} ADD_SONG addSong
|
|
305
|
+
* @prop {string} PLAY_SONG playSong
|
|
306
|
+
* @prop {string} FINISH_SONG finishSong
|
|
307
|
+
* @prop {string} EMPTY empty
|
|
308
|
+
* @prop {string} FINISH finish
|
|
309
|
+
* @prop {string} INIT_QUEUE initQueue
|
|
310
|
+
* @prop {string} NO_RELATED noRelated
|
|
311
|
+
* @prop {string} DISCONNECT disconnect
|
|
312
|
+
* @prop {string} DELETE_QUEUE deleteQueue
|
|
313
|
+
* @prop {string} SEARCH_CANCEL searchCancel
|
|
314
|
+
* @prop {string} SEARCH_NO_RESULT searchNoResult
|
|
315
|
+
* @prop {string} SEARCH_DONE searchDone
|
|
316
|
+
* @prop {string} SEARCH_INVALID_ANSWER searchInvalidAnswer
|
|
317
|
+
* @prop {string} SEARCH_RESULT searchResult
|
|
318
|
+
*/
|
|
149
319
|
declare enum Events {
|
|
150
320
|
ERROR = "error",
|
|
151
321
|
ADD_LIST = "addList",
|
|
@@ -165,6 +335,25 @@ declare enum Events {
|
|
|
165
335
|
SEARCH_RESULT = "searchResult"
|
|
166
336
|
}
|
|
167
337
|
|
|
338
|
+
/**
|
|
339
|
+
* Default DisTube audio filters.
|
|
340
|
+
* @typedef {Object} defaultFilters
|
|
341
|
+
* @prop {string} 3d 3d
|
|
342
|
+
* @prop {string} bassboost bassboost
|
|
343
|
+
* @prop {string} echo echo
|
|
344
|
+
* @prop {string} karaoke karaoke
|
|
345
|
+
* @prop {string} nightcore nightcore
|
|
346
|
+
* @prop {string} vaporwave vaporwave
|
|
347
|
+
* @prop {string} flanger flanger
|
|
348
|
+
* @prop {string} gate gate
|
|
349
|
+
* @prop {string} haas haas
|
|
350
|
+
* @prop {string} reverse reverse
|
|
351
|
+
* @prop {string} surround surround
|
|
352
|
+
* @prop {string} mcompand mcompand
|
|
353
|
+
* @prop {string} phaser phaser
|
|
354
|
+
* @prop {string} tremolo tremolo
|
|
355
|
+
* @prop {string} earwax earwax
|
|
356
|
+
*/
|
|
168
357
|
declare const defaultFilters: Filters;
|
|
169
358
|
declare const defaultOptions: {
|
|
170
359
|
plugins: never[];
|
|
@@ -240,14 +429,39 @@ declare class DisTubeError<T extends string> extends Error {
|
|
|
240
429
|
get code(): string;
|
|
241
430
|
}
|
|
242
431
|
|
|
432
|
+
/**
|
|
433
|
+
* Task queuing system
|
|
434
|
+
* @private
|
|
435
|
+
*/
|
|
243
436
|
declare class TaskQueue {
|
|
244
437
|
#private;
|
|
438
|
+
/**
|
|
439
|
+
* Waits for last task finished and queues a new task
|
|
440
|
+
* @param {boolean} [resolveInfo=false] Whether the task is a resolving info task
|
|
441
|
+
* @returns {Promise<void>}
|
|
442
|
+
*/
|
|
245
443
|
queuing(resolveInfo?: boolean): Promise<void>;
|
|
444
|
+
/**
|
|
445
|
+
* Removes the finished task and processes the next task
|
|
446
|
+
*/
|
|
246
447
|
resolve(): void;
|
|
448
|
+
/**
|
|
449
|
+
* The remaining number of tasks
|
|
450
|
+
* @type {number}
|
|
451
|
+
*/
|
|
247
452
|
get remaining(): number;
|
|
453
|
+
/**
|
|
454
|
+
* Whether or not having a resolving info task
|
|
455
|
+
* @type {boolean}
|
|
456
|
+
*/
|
|
248
457
|
get hasResolveTask(): boolean;
|
|
249
458
|
}
|
|
250
459
|
|
|
460
|
+
/**
|
|
461
|
+
* Class representing a playlist.
|
|
462
|
+
* @prop {string} source Playlist source
|
|
463
|
+
* @template T - The type for the metadata (if any) of the playlist
|
|
464
|
+
*/
|
|
251
465
|
declare class Playlist<T = unknown> implements PlaylistInfo {
|
|
252
466
|
#private;
|
|
253
467
|
source: string;
|
|
@@ -256,20 +470,49 @@ declare class Playlist<T = unknown> implements PlaylistInfo {
|
|
|
256
470
|
url?: string;
|
|
257
471
|
thumbnail?: string;
|
|
258
472
|
[x: string]: any;
|
|
473
|
+
/**
|
|
474
|
+
* Create a playlist
|
|
475
|
+
* @param {Song[]|PlaylistInfo} playlist Playlist
|
|
476
|
+
* @param {Object} [options] Optional options
|
|
477
|
+
* @param {Discord.GuildMember} [options.member] Requested user
|
|
478
|
+
* @param {Object} [options.properties] Custom properties
|
|
479
|
+
* @param {T} [options.metadata] Playlist metadata
|
|
480
|
+
*/
|
|
259
481
|
constructor(playlist: Song[] | PlaylistInfo, options?: {
|
|
260
482
|
member?: GuildMember;
|
|
261
483
|
properties?: Record<string, any>;
|
|
262
484
|
metadata?: T;
|
|
263
485
|
});
|
|
486
|
+
/**
|
|
487
|
+
* Playlist duration in second.
|
|
488
|
+
* @type {number}
|
|
489
|
+
*/
|
|
264
490
|
get duration(): number;
|
|
491
|
+
/**
|
|
492
|
+
* Formatted duration string `hh:mm:ss`.
|
|
493
|
+
* @type {string}
|
|
494
|
+
*/
|
|
265
495
|
get formattedDuration(): string;
|
|
496
|
+
/**
|
|
497
|
+
* User requested.
|
|
498
|
+
* @type {Discord.GuildMember?}
|
|
499
|
+
*/
|
|
266
500
|
get member(): GuildMember | undefined;
|
|
267
501
|
set member(member: GuildMember | undefined);
|
|
502
|
+
/**
|
|
503
|
+
* User requested.
|
|
504
|
+
* @type {Discord.User?}
|
|
505
|
+
*/
|
|
268
506
|
get user(): discord_js.User | undefined;
|
|
269
507
|
get metadata(): T;
|
|
270
508
|
set metadata(metadata: T);
|
|
271
509
|
}
|
|
272
510
|
|
|
511
|
+
/**
|
|
512
|
+
* A abstract class representing a search result.
|
|
513
|
+
* @abstract
|
|
514
|
+
* @private
|
|
515
|
+
*/
|
|
273
516
|
declare abstract class ISearchResult {
|
|
274
517
|
source: "youtube";
|
|
275
518
|
abstract type: SearchResultType;
|
|
@@ -280,8 +523,16 @@ declare abstract class ISearchResult {
|
|
|
280
523
|
name?: string;
|
|
281
524
|
url?: string;
|
|
282
525
|
};
|
|
526
|
+
/**
|
|
527
|
+
* Create a search result
|
|
528
|
+
* @param {Object} info ytsr result
|
|
529
|
+
*/
|
|
283
530
|
constructor(info: Video | Playlist$1);
|
|
284
531
|
}
|
|
532
|
+
/**
|
|
533
|
+
* A class representing a video search result.
|
|
534
|
+
* @extends ISearchResult
|
|
535
|
+
*/
|
|
285
536
|
declare class SearchResultVideo extends ISearchResult {
|
|
286
537
|
type: SearchResultType.VIDEO;
|
|
287
538
|
views: number;
|
|
@@ -291,17 +542,35 @@ declare class SearchResultVideo extends ISearchResult {
|
|
|
291
542
|
thumbnail: string;
|
|
292
543
|
constructor(info: Video);
|
|
293
544
|
}
|
|
545
|
+
/**
|
|
546
|
+
* A video or playlist search result
|
|
547
|
+
* @typedef {SearchResultVideo|SearchResultPlaylist} SearchResult
|
|
548
|
+
*/
|
|
294
549
|
type SearchResult = SearchResultVideo | SearchResultPlaylist;
|
|
550
|
+
/**
|
|
551
|
+
* A class representing a playlist search result.
|
|
552
|
+
* @extends ISearchResult
|
|
553
|
+
*/
|
|
295
554
|
declare class SearchResultPlaylist extends ISearchResult {
|
|
296
555
|
type: SearchResultType.PLAYLIST;
|
|
297
556
|
length: number;
|
|
298
557
|
constructor(info: Playlist$1);
|
|
299
558
|
}
|
|
300
559
|
|
|
560
|
+
/**
|
|
561
|
+
* Class representing a song.
|
|
562
|
+
*
|
|
563
|
+
* <info>If {@link Song} is added from a YouTube {@link SearchResult} or {@link Playlist},
|
|
564
|
+
* some info will be missing to save your resources. It will be filled when emitting {@link DisTube#playSong} event.
|
|
565
|
+
*
|
|
566
|
+
* Missing info: {@link Song#likes}, {@link Song#dislikes}, {@link Song#streamURL},
|
|
567
|
+
* {@link Song#related}, {@link Song#chapters}, {@link Song#age_restricted}</info>
|
|
568
|
+
* @template T - The type for the metadata (if any) of the song
|
|
569
|
+
*/
|
|
301
570
|
declare class Song<T = unknown> {
|
|
302
571
|
#private;
|
|
303
572
|
source: string;
|
|
304
|
-
formats?:
|
|
573
|
+
formats?: ytdl__default.videoFormat[];
|
|
305
574
|
id?: string;
|
|
306
575
|
name?: string;
|
|
307
576
|
isLive: boolean;
|
|
@@ -321,34 +590,102 @@ declare class Song<T = unknown> {
|
|
|
321
590
|
age_restricted: boolean;
|
|
322
591
|
chapters: Chapter[];
|
|
323
592
|
reposts: number;
|
|
324
|
-
|
|
593
|
+
/**
|
|
594
|
+
* Create a Song
|
|
595
|
+
* @param {ytdl.videoInfo|SearchResult|OtherSongInfo} info Raw info
|
|
596
|
+
* @param {Object} [options] Optional options
|
|
597
|
+
* @param {Discord.GuildMember} [options.member] Requested user
|
|
598
|
+
* @param {string} [options.source="youtube"] Song source
|
|
599
|
+
* @param {T} [options.metadata] Song metadata
|
|
600
|
+
*/
|
|
601
|
+
constructor(info: ytdl__default.videoInfo | SearchResult | OtherSongInfo | ytdl__default.relatedVideo | RelatedSong | ytpl.result["items"][number], options?: {
|
|
325
602
|
member?: GuildMember;
|
|
326
603
|
source?: string;
|
|
327
604
|
metadata?: T;
|
|
328
605
|
});
|
|
329
|
-
_patchYouTube(i:
|
|
606
|
+
_patchYouTube(i: ytdl__default.videoInfo | SearchResult): void;
|
|
607
|
+
/**
|
|
608
|
+
* Patch data from other source
|
|
609
|
+
* @param {OtherSongInfo} info Video info
|
|
610
|
+
* @private
|
|
611
|
+
*/
|
|
330
612
|
_patchOther(info: OtherSongInfo): void;
|
|
613
|
+
/**
|
|
614
|
+
* The playlist added this song
|
|
615
|
+
* @type {Playlist?}
|
|
616
|
+
*/
|
|
331
617
|
get playlist(): Playlist | undefined;
|
|
332
618
|
set playlist(playlist: Playlist | undefined);
|
|
619
|
+
/**
|
|
620
|
+
* User requested.
|
|
621
|
+
* @type {Discord.GuildMember?}
|
|
622
|
+
*/
|
|
333
623
|
get member(): GuildMember | undefined;
|
|
334
624
|
set member(member: GuildMember | undefined);
|
|
625
|
+
/**
|
|
626
|
+
* User requested.
|
|
627
|
+
* @type {Discord.User?}
|
|
628
|
+
*/
|
|
335
629
|
get user(): discord_js.User | undefined;
|
|
336
630
|
get metadata(): T;
|
|
337
631
|
set metadata(metadata: T);
|
|
338
632
|
}
|
|
339
633
|
|
|
634
|
+
/**
|
|
635
|
+
* @private
|
|
636
|
+
* @abstract
|
|
637
|
+
*/
|
|
340
638
|
declare abstract class DisTubeBase {
|
|
341
639
|
distube: DisTube;
|
|
342
640
|
constructor(distube: DisTube);
|
|
641
|
+
/**
|
|
642
|
+
* Emit the {@link DisTube} of this base
|
|
643
|
+
* @param {string} eventName Event name
|
|
644
|
+
* @param {...any} args arguments
|
|
645
|
+
* @returns {boolean}
|
|
646
|
+
*/
|
|
343
647
|
emit(eventName: keyof DisTubeEvents, ...args: any): boolean;
|
|
648
|
+
/**
|
|
649
|
+
* Emit error event
|
|
650
|
+
* @param {Error} error error
|
|
651
|
+
* @param {Discord.BaseGuildTextChannel} [channel] Text channel where the error is encountered.
|
|
652
|
+
*/
|
|
344
653
|
emitError(error: Error, channel?: GuildTextBasedChannel): void;
|
|
654
|
+
/**
|
|
655
|
+
* The queue manager
|
|
656
|
+
* @type {QueueManager}
|
|
657
|
+
* @readonly
|
|
658
|
+
*/
|
|
345
659
|
get queues(): QueueManager;
|
|
660
|
+
/**
|
|
661
|
+
* The voice manager
|
|
662
|
+
* @type {DisTubeVoiceManager}
|
|
663
|
+
* @readonly
|
|
664
|
+
*/
|
|
346
665
|
get voices(): DisTubeVoiceManager;
|
|
666
|
+
/**
|
|
667
|
+
* Discord.js client
|
|
668
|
+
* @type {Discord.Client}
|
|
669
|
+
* @readonly
|
|
670
|
+
*/
|
|
347
671
|
get client(): Client;
|
|
672
|
+
/**
|
|
673
|
+
* DisTube options
|
|
674
|
+
* @type {DisTubeOptions}
|
|
675
|
+
* @readonly
|
|
676
|
+
*/
|
|
348
677
|
get options(): Options;
|
|
678
|
+
/**
|
|
679
|
+
* DisTube handler
|
|
680
|
+
* @type {DisTubeHandler}
|
|
681
|
+
* @readonly
|
|
682
|
+
*/
|
|
349
683
|
get handler(): DisTubeHandler;
|
|
350
684
|
}
|
|
351
685
|
|
|
686
|
+
/**
|
|
687
|
+
* Create a voice connection to the voice channel
|
|
688
|
+
*/
|
|
352
689
|
declare class DisTubeVoice extends TypedEmitter<DisTubeVoiceEvents> {
|
|
353
690
|
#private;
|
|
354
691
|
readonly id: Snowflake;
|
|
@@ -359,58 +696,181 @@ declare class DisTubeVoice extends TypedEmitter<DisTubeVoiceEvents> {
|
|
|
359
696
|
emittedError: boolean;
|
|
360
697
|
isDisconnected: boolean;
|
|
361
698
|
constructor(voiceManager: DisTubeVoiceManager, channel: VoiceBasedChannel);
|
|
699
|
+
/**
|
|
700
|
+
* The voice channel id the bot is in
|
|
701
|
+
* @type {Snowflake?}
|
|
702
|
+
*/
|
|
362
703
|
get channelId(): string | undefined;
|
|
363
704
|
get channel(): VoiceBasedChannel;
|
|
364
705
|
set channel(channel: VoiceBasedChannel);
|
|
706
|
+
/**
|
|
707
|
+
* Join a voice channel with this connection
|
|
708
|
+
* @param {Discord.BaseGuildVoiceChannel} [channel] A voice channel
|
|
709
|
+
* @returns {Promise<DisTubeVoice>}
|
|
710
|
+
*/
|
|
365
711
|
join(channel?: VoiceBasedChannel): Promise<DisTubeVoice>;
|
|
712
|
+
/**
|
|
713
|
+
* Leave the voice channel of this connection
|
|
714
|
+
* @param {Error} [error] Optional, an error to emit with 'error' event.
|
|
715
|
+
*/
|
|
366
716
|
leave(error?: Error): void;
|
|
717
|
+
/**
|
|
718
|
+
* Stop the playing stream
|
|
719
|
+
* @param {boolean} [force=false] If true, will force the {@link DisTubeVoice#audioPlayer} to enter the Idle state
|
|
720
|
+
* even if the {@link DisTubeVoice#audioResource} has silence padding frames.
|
|
721
|
+
* @private
|
|
722
|
+
*/
|
|
367
723
|
stop(force?: boolean): void;
|
|
724
|
+
/**
|
|
725
|
+
* Play a readable stream
|
|
726
|
+
* @private
|
|
727
|
+
* @param {DisTubeStream} stream Readable stream
|
|
728
|
+
*/
|
|
368
729
|
play(stream: DisTubeStream): void;
|
|
369
730
|
set volume(volume: number);
|
|
370
731
|
get volume(): number;
|
|
732
|
+
/**
|
|
733
|
+
* Playback duration of the audio resource in seconds
|
|
734
|
+
* @type {number}
|
|
735
|
+
*/
|
|
371
736
|
get playbackDuration(): number;
|
|
372
737
|
pause(): void;
|
|
373
738
|
unpause(): void;
|
|
739
|
+
/**
|
|
740
|
+
* Whether the bot is self-deafened
|
|
741
|
+
* @type {boolean}
|
|
742
|
+
*/
|
|
374
743
|
get selfDeaf(): boolean;
|
|
744
|
+
/**
|
|
745
|
+
* Whether the bot is self-muted
|
|
746
|
+
* @type {boolean}
|
|
747
|
+
*/
|
|
375
748
|
get selfMute(): boolean;
|
|
749
|
+
/**
|
|
750
|
+
* Self-deafens/undeafens the bot.
|
|
751
|
+
* @param {boolean} selfDeaf Whether or not the bot should be self-deafened
|
|
752
|
+
* @returns {boolean} true if the voice state was successfully updated, otherwise false
|
|
753
|
+
*/
|
|
376
754
|
setSelfDeaf(selfDeaf: boolean): boolean;
|
|
755
|
+
/**
|
|
756
|
+
* Self-mutes/unmutes the bot.
|
|
757
|
+
* @param {boolean} selfMute Whether or not the bot should be self-muted
|
|
758
|
+
* @returns {boolean} true if the voice state was successfully updated, otherwise false
|
|
759
|
+
*/
|
|
377
760
|
setSelfMute(selfMute: boolean): boolean;
|
|
761
|
+
/**
|
|
762
|
+
* The voice state of this connection
|
|
763
|
+
* @type {Discord.VoiceState?}
|
|
764
|
+
*/
|
|
378
765
|
get voiceState(): VoiceState | undefined;
|
|
379
766
|
}
|
|
380
767
|
|
|
381
768
|
interface StreamOptions {
|
|
382
769
|
seek?: number;
|
|
383
770
|
ffmpegArgs?: string[];
|
|
384
|
-
isLive?: boolean;
|
|
385
771
|
type?: StreamType;
|
|
386
772
|
}
|
|
387
|
-
declare const chooseBestVideoFormat: (
|
|
773
|
+
declare const chooseBestVideoFormat: ({ duration, formats, isLive }: Song) => ytdl.videoFormat | undefined;
|
|
774
|
+
/**
|
|
775
|
+
* Create a stream to play with {@link DisTubeVoice}
|
|
776
|
+
* @private
|
|
777
|
+
*/
|
|
388
778
|
declare class DisTubeStream {
|
|
389
|
-
|
|
779
|
+
/**
|
|
780
|
+
* Create a stream from ytdl video formats
|
|
781
|
+
* @param {Song} song A YouTube Song
|
|
782
|
+
* @param {StreamOptions} options options
|
|
783
|
+
* @returns {DisTubeStream}
|
|
784
|
+
* @private
|
|
785
|
+
*/
|
|
786
|
+
static YouTube(song: Song, options?: StreamOptions): DisTubeStream;
|
|
787
|
+
/**
|
|
788
|
+
* Create a stream from a stream url
|
|
789
|
+
* @param {string} url stream url
|
|
790
|
+
* @param {StreamOptions} options options
|
|
791
|
+
* @returns {DisTubeStream}
|
|
792
|
+
* @private
|
|
793
|
+
*/
|
|
390
794
|
static DirectLink(url: string, options?: StreamOptions): DisTubeStream;
|
|
391
795
|
type: StreamType$1;
|
|
392
796
|
stream: FFmpeg;
|
|
393
797
|
url: string;
|
|
798
|
+
/**
|
|
799
|
+
* Create a DisTubeStream to play with {@link DisTubeVoice}
|
|
800
|
+
* @param {string} url Stream URL
|
|
801
|
+
* @param {StreamOptions} options Stream options
|
|
802
|
+
* @private
|
|
803
|
+
*/
|
|
394
804
|
constructor(url: string, options: StreamOptions);
|
|
395
805
|
}
|
|
396
806
|
|
|
807
|
+
/**
|
|
808
|
+
* DisTube's Handler
|
|
809
|
+
* @extends DisTubeBase
|
|
810
|
+
* @private
|
|
811
|
+
*/
|
|
397
812
|
declare class DisTubeHandler extends DisTubeBase {
|
|
813
|
+
#private;
|
|
398
814
|
constructor(distube: DisTube);
|
|
399
|
-
get ytdlOptions():
|
|
400
|
-
|
|
815
|
+
get ytdlOptions(): ytdl__default.getInfoOptions;
|
|
816
|
+
get ytCookie(): string;
|
|
817
|
+
/**
|
|
818
|
+
* @param {string} url url
|
|
819
|
+
* @param {boolean} [basic=false] getBasicInfo?
|
|
820
|
+
* @returns {Promise<ytdl.videoInfo>}
|
|
821
|
+
*/
|
|
822
|
+
getYouTubeInfo(url: string, basic?: boolean): Promise<ytdl__default.videoInfo>;
|
|
401
823
|
resolve<T = unknown>(song: Song<T>, options?: Omit<ResolveOptions, "metadata">): Promise<Song<T>>;
|
|
402
824
|
resolve<T = unknown>(song: Playlist<T>, options?: Omit<ResolveOptions, "metadata">): Promise<Playlist<T>>;
|
|
403
825
|
resolve<T = unknown>(song: string | SearchResult, options?: ResolveOptions<T>): Promise<Song<T> | Playlist<T>>;
|
|
404
|
-
resolve<T = unknown>(song:
|
|
826
|
+
resolve<T = unknown>(song: ytdl__default.videoInfo | OtherSongInfo | ytdl__default.relatedVideo, options?: ResolveOptions<T>): Promise<Song<T>>;
|
|
405
827
|
resolve<T = unknown>(song: Playlist, options: ResolveOptions<T>): Promise<Playlist<T>>;
|
|
406
|
-
resolve(song: string |
|
|
828
|
+
resolve(song: string | ytdl__default.videoInfo | Song | Playlist | SearchResult | OtherSongInfo | ytdl__default.relatedVideo, options?: ResolveOptions): Promise<Song | Playlist>;
|
|
407
829
|
resolvePlaylist<T = unknown>(playlist: Playlist<T> | Song<T>[] | string, options?: Omit<ResolvePlaylistOptions, "metadata">): Promise<Playlist<T>>;
|
|
408
830
|
resolvePlaylist<T = undefined>(playlist: Playlist | Song[] | string, options: ResolvePlaylistOptions<T>): Promise<Playlist<T>>;
|
|
409
831
|
resolvePlaylist(playlist: Playlist | Song[] | string, options?: ResolvePlaylistOptions): Promise<Playlist>;
|
|
832
|
+
/**
|
|
833
|
+
* Search for a song, fire {@link DisTube#event:error} if not found.
|
|
834
|
+
* @param {Discord.Message} message The original message from an user
|
|
835
|
+
* @param {string} query The query string
|
|
836
|
+
* @returns {Promise<SearchResult?>} Song info
|
|
837
|
+
* @throws {DisTubeError}
|
|
838
|
+
*/
|
|
410
839
|
searchSong(message: Message<true>, query: string): Promise<SearchResult | null>;
|
|
840
|
+
/**
|
|
841
|
+
* Create a message collector for selecting search results.
|
|
842
|
+
*
|
|
843
|
+
* Needed events: {@link DisTube#event:searchResult}, {@link DisTube#event:searchCancel},
|
|
844
|
+
* {@link DisTube#event:searchInvalidAnswer}, {@link DisTube#event:searchDone}.
|
|
845
|
+
* @param {Discord.Message} message The original message from an user
|
|
846
|
+
* @param {Array<SearchResult|Song|Playlist>} results The search results
|
|
847
|
+
* @param {string?} [query] The query string
|
|
848
|
+
* @returns {Promise<SearchResult|Song|Playlist|null>} Selected result
|
|
849
|
+
* @throws {DisTubeError}
|
|
850
|
+
*/
|
|
411
851
|
createSearchMessageCollector<R extends SearchResult | Song | Playlist>(message: Message<true>, results: Array<R>, query?: string): Promise<R | null>;
|
|
852
|
+
/**
|
|
853
|
+
* Play or add a {@link Playlist} to the queue.
|
|
854
|
+
* @param {Discord.BaseGuildVoiceChannel} voiceChannel A voice channel
|
|
855
|
+
* @param {Playlist|string} playlist A YouTube playlist url | a Playlist
|
|
856
|
+
* @param {PlayHandlerOptions} [options] Optional options
|
|
857
|
+
* @returns {Promise<void>}
|
|
858
|
+
* @throws {DisTubeError}
|
|
859
|
+
*/
|
|
412
860
|
playPlaylist(voiceChannel: VoiceBasedChannel, playlist: Playlist, options?: PlayHandlerOptions): Promise<void>;
|
|
861
|
+
/**
|
|
862
|
+
* Play or add a {@link Song} to the queue.
|
|
863
|
+
* @param {Discord.BaseGuildVoiceChannel} voiceChannel A voice channel
|
|
864
|
+
* @param {Song} song A YouTube playlist url | a Playlist
|
|
865
|
+
* @param {PlayHandlerOptions} [options] Optional options
|
|
866
|
+
* @returns {Promise<void>}
|
|
867
|
+
* @throws {DisTubeError}
|
|
868
|
+
*/
|
|
413
869
|
playSong(voiceChannel: VoiceBasedChannel, song: Song, options?: PlayHandlerOptions): Promise<void>;
|
|
870
|
+
/**
|
|
871
|
+
* Get {@link Song}'s stream info and attach it to the song.
|
|
872
|
+
* @param {Song} song A Song
|
|
873
|
+
*/
|
|
414
874
|
attachStreamInfo(song: Song): Promise<void>;
|
|
415
875
|
}
|
|
416
876
|
|
|
@@ -425,10 +885,9 @@ declare class Options {
|
|
|
425
885
|
savePreviousSongs: boolean;
|
|
426
886
|
searchSongs: number;
|
|
427
887
|
searchCooldown: number;
|
|
428
|
-
youtubeCookie?: string;
|
|
429
|
-
youtubeIdentityToken?: string;
|
|
888
|
+
youtubeCookie?: Cookie[] | string;
|
|
430
889
|
customFilters?: Filters;
|
|
431
|
-
ytdlOptions:
|
|
890
|
+
ytdlOptions: ytdl__default.getInfoOptions;
|
|
432
891
|
nsfw: boolean;
|
|
433
892
|
emitAddSongWhenCreatingQueue: boolean;
|
|
434
893
|
emitAddListWhenCreatingQueue: boolean;
|
|
@@ -438,11 +897,32 @@ declare class Options {
|
|
|
438
897
|
constructor(options: DisTubeOptions);
|
|
439
898
|
}
|
|
440
899
|
|
|
900
|
+
/**
|
|
901
|
+
* Manages the collection of a data model.
|
|
902
|
+
* @abstract
|
|
903
|
+
* @private
|
|
904
|
+
* @extends DisTubeBase
|
|
905
|
+
*/
|
|
441
906
|
declare abstract class BaseManager<V> extends DisTubeBase {
|
|
907
|
+
/**
|
|
908
|
+
* The collection of items for this manager.
|
|
909
|
+
* @type {Collection}
|
|
910
|
+
* @name BaseManager#collection
|
|
911
|
+
*/
|
|
442
912
|
collection: Collection<string, V>;
|
|
913
|
+
/**
|
|
914
|
+
* The size of the collection.
|
|
915
|
+
* @type {number}
|
|
916
|
+
*/
|
|
443
917
|
get size(): number;
|
|
444
918
|
}
|
|
445
919
|
|
|
920
|
+
/**
|
|
921
|
+
* Manages the collection of a data model paired with a guild id.
|
|
922
|
+
* @abstract
|
|
923
|
+
* @private
|
|
924
|
+
* @extends BaseManager
|
|
925
|
+
*/
|
|
446
926
|
declare abstract class GuildIdManager<V> extends BaseManager<V> {
|
|
447
927
|
add(idOrInstance: GuildIdResolvable, data: V): this | _discordjs_collection.Collection<string, V>;
|
|
448
928
|
get(idOrInstance: GuildIdResolvable): V | undefined;
|
|
@@ -450,34 +930,141 @@ declare abstract class GuildIdManager<V> extends BaseManager<V> {
|
|
|
450
930
|
has(idOrInstance: GuildIdResolvable): boolean;
|
|
451
931
|
}
|
|
452
932
|
|
|
933
|
+
/**
|
|
934
|
+
* Manages voice connections for {@link DisTube}
|
|
935
|
+
* @extends BaseManager
|
|
936
|
+
*/
|
|
453
937
|
declare class DisTubeVoiceManager extends GuildIdManager<DisTubeVoice> {
|
|
938
|
+
/**
|
|
939
|
+
* Get a {@link DisTubeVoice}.
|
|
940
|
+
* @method get
|
|
941
|
+
* @memberof DisTubeVoiceManager#
|
|
942
|
+
* @param {GuildIdResolvable} guild The queue resolvable to resolve
|
|
943
|
+
* @returns {DisTubeVoice?}
|
|
944
|
+
*/
|
|
945
|
+
/**
|
|
946
|
+
* Collection of {@link DisTubeVoice}.
|
|
947
|
+
* @name DisTubeVoiceManager#collection
|
|
948
|
+
* @type {Discord.Collection<string, DisTubeVoice>}
|
|
949
|
+
*/
|
|
950
|
+
/**
|
|
951
|
+
* Create a {@link DisTubeVoice}
|
|
952
|
+
* @param {Discord.BaseGuildVoiceChannel} channel A voice channel to join
|
|
953
|
+
* @returns {DisTubeVoice}
|
|
954
|
+
* @private
|
|
955
|
+
*/
|
|
454
956
|
create(channel: VoiceBasedChannel): DisTubeVoice;
|
|
957
|
+
/**
|
|
958
|
+
* Join a voice channel
|
|
959
|
+
* @param {Discord.BaseGuildVoiceChannel} channel A voice channel to join
|
|
960
|
+
* @returns {Promise<DisTubeVoice>}
|
|
961
|
+
*/
|
|
455
962
|
join(channel: VoiceBasedChannel): Promise<DisTubeVoice>;
|
|
963
|
+
/**
|
|
964
|
+
* Leave the connected voice channel in a guild
|
|
965
|
+
* @param {GuildIdResolvable} guild Queue Resolvable
|
|
966
|
+
*/
|
|
456
967
|
leave(guild: GuildIdResolvable): void;
|
|
457
968
|
}
|
|
458
969
|
|
|
970
|
+
/**
|
|
971
|
+
* Manage filters of a playing {@link Queue}
|
|
972
|
+
* @extends {BaseManager}
|
|
973
|
+
*/
|
|
459
974
|
declare class FilterManager extends BaseManager<Filter> {
|
|
460
975
|
#private;
|
|
976
|
+
/**
|
|
977
|
+
* Collection of {@link Filter}.
|
|
978
|
+
* @name FilterManager#collection
|
|
979
|
+
* @type {Discord.Collection<string, DisTubeVoice>}
|
|
980
|
+
*/
|
|
461
981
|
queue: Queue;
|
|
462
982
|
constructor(queue: Queue);
|
|
983
|
+
/**
|
|
984
|
+
* Enable a filter or multiple filters to the manager
|
|
985
|
+
* @param {FilterResolvable|FilterResolvable[]} filterOrFilters The filter or filters to enable
|
|
986
|
+
* @param {boolean} [override=false] Wether or not override the applied filter with new filter value
|
|
987
|
+
* @returns {FilterManager}
|
|
988
|
+
*/
|
|
463
989
|
add(filterOrFilters: FilterResolvable | FilterResolvable[], override?: boolean): this;
|
|
990
|
+
/**
|
|
991
|
+
* Clear enabled filters of the manager
|
|
992
|
+
* @returns {FilterManager}
|
|
993
|
+
*/
|
|
464
994
|
clear(): this;
|
|
995
|
+
/**
|
|
996
|
+
* Set the filters applied to the manager
|
|
997
|
+
* @param {FilterResolvable[]} filters The filters to apply
|
|
998
|
+
* @returns {FilterManager}
|
|
999
|
+
*/
|
|
465
1000
|
set(filters: FilterResolvable[]): this;
|
|
1001
|
+
/**
|
|
1002
|
+
* Disable a filter or multiple filters
|
|
1003
|
+
* @param {FilterResolvable|FilterResolvable[]} filterOrFilters The filter or filters to disable
|
|
1004
|
+
* @returns {FilterManager}
|
|
1005
|
+
*/
|
|
466
1006
|
remove(filterOrFilters: FilterResolvable | FilterResolvable[]): this;
|
|
1007
|
+
/**
|
|
1008
|
+
* Check whether a filter enabled or not
|
|
1009
|
+
* @param {FilterResolvable} filter The filter to check
|
|
1010
|
+
* @returns {boolean}
|
|
1011
|
+
*/
|
|
467
1012
|
has(filter: FilterResolvable): boolean;
|
|
1013
|
+
/**
|
|
1014
|
+
* Array of enabled filter names
|
|
1015
|
+
* @type {Array<string>}
|
|
1016
|
+
* @readonly
|
|
1017
|
+
*/
|
|
468
1018
|
get names(): string[];
|
|
1019
|
+
/**
|
|
1020
|
+
* Array of enabled filters
|
|
1021
|
+
* @type {Array<Filter>}
|
|
1022
|
+
* @readonly
|
|
1023
|
+
*/
|
|
469
1024
|
get values(): Filter[];
|
|
470
1025
|
get ffmpegArgs(): string[];
|
|
471
1026
|
toString(): string;
|
|
472
1027
|
}
|
|
473
1028
|
|
|
1029
|
+
/**
|
|
1030
|
+
* Queue manager
|
|
1031
|
+
* @extends GuildIdManager
|
|
1032
|
+
*/
|
|
474
1033
|
declare class QueueManager extends GuildIdManager<Queue> {
|
|
475
1034
|
#private;
|
|
1035
|
+
/**
|
|
1036
|
+
* Collection of {@link Queue}.
|
|
1037
|
+
* @name QueueManager#collection
|
|
1038
|
+
* @type {Discord.Collection<string, Queue>}
|
|
1039
|
+
*/
|
|
1040
|
+
/**
|
|
1041
|
+
* Create a {@link Queue}
|
|
1042
|
+
* @private
|
|
1043
|
+
* @param {Discord.BaseGuildVoiceChannel} channel A voice channel
|
|
1044
|
+
* @param {Song|Song[]} song First song
|
|
1045
|
+
* @param {Discord.BaseGuildTextChannel} textChannel Default text channel
|
|
1046
|
+
* @returns {Promise<Queue|true>} Returns `true` if encounter an error
|
|
1047
|
+
*/
|
|
476
1048
|
create(channel: VoiceBasedChannel, song: Song[] | Song, textChannel?: GuildTextBasedChannel): Promise<Queue | true>;
|
|
1049
|
+
/**
|
|
1050
|
+
* Create a ytdl stream
|
|
1051
|
+
* @param {Queue} queue Queue
|
|
1052
|
+
* @returns {DisTubeStream}
|
|
1053
|
+
*/
|
|
477
1054
|
createStream(queue: Queue): DisTubeStream;
|
|
1055
|
+
/**
|
|
1056
|
+
* Play a song on voice connection
|
|
1057
|
+
* @private
|
|
1058
|
+
* @param {Queue} queue The guild queue
|
|
1059
|
+
* @returns {Promise<boolean>} error?
|
|
1060
|
+
*/
|
|
478
1061
|
playSong(queue: Queue): Promise<boolean>;
|
|
479
1062
|
}
|
|
480
1063
|
|
|
1064
|
+
/**
|
|
1065
|
+
* Represents a queue.
|
|
1066
|
+
* @extends DisTubeBase
|
|
1067
|
+
*/
|
|
481
1068
|
declare class Queue extends DisTubeBase {
|
|
482
1069
|
#private;
|
|
483
1070
|
readonly id: Snowflake;
|
|
@@ -496,53 +1083,240 @@ declare class Queue extends DisTubeBase {
|
|
|
496
1083
|
_emptyTimeout?: NodeJS.Timeout;
|
|
497
1084
|
_taskQueue: TaskQueue;
|
|
498
1085
|
_listeners?: DisTubeVoiceEvents;
|
|
1086
|
+
/**
|
|
1087
|
+
* Create a queue for the guild
|
|
1088
|
+
* @param {DisTube} distube DisTube
|
|
1089
|
+
* @param {DisTubeVoice} voice Voice connection
|
|
1090
|
+
* @param {Song|Song[]} song First song(s)
|
|
1091
|
+
* @param {Discord.BaseGuildTextChannel?} textChannel Default text channel
|
|
1092
|
+
*/
|
|
499
1093
|
constructor(distube: DisTube, voice: DisTubeVoice, song: Song | Song[], textChannel?: GuildTextBasedChannel);
|
|
1094
|
+
/**
|
|
1095
|
+
* The client user as a `GuildMember` of this queue's guild
|
|
1096
|
+
* @type {Discord.GuildMember?}
|
|
1097
|
+
*/
|
|
500
1098
|
get clientMember(): discord_js.GuildMember | undefined;
|
|
1099
|
+
/**
|
|
1100
|
+
* The filter manager of the queue
|
|
1101
|
+
* @type {FilterManager}
|
|
1102
|
+
* @readonly
|
|
1103
|
+
*/
|
|
501
1104
|
get filters(): FilterManager;
|
|
1105
|
+
/**
|
|
1106
|
+
* Formatted duration string.
|
|
1107
|
+
* @type {string}
|
|
1108
|
+
* @readonly
|
|
1109
|
+
*/
|
|
502
1110
|
get formattedDuration(): string;
|
|
1111
|
+
/**
|
|
1112
|
+
* Queue's duration.
|
|
1113
|
+
* @type {number}
|
|
1114
|
+
* @readonly
|
|
1115
|
+
*/
|
|
503
1116
|
get duration(): number;
|
|
1117
|
+
/**
|
|
1118
|
+
* What time in the song is playing (in seconds).
|
|
1119
|
+
* @type {number}
|
|
1120
|
+
* @readonly
|
|
1121
|
+
*/
|
|
504
1122
|
get currentTime(): number;
|
|
1123
|
+
/**
|
|
1124
|
+
* Formatted {@link Queue#currentTime} string.
|
|
1125
|
+
* @type {string}
|
|
1126
|
+
* @readonly
|
|
1127
|
+
*/
|
|
505
1128
|
get formattedCurrentTime(): string;
|
|
1129
|
+
/**
|
|
1130
|
+
* The voice channel playing in.
|
|
1131
|
+
* @type {Discord.VoiceChannel|Discord.StageChannel|null}
|
|
1132
|
+
* @readonly
|
|
1133
|
+
*/
|
|
506
1134
|
get voiceChannel(): discord_js.VoiceBasedChannel | null;
|
|
507
1135
|
get volume(): number;
|
|
508
1136
|
set volume(value: number);
|
|
1137
|
+
/**
|
|
1138
|
+
* @private
|
|
1139
|
+
* Add a Song or an array of Song to the queue
|
|
1140
|
+
* @param {Song|Song[]} song Song to add
|
|
1141
|
+
* @param {number} [position=0] Position to add, <= 0 to add to the end of the queue
|
|
1142
|
+
* @throws {Error}
|
|
1143
|
+
* @returns {Queue} The guild queue
|
|
1144
|
+
*/
|
|
509
1145
|
addToQueue(song: Song | Song[], position?: number): Queue;
|
|
1146
|
+
/**
|
|
1147
|
+
* Pause the guild stream
|
|
1148
|
+
* @returns {Queue} The guild queue
|
|
1149
|
+
*/
|
|
510
1150
|
pause(): Queue;
|
|
1151
|
+
/**
|
|
1152
|
+
* Resume the guild stream
|
|
1153
|
+
* @returns {Queue} The guild queue
|
|
1154
|
+
*/
|
|
511
1155
|
resume(): Queue;
|
|
1156
|
+
/**
|
|
1157
|
+
* Set the guild stream's volume
|
|
1158
|
+
* @param {number} percent The percentage of volume you want to set
|
|
1159
|
+
* @returns {Queue} The guild queue
|
|
1160
|
+
*/
|
|
512
1161
|
setVolume(percent: number): Queue;
|
|
1162
|
+
/**
|
|
1163
|
+
* Skip the playing song if there is a next song in the queue.
|
|
1164
|
+
* <info>If {@link Queue#autoplay} is `true` and there is no up next song,
|
|
1165
|
+
* DisTube will add and play a related song.</info>
|
|
1166
|
+
* @returns {Promise<Song>} The song will skip to
|
|
1167
|
+
* @throws {Error}
|
|
1168
|
+
*/
|
|
513
1169
|
skip(): Promise<Song>;
|
|
1170
|
+
/**
|
|
1171
|
+
* Play the previous song if exists
|
|
1172
|
+
* @returns {Promise<Song>} The guild queue
|
|
1173
|
+
* @throws {Error}
|
|
1174
|
+
*/
|
|
514
1175
|
previous(): Promise<Song>;
|
|
1176
|
+
/**
|
|
1177
|
+
* Shuffle the queue's songs
|
|
1178
|
+
* @returns {Promise<Queue>} The guild queue
|
|
1179
|
+
*/
|
|
515
1180
|
shuffle(): Promise<Queue>;
|
|
1181
|
+
/**
|
|
1182
|
+
* Jump to the song position in the queue.
|
|
1183
|
+
* The next one is 1, 2,...
|
|
1184
|
+
* The previous one is -1, -2,...
|
|
1185
|
+
* @param {number} position The song position to play
|
|
1186
|
+
* @returns {Promise<Song>} The new Song will be played
|
|
1187
|
+
* @throws {Error} if `num` is invalid number
|
|
1188
|
+
*/
|
|
516
1189
|
jump(position: number): Promise<Song>;
|
|
1190
|
+
/**
|
|
1191
|
+
* Set the repeat mode of the guild queue.\
|
|
1192
|
+
* Toggle mode `(Disabled -> Song -> Queue -> Disabled ->...)` if `mode` is `undefined`
|
|
1193
|
+
* @param {RepeatMode?} [mode] The repeat modes (toggle if `undefined`)
|
|
1194
|
+
* @returns {RepeatMode} The new repeat mode
|
|
1195
|
+
*/
|
|
517
1196
|
setRepeatMode(mode?: RepeatMode): RepeatMode;
|
|
1197
|
+
/**
|
|
1198
|
+
* Set the playing time to another position
|
|
1199
|
+
* @param {number} time Time in seconds
|
|
1200
|
+
* @returns {Queue} The guild queue
|
|
1201
|
+
*/
|
|
518
1202
|
seek(time: number): Queue;
|
|
1203
|
+
/**
|
|
1204
|
+
* Add a related song of the playing song to the queue
|
|
1205
|
+
* @returns {Promise<Song>} The added song
|
|
1206
|
+
* @throws {Error}
|
|
1207
|
+
*/
|
|
519
1208
|
addRelatedSong(): Promise<Song>;
|
|
1209
|
+
/**
|
|
1210
|
+
* Stop the guild stream and delete the queue
|
|
1211
|
+
*/
|
|
520
1212
|
stop(): Promise<void>;
|
|
1213
|
+
/**
|
|
1214
|
+
* Remove the queue from the manager
|
|
1215
|
+
* (This does not leave the voice channel even if {@link DisTubeOptions|DisTubeOptions.leaveOnStop} is enabled)
|
|
1216
|
+
* @private
|
|
1217
|
+
*/
|
|
521
1218
|
remove(): void;
|
|
1219
|
+
/**
|
|
1220
|
+
* Toggle autoplay mode
|
|
1221
|
+
* @returns {boolean} Autoplay mode state
|
|
1222
|
+
*/
|
|
522
1223
|
toggleAutoplay(): boolean;
|
|
523
1224
|
}
|
|
524
1225
|
|
|
1226
|
+
/**
|
|
1227
|
+
* DisTube Plugin
|
|
1228
|
+
* @abstract
|
|
1229
|
+
* @private
|
|
1230
|
+
*/
|
|
525
1231
|
declare abstract class Plugin {
|
|
526
1232
|
abstract type: PluginType;
|
|
527
1233
|
distube: DisTube;
|
|
528
1234
|
init(distube: DisTube): void;
|
|
1235
|
+
/**
|
|
1236
|
+
* Type of the plugin
|
|
1237
|
+
* @name Plugin#type
|
|
1238
|
+
* @type {PluginType}
|
|
1239
|
+
*/
|
|
1240
|
+
/**
|
|
1241
|
+
* Emit an event to the {@link DisTube} class
|
|
1242
|
+
* @param {string} eventName Event name
|
|
1243
|
+
* @param {...any} args arguments
|
|
1244
|
+
* @returns {boolean}
|
|
1245
|
+
*/
|
|
529
1246
|
emit(eventName: keyof DisTubeEvents, ...args: any): boolean;
|
|
1247
|
+
/**
|
|
1248
|
+
* Emit error event to the {@link DisTube} class
|
|
1249
|
+
* @param {Error} error error
|
|
1250
|
+
* @param {Discord.BaseGuildTextChannel} [channel] Text channel where the error is encountered.
|
|
1251
|
+
*/
|
|
530
1252
|
emitError(error: Error, channel?: GuildTextBasedChannel): void;
|
|
1253
|
+
/**
|
|
1254
|
+
* The queue manager
|
|
1255
|
+
* @type {QueueManager}
|
|
1256
|
+
* @readonly
|
|
1257
|
+
*/
|
|
531
1258
|
get queues(): QueueManager;
|
|
1259
|
+
/**
|
|
1260
|
+
* The voice manager
|
|
1261
|
+
* @type {DisTubeVoiceManager}
|
|
1262
|
+
* @readonly
|
|
1263
|
+
*/
|
|
532
1264
|
get voices(): DisTubeVoiceManager;
|
|
1265
|
+
/**
|
|
1266
|
+
* Discord.js client
|
|
1267
|
+
* @type {Discord.Client}
|
|
1268
|
+
* @readonly
|
|
1269
|
+
*/
|
|
533
1270
|
get client(): Client;
|
|
1271
|
+
/**
|
|
1272
|
+
* DisTube options
|
|
1273
|
+
* @type {DisTubeOptions}
|
|
1274
|
+
* @readonly
|
|
1275
|
+
*/
|
|
534
1276
|
get options(): Options;
|
|
1277
|
+
/**
|
|
1278
|
+
* DisTube handler
|
|
1279
|
+
* @type {DisTubeHandler}
|
|
1280
|
+
* @readonly
|
|
1281
|
+
*/
|
|
535
1282
|
get handler(): DisTubeHandler;
|
|
1283
|
+
/**
|
|
1284
|
+
* Check if the string is working with this plugin
|
|
1285
|
+
* @param {string} _string Input string
|
|
1286
|
+
* @returns {boolean|Promise<boolean>}
|
|
1287
|
+
*/
|
|
536
1288
|
validate(_string: string): Awaitable<boolean>;
|
|
1289
|
+
/**
|
|
1290
|
+
* Get the stream url from {@link Song#url}. Returns {@link Song#url} by default.
|
|
1291
|
+
* Not needed if the plugin plays song from YouTube.
|
|
1292
|
+
* @param {string} url Input url
|
|
1293
|
+
* @returns {string|Promise<string>}
|
|
1294
|
+
*/
|
|
537
1295
|
getStreamURL(url: string): Awaitable<string>;
|
|
1296
|
+
/**
|
|
1297
|
+
* Get related songs from a supported url. {@link Song#member} should be `undefined`.
|
|
1298
|
+
* Not needed to add {@link Song#related} because it will be added with this function later.
|
|
1299
|
+
* @param {string} _url Input url
|
|
1300
|
+
* @returns {Song[]|Promise<Song[]>}
|
|
1301
|
+
*/
|
|
538
1302
|
getRelatedSongs(_url: string): Awaitable<RelatedSong[]>;
|
|
539
1303
|
}
|
|
540
1304
|
|
|
1305
|
+
/**
|
|
1306
|
+
* Custom Plugin
|
|
1307
|
+
* @extends Plugin
|
|
1308
|
+
* @abstract
|
|
1309
|
+
*/
|
|
541
1310
|
declare abstract class CustomPlugin extends Plugin {
|
|
542
1311
|
readonly type = PluginType.CUSTOM;
|
|
543
1312
|
abstract play(voiceChannel: VoiceBasedChannel, song: string, options: PlayOptions): Awaitable<void>;
|
|
544
1313
|
}
|
|
545
1314
|
|
|
1315
|
+
/**
|
|
1316
|
+
* Extractor Plugin
|
|
1317
|
+
* @extends Plugin
|
|
1318
|
+
* @abstract
|
|
1319
|
+
*/
|
|
546
1320
|
declare abstract class ExtractorPlugin extends Plugin {
|
|
547
1321
|
readonly type = PluginType.EXTRACTOR;
|
|
548
1322
|
abstract resolve<T = unknown>(url: string, options: {
|
|
@@ -551,12 +1325,41 @@ declare abstract class ExtractorPlugin extends Plugin {
|
|
|
551
1325
|
}): Awaitable<Song<T> | Playlist<T>>;
|
|
552
1326
|
}
|
|
553
1327
|
|
|
1328
|
+
/**
|
|
1329
|
+
* Format duration to string
|
|
1330
|
+
* @param {number} sec Duration in seconds
|
|
1331
|
+
* @returns {string}
|
|
1332
|
+
*/
|
|
554
1333
|
declare function formatDuration(sec: number): string;
|
|
1334
|
+
/**
|
|
1335
|
+
* Convert formatted duration to seconds
|
|
1336
|
+
* @param {*} input Formatted duration string
|
|
1337
|
+
* @returns {number}
|
|
1338
|
+
*/
|
|
555
1339
|
declare function toSecond(input: any): number;
|
|
1340
|
+
/**
|
|
1341
|
+
* Parse number from input
|
|
1342
|
+
* @param {*} input Any
|
|
1343
|
+
* @returns {number}
|
|
1344
|
+
*/
|
|
556
1345
|
declare function parseNumber(input: any): number;
|
|
557
1346
|
declare const SUPPORTED_PROTOCOL: readonly ["https:", "http:", "file:"];
|
|
1347
|
+
/**
|
|
1348
|
+
* Check if the string is an URL
|
|
1349
|
+
* @param {string} input input
|
|
1350
|
+
* @returns {boolean}
|
|
1351
|
+
*/
|
|
558
1352
|
declare function isURL(input: any): input is `${(typeof SUPPORTED_PROTOCOL)[number]}//${string}`;
|
|
1353
|
+
/**
|
|
1354
|
+
* Check if the Client has enough intents to using DisTube
|
|
1355
|
+
* @param {ClientOptions} options options
|
|
1356
|
+
*/
|
|
559
1357
|
declare function checkIntents(options: ClientOptions): void;
|
|
1358
|
+
/**
|
|
1359
|
+
* Check if the voice channel is empty
|
|
1360
|
+
* @param {Discord.VoiceState} voiceState voiceState
|
|
1361
|
+
* @returns {boolean}
|
|
1362
|
+
*/
|
|
560
1363
|
declare function isVoiceChannelEmpty(voiceState: VoiceState): boolean;
|
|
561
1364
|
declare function isSnowflake(id: any): id is Snowflake;
|
|
562
1365
|
declare function isMemberInstance(member: any): member is GuildMember;
|
|
@@ -572,17 +1375,24 @@ declare function isRecord<T = unknown>(obj: any): obj is Record<string, T>;
|
|
|
572
1375
|
type KeyOf<T> = T extends object ? (keyof T)[] : [];
|
|
573
1376
|
declare function objectKeys<T>(obj: T): KeyOf<T>;
|
|
574
1377
|
declare function isNsfwChannel(channel?: GuildTextBasedChannel): boolean;
|
|
1378
|
+
type Falsy = undefined | null | false | 0 | "";
|
|
1379
|
+
declare const isTruthy: <T>(x: T | Falsy) => x is T;
|
|
575
1380
|
|
|
576
1381
|
declare class DirectLinkPlugin extends ExtractorPlugin {
|
|
577
1382
|
validate(url: string): Promise<boolean>;
|
|
578
1383
|
resolve(url: string, options?: {
|
|
579
1384
|
member?: GuildMember;
|
|
580
1385
|
metadata?: any;
|
|
581
|
-
}):
|
|
1386
|
+
}): Song<any>;
|
|
582
1387
|
}
|
|
583
1388
|
|
|
584
1389
|
declare const version: string;
|
|
1390
|
+
/**
|
|
1391
|
+
* DisTube class
|
|
1392
|
+
* @extends EventEmitter
|
|
1393
|
+
*/
|
|
585
1394
|
declare class DisTube extends TypedEmitter<TypedDisTubeEvents> {
|
|
1395
|
+
#private;
|
|
586
1396
|
readonly handler: DisTubeHandler;
|
|
587
1397
|
readonly options: Options;
|
|
588
1398
|
readonly client: Client;
|
|
@@ -591,10 +1401,71 @@ declare class DisTube extends TypedEmitter<TypedDisTubeEvents> {
|
|
|
591
1401
|
readonly extractorPlugins: ExtractorPlugin[];
|
|
592
1402
|
readonly customPlugins: CustomPlugin[];
|
|
593
1403
|
readonly filters: Filters;
|
|
1404
|
+
/**
|
|
1405
|
+
* @deprecated Use `youtubeCookie: Cookie[]` instead. Guide: {@link https://distube.js.org/#/docs/DisTube/main/general/cookie YouTube Cookies}
|
|
1406
|
+
*/
|
|
1407
|
+
constructor(client: Client, otp: DisTubeOptions & {
|
|
1408
|
+
youtubeCookie: string;
|
|
1409
|
+
});
|
|
1410
|
+
/**
|
|
1411
|
+
* Create a new DisTube class.
|
|
1412
|
+
* @param {Discord.Client} client Discord.JS client
|
|
1413
|
+
* @param {DisTubeOptions} [otp] Custom DisTube options
|
|
1414
|
+
* @throws {DisTubeError}
|
|
1415
|
+
* @example
|
|
1416
|
+
* const Discord = require('discord.js'),
|
|
1417
|
+
* DisTube = require('distube'),
|
|
1418
|
+
* client = new Discord.Client();
|
|
1419
|
+
* // Create a new DisTube
|
|
1420
|
+
* const distube = new DisTube.default(client, { searchSongs: 10 });
|
|
1421
|
+
* // client.DisTube = distube // make it access easily
|
|
1422
|
+
* client.login("Your Discord Bot Token")
|
|
1423
|
+
*/
|
|
594
1424
|
constructor(client: Client, otp?: DisTubeOptions);
|
|
595
1425
|
static get version(): string;
|
|
1426
|
+
/**
|
|
1427
|
+
* DisTube version
|
|
1428
|
+
* @type {string}
|
|
1429
|
+
*/
|
|
596
1430
|
get version(): string;
|
|
1431
|
+
/**
|
|
1432
|
+
* Play / add a song or playlist from url. Search and play a song if it is not a valid url.
|
|
1433
|
+
*
|
|
1434
|
+
* @param {Discord.BaseGuildVoiceChannel} voiceChannel The channel will be joined if the bot isn't in any channels,
|
|
1435
|
+
* the bot will be moved to this channel if {@link DisTubeOptions}.joinNewVoiceChannel is `true`
|
|
1436
|
+
* @param {string|Song|SearchResult|Playlist} song URL | Search string |
|
|
1437
|
+
* {@link Song} | {@link SearchResult} | {@link Playlist}
|
|
1438
|
+
* @param {PlayOptions} [options] Optional options
|
|
1439
|
+
* @throws {DisTubeError}
|
|
1440
|
+
* @example
|
|
1441
|
+
* client.on('message', (message) => {
|
|
1442
|
+
* if (!message.content.startsWith(config.prefix)) return;
|
|
1443
|
+
* const args = message.content.slice(config.prefix.length).trim().split(/ +/g);
|
|
1444
|
+
* const command = args.shift();
|
|
1445
|
+
* if (command == "play")
|
|
1446
|
+
* distube.play(message.member.voice.channel, args.join(" "), {
|
|
1447
|
+
* member: message.member,
|
|
1448
|
+
* textChannel: message.channel,
|
|
1449
|
+
* message
|
|
1450
|
+
* });
|
|
1451
|
+
* });
|
|
1452
|
+
* @returns {Promise<void>}
|
|
1453
|
+
*/
|
|
597
1454
|
play(voiceChannel: VoiceBasedChannel, song: string | Song | SearchResult | Playlist, options?: PlayOptions): Promise<void>;
|
|
1455
|
+
/**
|
|
1456
|
+
* Create a custom playlist
|
|
1457
|
+
* @returns {Promise<Playlist>}
|
|
1458
|
+
* @param {Array<string|Song|SearchResult>} songs Array of url, Song or SearchResult
|
|
1459
|
+
* @param {CustomPlaylistOptions} [options] Optional options
|
|
1460
|
+
* @example
|
|
1461
|
+
* const songs = ["https://www.youtube.com/watch?v=xxx", "https://www.youtube.com/watch?v=yyy"];
|
|
1462
|
+
* const playlist = await distube.createCustomPlaylist(songs, {
|
|
1463
|
+
* member: message.member,
|
|
1464
|
+
* properties: { name: "My playlist name", source: "custom" },
|
|
1465
|
+
* parallel: true
|
|
1466
|
+
* });
|
|
1467
|
+
* distube.play(voiceChannel, playlist, { ... });
|
|
1468
|
+
*/
|
|
598
1469
|
createCustomPlaylist(songs: (string | Song | SearchResult)[], options?: CustomPlaylistOptions): Promise<Playlist>;
|
|
599
1470
|
search(string: string, options?: {
|
|
600
1471
|
type?: SearchResultType.VIDEO;
|
|
@@ -614,20 +1485,216 @@ declare class DisTube extends TypedEmitter<TypedDisTubeEvents> {
|
|
|
614
1485
|
safeSearch?: boolean;
|
|
615
1486
|
retried?: boolean;
|
|
616
1487
|
}): Promise<Array<SearchResult>>;
|
|
1488
|
+
/**
|
|
1489
|
+
* Get the guild queue
|
|
1490
|
+
* @param {GuildIdResolvable} guild The type can be resolved to give a {@link Queue}
|
|
1491
|
+
* @returns {Queue?}
|
|
1492
|
+
* @throws {Error}
|
|
1493
|
+
* @example
|
|
1494
|
+
* client.on('message', (message) => {
|
|
1495
|
+
* if (!message.content.startsWith(config.prefix)) return;
|
|
1496
|
+
* const args = message.content.slice(config.prefix.length).trim().split(/ +/g);
|
|
1497
|
+
* const command = args.shift();
|
|
1498
|
+
* if (command == "queue") {
|
|
1499
|
+
* const queue = distube.getQueue(message);
|
|
1500
|
+
* message.channel.send('Current queue:\n' + queue.songs.map((song, id) =>
|
|
1501
|
+
* `**${id+1}**. [${song.name}](${song.url}) - \`${song.formattedDuration}\``
|
|
1502
|
+
* ).join("\n"));
|
|
1503
|
+
* }
|
|
1504
|
+
* });
|
|
1505
|
+
*/
|
|
617
1506
|
getQueue(guild: GuildIdResolvable): Queue | undefined;
|
|
1507
|
+
/**
|
|
1508
|
+
* Pause the guild stream
|
|
1509
|
+
* @param {GuildIdResolvable} guild The type can be resolved to give a {@link Queue}
|
|
1510
|
+
* @returns {Queue} The guild queue
|
|
1511
|
+
* @throws {Error}
|
|
1512
|
+
*/
|
|
618
1513
|
pause(guild: GuildIdResolvable): Queue;
|
|
1514
|
+
/**
|
|
1515
|
+
* Resume the guild stream
|
|
1516
|
+
* @param {GuildIdResolvable} guild The type can be resolved to give a {@link Queue}
|
|
1517
|
+
* @returns {Queue} The guild queue
|
|
1518
|
+
* @throws {Error}
|
|
1519
|
+
*/
|
|
619
1520
|
resume(guild: GuildIdResolvable): Queue;
|
|
1521
|
+
/**
|
|
1522
|
+
* Stop the guild stream
|
|
1523
|
+
* @param {GuildIdResolvable} guild The type can be resolved to give a {@link Queue}
|
|
1524
|
+
* @returns {Promise<void>}
|
|
1525
|
+
* @throws {Error}
|
|
1526
|
+
* @example
|
|
1527
|
+
* client.on('message', (message) => {
|
|
1528
|
+
* if (!message.content.startsWith(config.prefix)) return;
|
|
1529
|
+
* const args = message.content.slice(config.prefix.length).trim().split(/ +/g);
|
|
1530
|
+
* const command = args.shift();
|
|
1531
|
+
* if (command == "stop") {
|
|
1532
|
+
* distube.stop(message);
|
|
1533
|
+
* message.channel.send("Stopped the queue!");
|
|
1534
|
+
* }
|
|
1535
|
+
* });
|
|
1536
|
+
*/
|
|
620
1537
|
stop(guild: GuildIdResolvable): Promise<void>;
|
|
1538
|
+
/**
|
|
1539
|
+
* Set the guild stream's volume
|
|
1540
|
+
* @param {GuildIdResolvable} guild The type can be resolved to give a {@link Queue}
|
|
1541
|
+
* @param {number} percent The percentage of volume you want to set
|
|
1542
|
+
* @returns {Queue} The guild queue
|
|
1543
|
+
* @throws {Error}
|
|
1544
|
+
* @example
|
|
1545
|
+
* client.on('message', (message) => {
|
|
1546
|
+
* if (!message.content.startsWith(config.prefix)) return;
|
|
1547
|
+
* const args = message.content.slice(config.prefix.length).trim().split(/ +/g);
|
|
1548
|
+
* const command = args.shift();
|
|
1549
|
+
* if (command == "volume")
|
|
1550
|
+
* distube.setVolume(message, Number(args[0]));
|
|
1551
|
+
* });
|
|
1552
|
+
*/
|
|
621
1553
|
setVolume(guild: GuildIdResolvable, percent: number): Queue;
|
|
1554
|
+
/**
|
|
1555
|
+
* Skip the playing song if there is a next song in the queue.
|
|
1556
|
+
* <info>If {@link Queue#autoplay} is `true` and there is no up next song,
|
|
1557
|
+
* DisTube will add and play a related song.</info>
|
|
1558
|
+
* @param {GuildIdResolvable} guild The type can be resolved to give a {@link Queue}
|
|
1559
|
+
* @returns {Promise<Song>} The new Song will be played
|
|
1560
|
+
* @throws {Error}
|
|
1561
|
+
* @example
|
|
1562
|
+
* client.on('message', (message) => {
|
|
1563
|
+
* if (!message.content.startsWith(config.prefix)) return;
|
|
1564
|
+
* const args = message.content.slice(config.prefix.length).trim().split(/ +/g);
|
|
1565
|
+
* const command = args.shift();
|
|
1566
|
+
* if (command == "skip")
|
|
1567
|
+
* distube.skip(message);
|
|
1568
|
+
* });
|
|
1569
|
+
*/
|
|
622
1570
|
skip(guild: GuildIdResolvable): Promise<Song>;
|
|
1571
|
+
/**
|
|
1572
|
+
* Play the previous song
|
|
1573
|
+
* @param {GuildIdResolvable} guild The type can be resolved to give a {@link Queue}
|
|
1574
|
+
* @returns {Promise<Song>} The new Song will be played
|
|
1575
|
+
* @throws {Error}
|
|
1576
|
+
* @example
|
|
1577
|
+
* client.on('message', (message) => {
|
|
1578
|
+
* if (!message.content.startsWith(config.prefix)) return;
|
|
1579
|
+
* const args = message.content.slice(config.prefix.length).trim().split(/ +/g);
|
|
1580
|
+
* const command = args.shift();
|
|
1581
|
+
* if (command == "previous")
|
|
1582
|
+
* distube.previous(message);
|
|
1583
|
+
* });
|
|
1584
|
+
*/
|
|
623
1585
|
previous(guild: GuildIdResolvable): Promise<Song>;
|
|
1586
|
+
/**
|
|
1587
|
+
* Shuffle the guild queue songs
|
|
1588
|
+
* @param {GuildIdResolvable} guild The type can be resolved to give a {@link Queue}
|
|
1589
|
+
* @returns {Promise<Queue>} The guild queue
|
|
1590
|
+
* @example
|
|
1591
|
+
* client.on('message', (message) => {
|
|
1592
|
+
* if (!message.content.startsWith(config.prefix)) return;
|
|
1593
|
+
* const args = message.content.slice(config.prefix.length).trim().split(/ +/g);
|
|
1594
|
+
* const command = args.shift();
|
|
1595
|
+
* if (command == "shuffle")
|
|
1596
|
+
* distube.shuffle(message);
|
|
1597
|
+
* });
|
|
1598
|
+
*/
|
|
624
1599
|
shuffle(guild: GuildIdResolvable): Promise<Queue>;
|
|
1600
|
+
/**
|
|
1601
|
+
* Jump to the song number in the queue.
|
|
1602
|
+
* The next one is 1, 2,...
|
|
1603
|
+
* The previous one is -1, -2,...
|
|
1604
|
+
* @param {GuildIdResolvable} guild The type can be resolved to give a {@link Queue}
|
|
1605
|
+
* @param {number} num The song number to play
|
|
1606
|
+
* @returns {Promise<Song>} The new Song will be played
|
|
1607
|
+
* @throws {Error} if `num` is invalid number (0 < num < {@link Queue#songs}.length)
|
|
1608
|
+
* @example
|
|
1609
|
+
* client.on('message', (message) => {
|
|
1610
|
+
* if (!message.content.startsWith(config.prefix)) return;
|
|
1611
|
+
* const args = message.content.slice(config.prefix.length).trim().split(/ +/g);
|
|
1612
|
+
* const command = args.shift();
|
|
1613
|
+
* if (command == "jump")
|
|
1614
|
+
* distube.jump(message, parseInt(args[0]))
|
|
1615
|
+
* .catch(err => message.channel.send("Invalid song number."));
|
|
1616
|
+
* });
|
|
1617
|
+
*/
|
|
625
1618
|
jump(guild: GuildIdResolvable, num: number): Promise<Song>;
|
|
1619
|
+
/**
|
|
1620
|
+
* Set the repeat mode of the guild queue.\
|
|
1621
|
+
* Toggle mode `(Disabled -> Song -> Queue -> Disabled ->...)` if `mode` is `undefined`
|
|
1622
|
+
* @param {GuildIdResolvable} guild The type can be resolved to give a {@link Queue}
|
|
1623
|
+
* @param {RepeatMode?} [mode] The repeat modes (toggle if `undefined`)
|
|
1624
|
+
* @returns {RepeatMode} The new repeat mode
|
|
1625
|
+
* @example
|
|
1626
|
+
* client.on('message', (message) => {
|
|
1627
|
+
* if (!message.content.startsWith(config.prefix)) return;
|
|
1628
|
+
* const args = message.content.slice(config.prefix.length).trim().split(/ +/g);
|
|
1629
|
+
* const command = args.shift();
|
|
1630
|
+
* if (command == "repeat") {
|
|
1631
|
+
* let mode = distube.setRepeatMode(message, parseInt(args[0]));
|
|
1632
|
+
* mode = mode ? mode == 2 ? "Repeat queue" : "Repeat song" : "Off";
|
|
1633
|
+
* message.channel.send("Set repeat mode to `" + mode + "`");
|
|
1634
|
+
* }
|
|
1635
|
+
* });
|
|
1636
|
+
* @example
|
|
1637
|
+
* const { RepeatMode } = require("distube");
|
|
1638
|
+
* let mode;
|
|
1639
|
+
* switch(distube.setRepeatMode(message, parseInt(args[0]))) {
|
|
1640
|
+
* case RepeatMode.DISABLED:
|
|
1641
|
+
* mode = "Off";
|
|
1642
|
+
* break;
|
|
1643
|
+
* case RepeatMode.SONG:
|
|
1644
|
+
* mode = "Repeat a song";
|
|
1645
|
+
* break;
|
|
1646
|
+
* case RepeatMode.QUEUE:
|
|
1647
|
+
* mode = "Repeat all queue";
|
|
1648
|
+
* break;
|
|
1649
|
+
* }
|
|
1650
|
+
* message.channel.send("Set repeat mode to `" + mode + "`");
|
|
1651
|
+
*/
|
|
626
1652
|
setRepeatMode(guild: GuildIdResolvable, mode?: number): number;
|
|
1653
|
+
/**
|
|
1654
|
+
* Toggle autoplay mode
|
|
1655
|
+
* @param {GuildIdResolvable} guild The type can be resolved to give a {@link Queue}
|
|
1656
|
+
* @returns {boolean} Autoplay mode state
|
|
1657
|
+
* @throws {Error}
|
|
1658
|
+
* @example
|
|
1659
|
+
* client.on('message', (message) => {
|
|
1660
|
+
* if (!message.content.startsWith(config.prefix)) return;
|
|
1661
|
+
* const args = message.content.slice(config.prefix.length).trim().split(/ +/g);
|
|
1662
|
+
* const command = args.shift();
|
|
1663
|
+
* if (command == "autoplay") {
|
|
1664
|
+
* const mode = distube.toggleAutoplay(message);
|
|
1665
|
+
* message.channel.send("Set autoplay mode to `" + (mode ? "On" : "Off") + "`");
|
|
1666
|
+
* }
|
|
1667
|
+
* });
|
|
1668
|
+
*/
|
|
627
1669
|
toggleAutoplay(guild: GuildIdResolvable): boolean;
|
|
1670
|
+
/**
|
|
1671
|
+
* Add related song to the queue
|
|
1672
|
+
* @param {GuildIdResolvable} guild The type can be resolved to give a {@link Queue}
|
|
1673
|
+
* @returns {Promise<Song>} The guild queue
|
|
1674
|
+
*/
|
|
628
1675
|
addRelatedSong(guild: GuildIdResolvable): Promise<Song>;
|
|
1676
|
+
/**
|
|
1677
|
+
* Set the playing time to another position
|
|
1678
|
+
* @param {GuildIdResolvable} guild The type can be resolved to give a {@link Queue}
|
|
1679
|
+
* @param {number} time Time in seconds
|
|
1680
|
+
* @returns {Queue} Seeked queue
|
|
1681
|
+
* @example
|
|
1682
|
+
* client.on('message', message => {
|
|
1683
|
+
* if (!message.content.startsWith(config.prefix)) return;
|
|
1684
|
+
* const args = message.content.slice(config.prefix.length).trim().split(/ +/g);
|
|
1685
|
+
* const command = args.shift();
|
|
1686
|
+
* if (command = 'seek')
|
|
1687
|
+
* distube.seek(message, Number(args[0]));
|
|
1688
|
+
* });
|
|
1689
|
+
*/
|
|
629
1690
|
seek(guild: GuildIdResolvable, time: number): Queue;
|
|
1691
|
+
/**
|
|
1692
|
+
* Emit error event
|
|
1693
|
+
* @param {Error} error error
|
|
1694
|
+
* @param {Discord.BaseGuildTextChannel} [channel] Text channel where the error is encountered.
|
|
1695
|
+
* @private
|
|
1696
|
+
*/
|
|
630
1697
|
emitError(error: Error, channel?: GuildTextBasedChannel): void;
|
|
631
1698
|
}
|
|
632
1699
|
|
|
633
|
-
export { Awaitable, BaseManager, Chapter, CustomPlaylistOptions, CustomPlugin, DirectLinkPlugin, DisTube, DisTubeBase, DisTubeError, DisTubeEvents, DisTubeHandler, DisTubeOptions, DisTubeStream, DisTubeVoice, DisTubeVoiceEvents, DisTubeVoiceManager, Events, ExtractorPlugin, Filter, FilterManager, FilterResolvable, Filters, GuildIdManager, GuildIdResolvable, Options, OtherSongInfo, PlayHandlerOptions, PlayOptions, Playlist, PlaylistInfo, Plugin, PluginType, Queue, QueueManager, RelatedSong, RepeatMode, ResolveOptions, ResolvePlaylistOptions, SearchResult, SearchResultPlaylist, SearchResultType, SearchResultVideo, Song, StreamType, TaskQueue, TypedDisTubeEvents, checkIntents, checkInvalidKey, chooseBestVideoFormat, DisTube as default, defaultFilters, defaultOptions, formatDuration, isClientInstance, isGuildInstance, isMemberInstance, isMessageInstance, isNsfwChannel, isObject, isRecord, isSnowflake, isSupportedVoiceChannel, isTextChannelInstance, isURL, isVoiceChannelEmpty, objectKeys, parseNumber, resolveGuildId, toSecond, version };
|
|
1700
|
+
export { Awaitable, BaseManager, Chapter, CustomPlaylistOptions, CustomPlugin, DirectLinkPlugin, DisTube, DisTubeBase, DisTubeError, DisTubeEvents, DisTubeHandler, DisTubeOptions, DisTubeStream, DisTubeVoice, DisTubeVoiceEvents, DisTubeVoiceManager, Events, ExtractorPlugin, Filter, FilterManager, FilterResolvable, Filters, GuildIdManager, GuildIdResolvable, Options, OtherSongInfo, PlayHandlerOptions, PlayOptions, Playlist, PlaylistInfo, Plugin, PluginType, Queue, QueueManager, RelatedSong, RepeatMode, ResolveOptions, ResolvePlaylistOptions, SearchResult, SearchResultPlaylist, SearchResultType, SearchResultVideo, Song, StreamType, TaskQueue, TypedDisTubeEvents, checkIntents, checkInvalidKey, chooseBestVideoFormat, DisTube as default, defaultFilters, defaultOptions, formatDuration, isClientInstance, isGuildInstance, isMemberInstance, isMessageInstance, isNsfwChannel, isObject, isRecord, isSnowflake, isSupportedVoiceChannel, isTextChannelInstance, isTruthy, isURL, isVoiceChannelEmpty, objectKeys, parseNumber, resolveGuildId, toSecond, version };
|