distube 3.0.0-beta.9 → 3.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -21
- package/README.md +64 -51
- package/dist/DisTube.d.ts +522 -0
- package/dist/DisTube.d.ts.map +1 -0
- package/dist/DisTube.js +794 -0
- package/dist/DisTube.js.map +1 -0
- package/dist/constant.d.ts +130 -0
- package/dist/constant.d.ts.map +1 -0
- package/dist/constant.js +150 -0
- package/dist/constant.js.map +1 -0
- package/dist/core/DisTubeBase.d.ts +55 -0
- package/dist/core/DisTubeBase.d.ts.map +1 -0
- package/dist/core/DisTubeBase.js +76 -0
- package/dist/core/DisTubeBase.js.map +1 -0
- package/dist/core/DisTubeHandler.d.ts +95 -0
- package/dist/core/DisTubeHandler.d.ts.map +1 -0
- package/dist/core/DisTubeHandler.js +337 -0
- package/dist/core/DisTubeHandler.js.map +1 -0
- package/dist/core/DisTubeOptions.d.ts +26 -0
- package/dist/core/DisTubeOptions.d.ts.map +1 -0
- package/dist/core/DisTubeOptions.js +93 -0
- package/dist/core/DisTubeOptions.js.map +1 -0
- package/dist/core/DisTubeStream.d.ts +52 -0
- package/dist/core/DisTubeStream.d.ts.map +1 -0
- package/dist/core/DisTubeStream.js +109 -0
- package/dist/core/DisTubeStream.js.map +1 -0
- package/dist/core/index.d.ts +7 -0
- package/dist/core/index.d.ts.map +1 -0
- package/dist/core/index.js +19 -0
- package/dist/core/index.js.map +1 -0
- package/dist/core/manager/BaseManager.d.ts +18 -0
- package/dist/core/manager/BaseManager.d.ts.map +1 -0
- package/dist/core/manager/BaseManager.js +44 -0
- package/dist/core/manager/BaseManager.js.map +1 -0
- package/dist/core/manager/QueueManager.d.ts +60 -0
- package/dist/core/manager/QueueManager.d.ts.map +1 -0
- package/dist/core/manager/QueueManager.js +202 -0
- package/dist/core/manager/QueueManager.js.map +1 -0
- package/dist/core/manager/index.d.ts +3 -0
- package/dist/core/manager/index.d.ts.map +1 -0
- package/dist/core/manager/index.js +15 -0
- package/dist/core/manager/index.js.map +1 -0
- package/dist/core/voice/DJSAdapter.d.ts +4 -0
- package/dist/core/voice/DJSAdapter.d.ts.map +1 -0
- package/dist/core/voice/DJSAdapter.js +61 -0
- package/dist/core/voice/DJSAdapter.js.map +1 -0
- package/dist/core/voice/DisTubeVoice.d.ts +85 -0
- package/dist/core/voice/DisTubeVoice.d.ts.map +1 -0
- package/dist/core/voice/DisTubeVoice.js +246 -0
- package/dist/core/voice/DisTubeVoice.js.map +1 -0
- package/dist/core/voice/DisTubeVoiceManager.d.ts +41 -0
- package/dist/core/voice/DisTubeVoiceManager.d.ts.map +1 -0
- package/dist/core/voice/DisTubeVoiceManager.js +67 -0
- package/dist/core/voice/DisTubeVoiceManager.js.map +1 -0
- package/dist/core/voice/index.d.ts +4 -0
- package/dist/core/voice/index.d.ts.map +1 -0
- package/dist/core/voice/index.js +16 -0
- package/dist/core/voice/index.js.map +1 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +23 -0
- package/dist/index.js.map +1 -0
- package/dist/plugin/http.d.ts +8 -0
- package/dist/plugin/http.d.ts.map +1 -0
- package/dist/plugin/http.js +20 -0
- package/dist/plugin/http.js.map +1 -0
- package/dist/plugin/https.d.ts +14 -0
- package/dist/plugin/https.d.ts.map +1 -0
- package/dist/plugin/https.js +50 -0
- package/dist/plugin/https.js.map +1 -0
- package/dist/plugin/index.d.ts +4 -0
- package/dist/plugin/index.d.ts.map +1 -0
- package/dist/plugin/index.js +16 -0
- package/dist/plugin/index.js.map +1 -0
- package/dist/plugin/youtube-dl.d.ts +11 -0
- package/dist/plugin/youtube-dl.d.ts.map +1 -0
- package/dist/plugin/youtube-dl.js +75 -0
- package/dist/plugin/youtube-dl.js.map +1 -0
- package/dist/struct/CustomPlugin.d.ts +27 -0
- package/dist/struct/CustomPlugin.d.ts.map +1 -0
- package/dist/struct/CustomPlugin.js +35 -0
- package/dist/struct/CustomPlugin.js.map +1 -0
- package/dist/struct/DisTubeError.d.ts +56 -0
- package/dist/struct/DisTubeError.d.ts.map +1 -0
- package/dist/struct/DisTubeError.js +75 -0
- package/dist/struct/DisTubeError.js.map +1 -0
- package/dist/struct/ExtractorPlugin.d.ts +29 -0
- package/dist/struct/ExtractorPlugin.d.ts.map +1 -0
- package/dist/struct/ExtractorPlugin.js +32 -0
- package/dist/struct/ExtractorPlugin.js.map +1 -0
- package/dist/struct/Playlist.d.ts +42 -0
- package/dist/struct/Playlist.d.ts.map +1 -0
- package/dist/struct/Playlist.js +104 -0
- package/dist/struct/Playlist.js.map +1 -0
- package/dist/struct/Plugin.d.ts +82 -0
- package/dist/struct/Plugin.d.ts.map +1 -0
- package/dist/struct/Plugin.js +108 -0
- package/dist/struct/Plugin.js.map +1 -0
- package/dist/struct/Queue.d.ts +217 -0
- package/dist/struct/Queue.d.ts.map +1 -0
- package/dist/struct/Queue.js +481 -0
- package/dist/struct/Queue.js.map +1 -0
- package/dist/struct/SearchResult.d.ts +28 -0
- package/dist/struct/SearchResult.d.ts.map +1 -0
- package/dist/struct/SearchResult.js +79 -0
- package/dist/struct/SearchResult.js.map +1 -0
- package/dist/struct/Song.d.ts +68 -0
- package/dist/struct/Song.d.ts.map +1 -0
- package/dist/struct/Song.js +229 -0
- package/dist/struct/Song.js.map +1 -0
- package/dist/struct/TaskQueue.d.ts +33 -0
- package/dist/struct/TaskQueue.d.ts.map +1 -0
- package/dist/struct/TaskQueue.js +58 -0
- package/dist/struct/TaskQueue.js.map +1 -0
- package/dist/struct/index.d.ts +10 -0
- package/dist/struct/index.d.ts.map +1 -0
- package/dist/struct/index.js +22 -0
- package/dist/struct/index.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/dist/type.d.ts +159 -0
- package/dist/type.d.ts.map +1 -0
- package/dist/type.js +3 -0
- package/dist/type.js.map +1 -0
- package/dist/util.d.ts +47 -0
- package/dist/util.d.ts.map +1 -0
- package/dist/util.js +205 -0
- package/dist/util.js.map +1 -0
- package/package.json +88 -62
- package/src/DisTube.js +0 -851
- package/src/DisTubeBase.js +0 -39
- package/src/DisTubeHandler.js +0 -440
- package/src/DisTubeOptions.js +0 -82
- package/src/Filter.js +0 -36
- package/src/Playlist.js +0 -75
- package/src/Plugin/CustomPlugin.js +0 -26
- package/src/Plugin/ExtractorPlugin.js +0 -25
- package/src/Plugin/Plugin.js +0 -36
- package/src/Plugin/http.js +0 -27
- package/src/Plugin/https.js +0 -27
- package/src/Queue.js +0 -340
- package/src/SearchResult.js +0 -57
- package/src/Song.js +0 -169
- package/src/util.js +0 -65
- package/typings/DisTube.d.ts +0 -553
- package/typings/DisTubeBase.d.ts +0 -31
- package/typings/DisTubeHandler.d.ts +0 -130
- package/typings/DisTubeOptions.d.ts +0 -5
- package/typings/Filter.d.ts +0 -83
- package/typings/Playlist.d.ts +0 -58
- package/typings/Plugin/CustomPlugin.d.ts +0 -21
- package/typings/Plugin/ExtractorPlugin.d.ts +0 -20
- package/typings/Plugin/Plugin.d.ts +0 -31
- package/typings/Plugin/http.d.ts +0 -4
- package/typings/Plugin/https.d.ts +0 -4
- package/typings/Queue.d.ts +0 -227
- package/typings/SearchResult.d.ts +0 -51
- package/typings/Song.d.ts +0 -153
- package/typings/util.d.ts +0 -6
package/src/util.js
DELETED
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
const formatInt = int => int < 10 ? `0${int}` : int;
|
|
2
|
-
|
|
3
|
-
module.exports.formatDuration = secs => {
|
|
4
|
-
if (!secs || !Number(secs)) return "00:00";
|
|
5
|
-
const seconds = Math.floor(secs % 60);
|
|
6
|
-
const minutes = Math.floor(secs % 3600 / 60);
|
|
7
|
-
const hours = Math.floor(secs / 3600);
|
|
8
|
-
if (hours > 0) {
|
|
9
|
-
return `${formatInt(hours)}:${formatInt(minutes)}:${formatInt(seconds)}`;
|
|
10
|
-
}
|
|
11
|
-
if (minutes > 0) {
|
|
12
|
-
return `${formatInt(minutes)}:${formatInt(seconds)}`;
|
|
13
|
-
}
|
|
14
|
-
return `00:${formatInt(seconds)}`;
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
module.exports.toSecond = string => {
|
|
18
|
-
if (!string) return 0;
|
|
19
|
-
if (typeof string !== "string") return parseInt(string) || 0;
|
|
20
|
-
let h = 0, m = 0, s = 0;
|
|
21
|
-
if (string.match(/:/g)) {
|
|
22
|
-
const time = string.split(":");
|
|
23
|
-
if (time.length === 2) {
|
|
24
|
-
m = parseInt(time[0], 10);
|
|
25
|
-
s = parseInt(time[1], 10);
|
|
26
|
-
} else if (time.length === 3) {
|
|
27
|
-
h = parseInt(time[0], 10);
|
|
28
|
-
m = parseInt(time[1], 10);
|
|
29
|
-
s = parseInt(time[2], 10);
|
|
30
|
-
}
|
|
31
|
-
} else s = parseInt(string, 10);
|
|
32
|
-
// eslint-disable-next-line no-mixed-operators
|
|
33
|
-
return h * 60 * 60 + m * 60 + s;
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
module.exports.parseNumber = string => (typeof string === "string" ? Number(string.replace(/\D+/g, "")) : Number(string)) || 0;
|
|
37
|
-
|
|
38
|
-
const merge = module.exports.mergeObject = (def, opt) => {
|
|
39
|
-
if (!opt) return def;
|
|
40
|
-
for (const key in def) {
|
|
41
|
-
if (!Object.prototype.hasOwnProperty.call(opt, key) || opt[key] === undefined) {
|
|
42
|
-
opt[key] = def[key];
|
|
43
|
-
} else if (opt[key] === Object(opt[key])) {
|
|
44
|
-
opt[key] = merge(def[key], opt[key]);
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
return opt;
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
module.exports.isURL = string => {
|
|
51
|
-
if (string.includes(" ")) return false;
|
|
52
|
-
try {
|
|
53
|
-
const url = new URL(string);
|
|
54
|
-
if (!["https:", "http:"].includes(url.protocol) ||
|
|
55
|
-
url.origin === "null" || !url.host
|
|
56
|
-
) return false;
|
|
57
|
-
} catch { return false }
|
|
58
|
-
return true;
|
|
59
|
-
};
|
|
60
|
-
|
|
61
|
-
module.exports.isVoiceChannelEmpty = queue => {
|
|
62
|
-
const voiceChannel = queue.connection.channel;
|
|
63
|
-
const members = voiceChannel.members.filter(m => !m.user.bot);
|
|
64
|
-
return !members.size;
|
|
65
|
-
};
|
package/typings/DisTube.d.ts
DELETED
|
@@ -1,553 +0,0 @@
|
|
|
1
|
-
export = DisTube;
|
|
2
|
-
/**
|
|
3
|
-
* FFmpeg Filters
|
|
4
|
-
* ```
|
|
5
|
-
* {
|
|
6
|
-
* "Filter Name": "Filter Value",
|
|
7
|
-
* "bassboost": "bass=g=10,dynaudnorm=f=150:g=15"
|
|
8
|
-
* }
|
|
9
|
-
* ```
|
|
10
|
-
* @typedef {Object.<string, string>} Filters
|
|
11
|
-
* @see {@link DefaultFilters}
|
|
12
|
-
*/
|
|
13
|
-
/**
|
|
14
|
-
* DisTube options.
|
|
15
|
-
* @typedef {Object} DisTubeOptions
|
|
16
|
-
* @prop {Array<Plugin>} [plugins] DisTube plugins.
|
|
17
|
-
* @prop {boolean} [emitNewSongOnly=false] If `true`, {@link DisTube#event:playSong} will not be emitted when looping a song or next song is the same as the previous one
|
|
18
|
-
* @prop {boolean} [leaveOnEmpty=true] Whether or not leaving voice channel if channel is empty in 60s. (Avoid accident leaving)
|
|
19
|
-
* @prop {boolean} [leaveOnFinish=false] Whether or not leaving voice channel when the queue ends.
|
|
20
|
-
* @prop {boolean} [leaveOnStop=true] Whether or not leaving voice channel after using {@link DisTube#stop|stop()} function.
|
|
21
|
-
* @prop {boolean} [savePreviousSongs=true] Whether or not saving the previous songs of the queue and enable {@link DisTube#previous|previous()} method
|
|
22
|
-
* @prop {number} [searchSongs=0] Limit of search results emits in {@link DisTube#event:searchResult} event when {@link DisTube#play|play()} method executed. If `searchSongs <= 1`, play the first result
|
|
23
|
-
* @prop {string} [youtubeCookie=null] YouTube cookies. Read how to get it in {@link https://github.com/fent/node-ytdl-core/blob/997efdd5dd9063363f6ef668bb364e83970756e7/example/cookies.js#L6-L12|YTDL's Example}
|
|
24
|
-
* @prop {string} [youtubeIdentityToken=null] If not given; ytdl-core will try to find it. You can find this by going to a video's watch page; viewing the source; and searching for "ID_TOKEN".
|
|
25
|
-
* @prop {boolean} [youtubeDL=true] Whether or not using youtube-dl.
|
|
26
|
-
* @prop {boolean} [updateYouTubeDL=true] Whether or not updating youtube-dl automatically.
|
|
27
|
-
* @prop {Filters} [customFilters] Override {@link DefaultFilters} or add more ffmpeg filters. Example=`{ "Filter name"="Filter value"; "8d"="apulsator=hz=0.075" }`
|
|
28
|
-
* @prop {Object} [ytdlOptions] `ytdl-core` options
|
|
29
|
-
* @prop {number} [searchCooldown=60] Built-in search cooldown in seconds (When searchSongs is bigger than 0)
|
|
30
|
-
* @prop {number} [emptyCooldown=60] Built-in leave on empty cooldown in seconds (When leaveOnEmpty is true)
|
|
31
|
-
* @prop {boolean} [nsfw=false] Whether or not playing age-restricted content in non-NSFW channel
|
|
32
|
-
*/
|
|
33
|
-
/**
|
|
34
|
-
* DisTube class
|
|
35
|
-
* @extends EventEmitter
|
|
36
|
-
*/
|
|
37
|
-
declare class DisTube extends EventEmitter {
|
|
38
|
-
static get version(): any;
|
|
39
|
-
/**
|
|
40
|
-
* Create a new DisTube class.
|
|
41
|
-
* @param {Discord.Client} client Discord.JS client
|
|
42
|
-
* @param {DisTubeOptions} [otp] Custom DisTube options
|
|
43
|
-
* @example
|
|
44
|
-
* const Discord = require('discord.js'),
|
|
45
|
-
* DisTube = require('distube'),
|
|
46
|
-
* client = new Discord.Client();
|
|
47
|
-
* // Create a new DisTube
|
|
48
|
-
* const distube = new DisTube(client, { searchSongs: 10 });
|
|
49
|
-
* // client.DisTube = distube // make it access easily
|
|
50
|
-
* client.login("Your Discord Bot Token")
|
|
51
|
-
*/
|
|
52
|
-
constructor(client: Discord.Client, otp?: DisTubeOptions);
|
|
53
|
-
/**
|
|
54
|
-
* DisTube's current version.
|
|
55
|
-
* @type {string}
|
|
56
|
-
*/
|
|
57
|
-
get version(): string;
|
|
58
|
-
/**
|
|
59
|
-
* Discord.JS client
|
|
60
|
-
* @type {Discord.Client}
|
|
61
|
-
*/
|
|
62
|
-
client: Discord.Client;
|
|
63
|
-
/**
|
|
64
|
-
* Collection of guild queues
|
|
65
|
-
* @type {Discord.Collection<string, Queue>}
|
|
66
|
-
*/
|
|
67
|
-
guildQueues: Discord.Collection<string, Queue>;
|
|
68
|
-
/**
|
|
69
|
-
* DisTube options
|
|
70
|
-
* @type {DisTubeOptions}
|
|
71
|
-
*/
|
|
72
|
-
options: DisTubeOptions;
|
|
73
|
-
/**
|
|
74
|
-
* DisTube's Handler
|
|
75
|
-
* @type {DisTubeHandler}
|
|
76
|
-
* @private
|
|
77
|
-
*/
|
|
78
|
-
private handler;
|
|
79
|
-
/**
|
|
80
|
-
* DisTube filters
|
|
81
|
-
* @type {Filters}
|
|
82
|
-
*/
|
|
83
|
-
filters: Filters;
|
|
84
|
-
/**
|
|
85
|
-
* Extractor Plugins
|
|
86
|
-
* @type {Array<ExtractorPlugin>}
|
|
87
|
-
* @private
|
|
88
|
-
*/
|
|
89
|
-
private extractorPlugins;
|
|
90
|
-
/**
|
|
91
|
-
* Custom Plugins
|
|
92
|
-
* @type {Array<CustomPlugin>}
|
|
93
|
-
* @private
|
|
94
|
-
*/
|
|
95
|
-
private customPlugins;
|
|
96
|
-
/**
|
|
97
|
-
* Play / add a song or playlist from url. Search and play a song if it is not a valid url.
|
|
98
|
-
* Emit {@link DisTube#addList}, {@link DisTube#addSong} or {@link DisTube#playSong} after executing
|
|
99
|
-
* @returns {Promise<void>}
|
|
100
|
-
* @param {Discord.Message} message A message from guild channel
|
|
101
|
-
* @param {string|Song|SearchResult|Playlist} song YouTube url | Search string | {@link Song} | {@link SearchResult} | {@link Playlist}
|
|
102
|
-
* @param {boolean} skip Whether or not skipping the playing song
|
|
103
|
-
* @example
|
|
104
|
-
* client.on('message', (message) => {
|
|
105
|
-
* if (!message.content.startsWith(config.prefix)) return;
|
|
106
|
-
* const args = message.content.slice(config.prefix.length).trim().split(/ +/g);
|
|
107
|
-
* const command = args.shift();
|
|
108
|
-
* if (command == "play")
|
|
109
|
-
* distube.play(message, args.join(" "));
|
|
110
|
-
* });
|
|
111
|
-
*/
|
|
112
|
-
play(message: Discord.Message, song: string | Song | SearchResult | Playlist, skip?: boolean): Promise<void>;
|
|
113
|
-
/**
|
|
114
|
-
* Play / add a song or playlist from url. Search and play a song if it is not a valid url.
|
|
115
|
-
* Emit {@link DisTube#addList}, {@link DisTube#addSong} or {@link DisTube#playSong} after executing
|
|
116
|
-
* @returns {Promise<void>}
|
|
117
|
-
* @param {Discord.VoiceChannel|Discord.StageChannel} voiceChannel The voice channel will be joined
|
|
118
|
-
* @param {string|Song|SearchResult|Playlist} song YouTube url | Search string | {@link Song} | {@link SearchResult} | {@link Playlist}
|
|
119
|
-
* @param {Object} [options] Optional options
|
|
120
|
-
* @param {Discord.GuildMember} [options.member] Requested user (default is your bot)
|
|
121
|
-
* @param {Discord.TextChannel} [options.textChannel] Default {@link Queue#textChannel} (if the queue wasn't created)
|
|
122
|
-
* @param {boolean} [options.skip] Skip the playing song (if exists)
|
|
123
|
-
*/
|
|
124
|
-
playVoiceChannel(voiceChannel: Discord.VoiceChannel | Discord.StageChannel, song: string | Song | SearchResult | Playlist, options?: {
|
|
125
|
-
member?: Discord.GuildMember;
|
|
126
|
-
textChannel?: Discord.TextChannel;
|
|
127
|
-
skip?: boolean;
|
|
128
|
-
}): Promise<void>;
|
|
129
|
-
/**
|
|
130
|
-
* Skip the playing song and play a song or playlist
|
|
131
|
-
* @returns {Promise<void>}
|
|
132
|
-
* @param {Discord.Message} message A message from guild channel
|
|
133
|
-
* @param {string|Song|SearchResult|Playlist} song YouTube url | Search string | {@link Song} | {@link SearchResult} | {@link Playlist}
|
|
134
|
-
* @example
|
|
135
|
-
* client.on('message', (message) => {
|
|
136
|
-
* if (!message.content.startsWith(config.prefix)) return;
|
|
137
|
-
* const args = message.content.slice(config.prefix.length).trim().split(/ +/g);
|
|
138
|
-
* const command = args.shift();
|
|
139
|
-
* if (command == "playSkip")
|
|
140
|
-
* distube.playSkip(message, args.join(" "));
|
|
141
|
-
* });
|
|
142
|
-
*/
|
|
143
|
-
playSkip(message: Discord.Message, song: string | Song | SearchResult | Playlist): Promise<void>;
|
|
144
|
-
/**
|
|
145
|
-
* Play or add array of video urls.
|
|
146
|
-
* {@link DisTube#event:playList} or {@link DisTube#event:addList} will be emitted
|
|
147
|
-
* with `playlist`'s properties include `properties` parameter's properties such as
|
|
148
|
-
* `user`, `songs`, `duration`, `formattedDuration`, `thumbnail` like {@link Playlist}
|
|
149
|
-
* @returns {Promise<void>}
|
|
150
|
-
* @param {Discord.Message} message A message from guild channel
|
|
151
|
-
* @param {Array<string|Song|SearchResult>} songs Array of url, Song or SearchResult
|
|
152
|
-
* @param {Object} [properties={}] Additional properties such as `name`
|
|
153
|
-
* @param {boolean} [playSkip=false] Whether or not play this playlist instantly
|
|
154
|
-
* @param {boolean} [parallel=true] Whether or not fetch the songs in parallel
|
|
155
|
-
* @example
|
|
156
|
-
* let songs = ["https://www.youtube.com/watch?v=xxx", "https://www.youtube.com/watch?v=yyy"];
|
|
157
|
-
* distube.playCustomPlaylist(message, songs, { name: "My playlist name" });
|
|
158
|
-
* // Fetching custom playlist sequentially (reduce lag for low specs)
|
|
159
|
-
* distube.playCustomPlaylist(message, songs, { name: "My playlist name" }, false, false);
|
|
160
|
-
*/
|
|
161
|
-
playCustomPlaylist(message: Discord.Message, songs: Array<string | Song | SearchResult>, properties?: any, playSkip?: boolean, parallel?: boolean): Promise<void>;
|
|
162
|
-
/**
|
|
163
|
-
* Search for a song.
|
|
164
|
-
* You can customize how user answers instead of send a number.
|
|
165
|
-
* Then use {@link DisTube#play|play(message, aResultFromSearch)} or {@link DisTube#playSkip|playSkip()} to play it.
|
|
166
|
-
* @param {string} string The string search for
|
|
167
|
-
* @param {Object} options Search options
|
|
168
|
-
* @param {number} [options.limit=10] Limit the results
|
|
169
|
-
* @param {'video'|'playlist'} [options.type='video'] Type of search (`video` or `playlist`).
|
|
170
|
-
* @param {boolean} [options.safeSearch=false] Type of search (`video` or `playlist`).
|
|
171
|
-
* @param {boolean} retried Retried?
|
|
172
|
-
* @throws {Error}
|
|
173
|
-
* @returns {Promise<Array<SearchResult>>} Array of results
|
|
174
|
-
*/
|
|
175
|
-
search(string: string, options?: {
|
|
176
|
-
limit?: number;
|
|
177
|
-
type?: 'video' | 'playlist';
|
|
178
|
-
safeSearch?: boolean;
|
|
179
|
-
}, retried?: boolean): Promise<Array<SearchResult>>;
|
|
180
|
-
/**
|
|
181
|
-
* Create a new guild queue
|
|
182
|
-
* @private
|
|
183
|
-
* @param {Discord.Message|Discord.VoiceChannel|Discord.StageChannel} message A message from guild channel | a voice channel
|
|
184
|
-
* @param {Song|Array<Song>} song Song to play
|
|
185
|
-
* @param {Discord.TextChannel} textChannel A text channel of the queue
|
|
186
|
-
* @throws {Error}
|
|
187
|
-
* @returns {Promise<Queue|true>} `true` if queue is not generated
|
|
188
|
-
*/
|
|
189
|
-
private _newQueue;
|
|
190
|
-
/**
|
|
191
|
-
* Delete a guild queue
|
|
192
|
-
* @private
|
|
193
|
-
* @param {Discord.Snowflake|Discord.Message|Queue} queue A message from guild channel | Queue
|
|
194
|
-
*/
|
|
195
|
-
private _deleteQueue;
|
|
196
|
-
/**
|
|
197
|
-
* Get the guild queue
|
|
198
|
-
* @param {Discord.Snowflake|Discord.Message|Discord.VoiceChannel|Discord.StageChannel} message A guild ID | a message from guild channel | a voice channel.
|
|
199
|
-
* @returns {Queue} The guild queue
|
|
200
|
-
* @throws {Error}
|
|
201
|
-
* @example
|
|
202
|
-
* client.on('message', (message) => {
|
|
203
|
-
* if (!message.content.startsWith(config.prefix)) return;
|
|
204
|
-
* const args = message.content.slice(config.prefix.length).trim().split(/ +/g);
|
|
205
|
-
* const command = args.shift();
|
|
206
|
-
* if (command == "queue") {
|
|
207
|
-
* const queue = distube.getQueue(message);
|
|
208
|
-
* message.channel.send('Current queue:\n' + queue.songs.map((song, id) =>
|
|
209
|
-
* `**${id+1}**. [${song.name}](${song.url}) - \`${song.formattedDuration}\``
|
|
210
|
-
* ).join("\n"));
|
|
211
|
-
* }
|
|
212
|
-
* });
|
|
213
|
-
*/
|
|
214
|
-
getQueue(message: Discord.Snowflake | Discord.Message | Discord.VoiceChannel | Discord.StageChannel): Queue;
|
|
215
|
-
/**
|
|
216
|
-
* Pause the guild stream
|
|
217
|
-
* @param {Discord.Snowflake|Discord.Message} message A message from guild channel
|
|
218
|
-
* @returns {Queue} The guild queue
|
|
219
|
-
* @throws {Error}
|
|
220
|
-
*/
|
|
221
|
-
pause(message: Discord.Snowflake | Discord.Message): Queue;
|
|
222
|
-
/**
|
|
223
|
-
* Resume the guild stream
|
|
224
|
-
* @param {Discord.Snowflake|Discord.Message} message A message from guild channel
|
|
225
|
-
* @returns {Queue} The guild queue
|
|
226
|
-
* @throws {Error}
|
|
227
|
-
*/
|
|
228
|
-
resume(message: Discord.Snowflake | Discord.Message): Queue;
|
|
229
|
-
/**
|
|
230
|
-
* Stop the guild stream
|
|
231
|
-
* @param {Discord.Snowflake|Discord.Message} message A message from guild channel or Queue
|
|
232
|
-
* @throws {Error}
|
|
233
|
-
* @example
|
|
234
|
-
* client.on('message', (message) => {
|
|
235
|
-
* if (!message.content.startsWith(config.prefix)) return;
|
|
236
|
-
* const args = message.content.slice(config.prefix.length).trim().split(/ +/g);
|
|
237
|
-
* const command = args.shift();
|
|
238
|
-
* if (command == "stop") {
|
|
239
|
-
* distube.stop(message);
|
|
240
|
-
* message.channel.send("Stopped the queue!");
|
|
241
|
-
* }
|
|
242
|
-
* });
|
|
243
|
-
*/
|
|
244
|
-
stop(message: Discord.Snowflake | Discord.Message): void;
|
|
245
|
-
/**
|
|
246
|
-
* Set the guild stream's volume
|
|
247
|
-
* @param {Discord.Snowflake|Discord.Message} message A message from guild channel
|
|
248
|
-
* @param {number} percent The percentage of volume you want to set
|
|
249
|
-
* @returns {Queue} The guild queue
|
|
250
|
-
* @throws {Error}
|
|
251
|
-
* @example
|
|
252
|
-
* client.on('message', (message) => {
|
|
253
|
-
* if (!message.content.startsWith(config.prefix)) return;
|
|
254
|
-
* const args = message.content.slice(config.prefix.length).trim().split(/ +/g);
|
|
255
|
-
* const command = args.shift();
|
|
256
|
-
* if (command == "volume")
|
|
257
|
-
* distube.setVolume(message, args[0]);
|
|
258
|
-
* });
|
|
259
|
-
*/
|
|
260
|
-
setVolume(message: Discord.Snowflake | Discord.Message, percent: number): Queue;
|
|
261
|
-
/**
|
|
262
|
-
* Skip the playing song
|
|
263
|
-
*
|
|
264
|
-
* @param {Discord.Snowflake|Discord.Message} message A message from guild channel
|
|
265
|
-
* @returns {Queue} The guild queue
|
|
266
|
-
* @throws {Error}
|
|
267
|
-
* @example
|
|
268
|
-
* client.on('message', (message) => {
|
|
269
|
-
* if (!message.content.startsWith(config.prefix)) return;
|
|
270
|
-
* const args = message.content.slice(config.prefix.length).trim().split(/ +/g);
|
|
271
|
-
* const command = args.shift();
|
|
272
|
-
* if (command == "skip")
|
|
273
|
-
* distube.skip(message);
|
|
274
|
-
* });
|
|
275
|
-
*/
|
|
276
|
-
skip(message: Discord.Snowflake | Discord.Message): Queue;
|
|
277
|
-
/**
|
|
278
|
-
* Play the previous song
|
|
279
|
-
*
|
|
280
|
-
* @param {Discord.Snowflake|Discord.Message} message A message from guild channel
|
|
281
|
-
* @returns {Queue} The guild queue
|
|
282
|
-
* @throws {Error}
|
|
283
|
-
* @example
|
|
284
|
-
* client.on('message', (message) => {
|
|
285
|
-
* if (!message.content.startsWith(config.prefix)) return;
|
|
286
|
-
* const args = message.content.slice(config.prefix.length).trim().split(/ +/g);
|
|
287
|
-
* const command = args.shift();
|
|
288
|
-
* if (command == "previous")
|
|
289
|
-
* distube.previous(message);
|
|
290
|
-
* });
|
|
291
|
-
*/
|
|
292
|
-
previous(message: Discord.Snowflake | Discord.Message): Queue;
|
|
293
|
-
/**
|
|
294
|
-
* Shuffle the guild queue songs
|
|
295
|
-
* @param {Discord.Snowflake|Discord.Message} message A message from guild channel
|
|
296
|
-
* @returns {Queue} The guild queue
|
|
297
|
-
* @example
|
|
298
|
-
* client.on('message', (message) => {
|
|
299
|
-
* if (!message.content.startsWith(config.prefix)) return;
|
|
300
|
-
* const args = message.content.slice(config.prefix.length).trim().split(/ +/g);
|
|
301
|
-
* const command = args.shift();
|
|
302
|
-
* if (command == "shuffle")
|
|
303
|
-
* distube.shuffle(message);
|
|
304
|
-
* });
|
|
305
|
-
*/
|
|
306
|
-
shuffle(message: Discord.Snowflake | Discord.Message): Queue;
|
|
307
|
-
/**
|
|
308
|
-
* Jump to the song number in the queue.
|
|
309
|
-
* The next one is 1, 2,...
|
|
310
|
-
* The previous one is -1, -2,...
|
|
311
|
-
* @param {Discord.Snowflake|Discord.Message} message A message from guild channel
|
|
312
|
-
* @param {number} num The song number to play
|
|
313
|
-
* @returns {Queue} The guild queue
|
|
314
|
-
* @throws {InvalidSong} if `num` is invalid number (0 < num < {@link Queue#songs}.length)
|
|
315
|
-
* @example
|
|
316
|
-
* client.on('message', (message) => {
|
|
317
|
-
* if (!message.content.startsWith(config.prefix)) return;
|
|
318
|
-
* const args = message.content.slice(config.prefix.length).trim().split(/ +/g);
|
|
319
|
-
* const command = args.shift();
|
|
320
|
-
* if (command == "jump")
|
|
321
|
-
* distube.jump(message, parseInt(args[0]))
|
|
322
|
-
* .catch(err => message.channel.send("Invalid song number."));
|
|
323
|
-
* });
|
|
324
|
-
*/
|
|
325
|
-
jump(message: Discord.Snowflake | Discord.Message, num: number): Queue;
|
|
326
|
-
/**
|
|
327
|
-
* Set the repeat mode of the guild queue.
|
|
328
|
-
* Turn off if repeat mode is the same value as new mode.
|
|
329
|
-
* Toggle mode: `mode = null` `(0 -> 1 -> 2 -> 0...)`
|
|
330
|
-
*
|
|
331
|
-
* @param {Discord.Snowflake|Discord.Message} message A message from guild channel
|
|
332
|
-
* @param {number} mode The repeat modes `(0: disabled, 1: Repeat a song, 2: Repeat all the queue)`
|
|
333
|
-
* @returns {number} The new repeat mode
|
|
334
|
-
*
|
|
335
|
-
* @example
|
|
336
|
-
* client.on('message', (message) => {
|
|
337
|
-
* if (!message.content.startsWith(config.prefix)) return;
|
|
338
|
-
* const args = message.content.slice(config.prefix.length).trim().split(/ +/g);
|
|
339
|
-
* const command = args.shift();
|
|
340
|
-
* if (command == "repeat") {
|
|
341
|
-
* let mode = distube.setRepeatMode(message, parseInt(args[0]));
|
|
342
|
-
* mode = mode ? mode == 2 ? "Repeat queue" : "Repeat song" : "Off";
|
|
343
|
-
* message.channel.send("Set repeat mode to `" + mode + "`");
|
|
344
|
-
* }
|
|
345
|
-
* });
|
|
346
|
-
*/
|
|
347
|
-
setRepeatMode(message: Discord.Snowflake | Discord.Message, mode?: number): number;
|
|
348
|
-
/**
|
|
349
|
-
* Toggle autoplay mode
|
|
350
|
-
* @param {Discord.Snowflake|Discord.Message} message A message from guild channel
|
|
351
|
-
* @returns {boolean} Autoplay mode state
|
|
352
|
-
* @throws {Error}
|
|
353
|
-
* @example
|
|
354
|
-
* client.on('message', (message) => {
|
|
355
|
-
* if (!message.content.startsWith(config.prefix)) return;
|
|
356
|
-
* const args = message.content.slice(config.prefix.length).trim().split(/ +/g);
|
|
357
|
-
* const command = args.shift();
|
|
358
|
-
* if (command == "autoplay") {
|
|
359
|
-
* let mode = distube.toggleAutoplay(message);
|
|
360
|
-
* message.channel.send("Set autoplay mode to `" + (mode ? "On" : "Off") + "`");
|
|
361
|
-
* }
|
|
362
|
-
* });
|
|
363
|
-
*/
|
|
364
|
-
toggleAutoplay(message: Discord.Snowflake | Discord.Message): boolean;
|
|
365
|
-
/**
|
|
366
|
-
* Whether or not a guild is playing music.
|
|
367
|
-
* @param {Discord.Snowflake|Discord.Message} message A message from guild channel to check
|
|
368
|
-
* @returns {boolean} Whether or not the guild is playing song(s)
|
|
369
|
-
*/
|
|
370
|
-
isPlaying(message: Discord.Snowflake | Discord.Message): boolean;
|
|
371
|
-
/**
|
|
372
|
-
* Whether or not the guild queue is paused
|
|
373
|
-
* @param {Discord.Snowflake|Discord.Message} message A message from guild channel to check
|
|
374
|
-
* @returns {boolean} Whether or not the guild queue is paused
|
|
375
|
-
*/
|
|
376
|
-
isPaused(message: Discord.Snowflake | Discord.Message): boolean;
|
|
377
|
-
/**
|
|
378
|
-
* Add related song to the queue
|
|
379
|
-
* @param {Discord.Snowflake|Discord.Message} message A message from guild channel
|
|
380
|
-
* @returns {Promise<Queue>} The guild queue
|
|
381
|
-
*/
|
|
382
|
-
addRelatedVideo(message: Discord.Snowflake | Discord.Message): Promise<Queue>;
|
|
383
|
-
/**
|
|
384
|
-
* Enable or disable a filter of the queue.
|
|
385
|
-
* Available filters: {@link Filters}
|
|
386
|
-
*
|
|
387
|
-
* @param {Discord.Snowflake|Discord.Message} message A message from guild channel
|
|
388
|
-
* @param {string|false} filter A filter name, `false` to clear all the filters
|
|
389
|
-
* @returns {Array<string>} Enabled filters.
|
|
390
|
-
* @example
|
|
391
|
-
* client.on('message', (message) => {
|
|
392
|
-
* if (!message.content.startsWith(config.prefix)) return;
|
|
393
|
-
* const args = message.content.slice(config.prefix.length).trim().split(/ +/g);
|
|
394
|
-
* const command = args.shift();
|
|
395
|
-
* if ([`3d`, `bassboost`, `echo`, `karaoke`, `nightcore`, `vaporwave`].includes(command)) {
|
|
396
|
-
* let filter = distube.setFilter(message, command);
|
|
397
|
-
* message.channel.send("Current queue filter: " + (filter.join(", ") || "Off"));
|
|
398
|
-
* }
|
|
399
|
-
* });
|
|
400
|
-
*/
|
|
401
|
-
setFilter(message: Discord.Snowflake | Discord.Message, filter: string | false): Array<string>;
|
|
402
|
-
/**
|
|
403
|
-
* Set the playing time to another position
|
|
404
|
-
* @param {Discord.Snowflake|Discord.Message} message A message from guild channel
|
|
405
|
-
* @param {number} time Time in seconds
|
|
406
|
-
* @returns {Queue}
|
|
407
|
-
* @example
|
|
408
|
-
* client.on('message', message => {
|
|
409
|
-
* if (!message.content.startsWith(config.prefix)) return;
|
|
410
|
-
* const args = message.content.slice(config.prefix.length).trim().split(/ +/g);
|
|
411
|
-
* const command = args.shift();
|
|
412
|
-
* if (command = 'seek')
|
|
413
|
-
* distube.seek(message, Number(args[0]));
|
|
414
|
-
* });
|
|
415
|
-
*/
|
|
416
|
-
seek(message: Discord.Snowflake | Discord.Message, time: number): Queue;
|
|
417
|
-
/**
|
|
418
|
-
* Emit error event
|
|
419
|
-
* @param {Discord.TextChannel} channel Text channel where the error is encountered.
|
|
420
|
-
* @param {Error} error error
|
|
421
|
-
* @private
|
|
422
|
-
*/
|
|
423
|
-
private emitError;
|
|
424
|
-
on(
|
|
425
|
-
event: "addList",
|
|
426
|
-
listener: (queue: Queue, playlist: Playlist) => void
|
|
427
|
-
): this;
|
|
428
|
-
on(
|
|
429
|
-
event: "addSong" | "playSong" | "finishSong",
|
|
430
|
-
listener: (queue: Queue, song: Song) => void
|
|
431
|
-
): this;
|
|
432
|
-
on(
|
|
433
|
-
event: "empty" | "finish" | "initQueue" | "noRelated" | "disconnect" | "connect" | "deleteQueue",
|
|
434
|
-
listener: (queue: Queue) => void
|
|
435
|
-
): this;
|
|
436
|
-
on(
|
|
437
|
-
event: "error",
|
|
438
|
-
listener: (channel: Discord.TextChannel, error: Error) => void
|
|
439
|
-
): this;
|
|
440
|
-
on(
|
|
441
|
-
event: "searchNoResult" | "searchCancel",
|
|
442
|
-
listener: (message: Discord.Message, query: string) => void
|
|
443
|
-
): this;
|
|
444
|
-
on(
|
|
445
|
-
event: "searchResult",
|
|
446
|
-
listener: (
|
|
447
|
-
message: Discord.Message,
|
|
448
|
-
results: SearchResult[],
|
|
449
|
-
query: string
|
|
450
|
-
) => void
|
|
451
|
-
): this;
|
|
452
|
-
on(
|
|
453
|
-
event: "searchDone",
|
|
454
|
-
listener: (
|
|
455
|
-
message: Discord.Message,
|
|
456
|
-
answer: Discord.Message,
|
|
457
|
-
query: string
|
|
458
|
-
) => void
|
|
459
|
-
): this;
|
|
460
|
-
}
|
|
461
|
-
declare namespace DisTube {
|
|
462
|
-
export { CustomPlugin, ExtractorPlugin, Playlist, Song, Filters, DisTubeOptions };
|
|
463
|
-
}
|
|
464
|
-
import { EventEmitter } from "events";
|
|
465
|
-
import Discord = require("discord.js");
|
|
466
|
-
import Queue = require("./Queue");
|
|
467
|
-
/**
|
|
468
|
-
* DisTube options.
|
|
469
|
-
*/
|
|
470
|
-
type DisTubeOptions = {
|
|
471
|
-
/**
|
|
472
|
-
* DisTube plugins.
|
|
473
|
-
*/
|
|
474
|
-
plugins?: Array<Plugin>;
|
|
475
|
-
/**
|
|
476
|
-
* If `true`, {@link DisTube#event:playSong} will not be emitted when looping a song or next song is the same as the previous one
|
|
477
|
-
*/
|
|
478
|
-
emitNewSongOnly?: boolean;
|
|
479
|
-
/**
|
|
480
|
-
* Whether or not leaving voice channel if channel is empty in 60s. (Avoid accident leaving)
|
|
481
|
-
*/
|
|
482
|
-
leaveOnEmpty?: boolean;
|
|
483
|
-
/**
|
|
484
|
-
* Whether or not leaving voice channel when the queue ends.
|
|
485
|
-
*/
|
|
486
|
-
leaveOnFinish?: boolean;
|
|
487
|
-
/**
|
|
488
|
-
* Whether or not leaving voice channel after using {@link DisTube#stop|stop()} function.
|
|
489
|
-
*/
|
|
490
|
-
leaveOnStop?: boolean;
|
|
491
|
-
/**
|
|
492
|
-
* Whether or not saving the previous songs of the queue and enable {@link DisTube#previous|previous()} method
|
|
493
|
-
*/
|
|
494
|
-
savePreviousSongs?: boolean;
|
|
495
|
-
/**
|
|
496
|
-
* Limit of search results emits in {@link DisTube#event:searchResult} event when {@link DisTube#play|play()} method executed. If `searchSongs <= 1`, play the first result
|
|
497
|
-
*/
|
|
498
|
-
searchSongs?: number;
|
|
499
|
-
/**
|
|
500
|
-
* YouTube cookies. Read how to get it in {@link https://github.com/fent/node-ytdl-core/blob/997efdd5dd9063363f6ef668bb364e83970756e7/example/cookies.js#L6-L12|YTDL's Example}
|
|
501
|
-
*/
|
|
502
|
-
youtubeCookie?: string;
|
|
503
|
-
/**
|
|
504
|
-
* If not given; ytdl-core will try to find it. You can find this by going to a video's watch page; viewing the source; and searching for "ID_TOKEN".
|
|
505
|
-
*/
|
|
506
|
-
youtubeIdentityToken?: string;
|
|
507
|
-
/**
|
|
508
|
-
* Whether or not using youtube-dl.
|
|
509
|
-
*/
|
|
510
|
-
youtubeDL?: boolean;
|
|
511
|
-
/**
|
|
512
|
-
* Whether or not updating youtube-dl automatically.
|
|
513
|
-
*/
|
|
514
|
-
updateYouTubeDL?: boolean;
|
|
515
|
-
/**
|
|
516
|
-
* Override {@link DefaultFilters} or add more ffmpeg filters. Example=`{ "Filter name"="Filter value"; "8d"="apulsator=hz=0.075" }`
|
|
517
|
-
*/
|
|
518
|
-
customFilters?: Filters;
|
|
519
|
-
/**
|
|
520
|
-
* `ytdl-core` options
|
|
521
|
-
*/
|
|
522
|
-
ytdlOptions?: any;
|
|
523
|
-
/**
|
|
524
|
-
* Built-in search cooldown in seconds (When searchSongs is bigger than 0)
|
|
525
|
-
*/
|
|
526
|
-
searchCooldown?: number;
|
|
527
|
-
/**
|
|
528
|
-
* Built-in leave on empty cooldown in seconds (When leaveOnEmpty is true)
|
|
529
|
-
*/
|
|
530
|
-
emptyCooldown?: number;
|
|
531
|
-
/**
|
|
532
|
-
* Whether or not playing age-restricted content in non-NSFW channel
|
|
533
|
-
*/
|
|
534
|
-
nsfw?: boolean;
|
|
535
|
-
};
|
|
536
|
-
/**
|
|
537
|
-
* FFmpeg Filters
|
|
538
|
-
* ```
|
|
539
|
-
* {
|
|
540
|
-
* "Filter Name": "Filter Value",
|
|
541
|
-
* "bassboost": "bass=g=10,dynaudnorm=f=150:g=15"
|
|
542
|
-
* }
|
|
543
|
-
* ```
|
|
544
|
-
*/
|
|
545
|
-
type Filters = {
|
|
546
|
-
[x: string]: string;
|
|
547
|
-
};
|
|
548
|
-
import Song = require("./Song");
|
|
549
|
-
import SearchResult = require("./SearchResult");
|
|
550
|
-
import Playlist = require("./Playlist");
|
|
551
|
-
import CustomPlugin = require("./Plugin/CustomPlugin");
|
|
552
|
-
import ExtractorPlugin = require("./Plugin/ExtractorPlugin");
|
|
553
|
-
import Plugin = require("./Plugin/Plugin");
|
package/typings/DisTubeBase.d.ts
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
export = DisTubeBase;
|
|
2
|
-
/** @private */
|
|
3
|
-
declare class DisTubeBase {
|
|
4
|
-
/** @param {DisTube} distube distube */
|
|
5
|
-
constructor(distube: DisTube);
|
|
6
|
-
/**
|
|
7
|
-
* DisTube
|
|
8
|
-
* @type {DisTube}
|
|
9
|
-
* @private
|
|
10
|
-
*/
|
|
11
|
-
private distube;
|
|
12
|
-
/**
|
|
13
|
-
* DisTube options
|
|
14
|
-
* @type {DisTube.DisTubeOptions}
|
|
15
|
-
* @private
|
|
16
|
-
*/
|
|
17
|
-
private options;
|
|
18
|
-
/**
|
|
19
|
-
* Discord.js client
|
|
20
|
-
* @type {Discord.Client}
|
|
21
|
-
* @private
|
|
22
|
-
*/
|
|
23
|
-
private client;
|
|
24
|
-
/**
|
|
25
|
-
* Redirect emitter
|
|
26
|
-
* @private
|
|
27
|
-
* @param {...any} args arguments
|
|
28
|
-
*/
|
|
29
|
-
private emit;
|
|
30
|
-
}
|
|
31
|
-
import DisTube = require("./DisTube");
|