distube 3.3.1 → 4.0.0-dev.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -8
- package/dist/DisTube.d.ts +13 -557
- package/dist/DisTube.d.ts.map +1 -1
- package/dist/DisTube.js +38 -639
- package/dist/DisTube.js.map +1 -1
- package/dist/constant.d.ts +0 -101
- package/dist/constant.d.ts.map +1 -1
- package/dist/constant.js +0 -101
- package/dist/constant.js.map +1 -1
- package/dist/core/DisTubeBase.d.ts +0 -40
- package/dist/core/DisTubeBase.d.ts.map +1 -1
- package/dist/core/DisTubeBase.js +0 -44
- package/dist/core/DisTubeBase.js.map +1 -1
- package/dist/core/DisTubeHandler.d.ts +2 -89
- package/dist/core/DisTubeHandler.d.ts.map +1 -1
- package/dist/core/DisTubeHandler.js +14 -124
- package/dist/core/DisTubeHandler.js.map +1 -1
- package/dist/core/DisTubeOptions.d.ts +0 -2
- package/dist/core/DisTubeOptions.d.ts.map +1 -1
- package/dist/core/DisTubeOptions.js +0 -13
- package/dist/core/DisTubeOptions.js.map +1 -1
- package/dist/core/DisTubeStream.d.ts +0 -33
- package/dist/core/DisTubeStream.d.ts.map +1 -1
- package/dist/core/DisTubeStream.js +0 -36
- package/dist/core/DisTubeStream.js.map +1 -1
- package/dist/core/manager/BaseManager.d.ts +1 -16
- package/dist/core/manager/BaseManager.d.ts.map +1 -1
- package/dist/core/manager/BaseManager.js +2 -28
- package/dist/core/manager/BaseManager.js.map +1 -1
- package/dist/core/manager/FilterManager.d.ts +16 -0
- package/dist/core/manager/FilterManager.d.ts.map +1 -0
- package/dist/core/manager/FilterManager.js +88 -0
- package/dist/core/manager/FilterManager.js.map +1 -0
- package/dist/core/manager/GuildIdManager.d.ts +9 -0
- package/dist/core/manager/GuildIdManager.d.ts.map +1 -0
- package/dist/core/manager/GuildIdManager.js +25 -0
- package/dist/core/manager/GuildIdManager.js.map +1 -0
- package/dist/core/manager/QueueManager.d.ts +4 -26
- package/dist/core/manager/QueueManager.d.ts.map +1 -1
- package/dist/core/manager/QueueManager.js +27 -48
- package/dist/core/manager/QueueManager.js.map +1 -1
- package/dist/core/manager/index.d.ts +2 -0
- package/dist/core/manager/index.d.ts.map +1 -1
- package/dist/core/manager/index.js +2 -0
- package/dist/core/manager/index.js.map +1 -1
- package/dist/core/voice/DisTubeVoice.d.ts +0 -50
- package/dist/core/voice/DisTubeVoice.d.ts.map +1 -1
- package/dist/core/voice/DisTubeVoice.js +9 -71
- package/dist/core/voice/DisTubeVoice.js.map +1 -1
- package/dist/core/voice/DisTubeVoiceManager.d.ts +2 -33
- package/dist/core/voice/DisTubeVoiceManager.d.ts.map +1 -1
- package/dist/core/voice/DisTubeVoiceManager.js +1 -32
- package/dist/core/voice/DisTubeVoiceManager.js.map +1 -1
- package/dist/core/voice/index.d.ts +0 -1
- package/dist/core/voice/index.d.ts.map +1 -1
- package/dist/core/voice/index.js +0 -1
- package/dist/core/voice/index.js.map +1 -1
- package/dist/plugin/index.d.ts +0 -1
- package/dist/plugin/index.d.ts.map +1 -1
- package/dist/plugin/index.js +0 -1
- package/dist/plugin/index.js.map +1 -1
- package/dist/struct/CustomPlugin.d.ts +0 -41
- package/dist/struct/CustomPlugin.d.ts.map +1 -1
- package/dist/struct/CustomPlugin.js +0 -34
- package/dist/struct/CustomPlugin.js.map +1 -1
- package/dist/struct/DisTubeError.d.ts +0 -1
- package/dist/struct/DisTubeError.d.ts.map +1 -1
- package/dist/struct/DisTubeError.js +0 -2
- package/dist/struct/DisTubeError.js.map +1 -1
- package/dist/struct/ExtractorPlugin.d.ts +0 -32
- package/dist/struct/ExtractorPlugin.d.ts.map +1 -1
- package/dist/struct/ExtractorPlugin.js +0 -23
- package/dist/struct/ExtractorPlugin.js.map +1 -1
- package/dist/struct/Playlist.d.ts +0 -36
- package/dist/struct/Playlist.d.ts.map +1 -1
- package/dist/struct/Playlist.js +3 -54
- package/dist/struct/Playlist.js.map +1 -1
- package/dist/struct/Plugin.d.ts +0 -58
- package/dist/struct/Plugin.d.ts.map +1 -1
- package/dist/struct/Plugin.js +0 -62
- package/dist/struct/Plugin.js.map +1 -1
- package/dist/struct/Queue.d.ts +10 -177
- package/dist/struct/Queue.d.ts.map +1 -1
- package/dist/struct/Queue.js +49 -256
- package/dist/struct/Queue.js.map +1 -1
- package/dist/struct/SearchResult.d.ts +0 -8
- package/dist/struct/SearchResult.d.ts.map +1 -1
- package/dist/struct/SearchResult.js +0 -47
- package/dist/struct/SearchResult.js.map +1 -1
- package/dist/struct/Song.d.ts +0 -38
- package/dist/struct/Song.d.ts.map +1 -1
- package/dist/struct/Song.js +3 -122
- package/dist/struct/Song.js.map +1 -1
- package/dist/struct/TaskQueue.d.ts +0 -20
- package/dist/struct/TaskQueue.d.ts.map +1 -1
- package/dist/struct/TaskQueue.js +0 -25
- package/dist/struct/TaskQueue.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/type.d.ts +6 -75
- package/dist/type.d.ts.map +1 -1
- package/dist/type.js.map +1 -1
- package/dist/util.d.ts +1 -30
- package/dist/util.d.ts.map +1 -1
- package/dist/util.js +16 -59
- package/dist/util.js.map +1 -1
- package/package.json +22 -14
- package/dist/core/voice/DJSAdapter.d.ts +0 -4
- package/dist/core/voice/DJSAdapter.d.ts.map +0 -1
- package/dist/core/voice/DJSAdapter.js +0 -58
- package/dist/core/voice/DJSAdapter.js.map +0 -1
- package/dist/plugin/youtube-dl.d.ts +0 -12
- package/dist/plugin/youtube-dl.d.ts.map +0 -1
- package/dist/plugin/youtube-dl.js +0 -70
- package/dist/plugin/youtube-dl.js.map +0 -1
package/dist/DisTube.js
CHANGED
|
@@ -9,129 +9,41 @@ const ytsr_1 = __importDefault(require("@distube/ytsr"));
|
|
|
9
9
|
const util_1 = require("./util");
|
|
10
10
|
const tiny_typed_emitter_1 = require("tiny-typed-emitter");
|
|
11
11
|
const _1 = require(".");
|
|
12
|
-
// TODO: remove deprecated stuff on the next major version
|
|
13
|
-
// Cannot be `import` as it's not under TS root dir
|
|
14
|
-
// eslint-disable-next-line @typescript-eslint/no-var-requires, @typescript-eslint/no-require-imports
|
|
15
12
|
exports.version = require("../package.json").version;
|
|
16
|
-
/**
|
|
17
|
-
* DisTube class
|
|
18
|
-
* @extends EventEmitter
|
|
19
|
-
*/
|
|
20
13
|
class DisTube extends tiny_typed_emitter_1.TypedEmitter {
|
|
21
|
-
/**
|
|
22
|
-
* Create a new DisTube class.
|
|
23
|
-
* @param {Discord.Client} client Discord.JS client
|
|
24
|
-
* @param {DisTubeOptions} [otp] Custom DisTube options
|
|
25
|
-
* @example
|
|
26
|
-
* const Discord = require('discord.js'),
|
|
27
|
-
* DisTube = require('distube'),
|
|
28
|
-
* client = new Discord.Client();
|
|
29
|
-
* // Create a new DisTube
|
|
30
|
-
* const distube = new DisTube.default(client, { searchSongs: 10 });
|
|
31
|
-
* // client.DisTube = distube // make it access easily
|
|
32
|
-
* client.login("Your Discord Bot Token")
|
|
33
|
-
*/
|
|
34
14
|
constructor(client, otp = {}) {
|
|
35
15
|
super();
|
|
36
16
|
this.setMaxListeners(1);
|
|
37
17
|
if (!(0, _1.isClientInstance)(client))
|
|
38
18
|
throw new _1.DisTubeError("INVALID_TYPE", "Discord.Client", client, "client");
|
|
39
|
-
/**
|
|
40
|
-
* Discord.JS client
|
|
41
|
-
* @type {Discord.Client}
|
|
42
|
-
*/
|
|
43
19
|
this.client = client;
|
|
44
20
|
(0, util_1.checkIntents)(client.options);
|
|
45
|
-
/**
|
|
46
|
-
* DisTube options
|
|
47
|
-
* @type {DisTubeOptions}
|
|
48
|
-
*/
|
|
49
21
|
this.options = new _1.Options(otp);
|
|
50
|
-
/**
|
|
51
|
-
* Voice connections manager
|
|
52
|
-
* @type {DisTubeVoiceManager}
|
|
53
|
-
*/
|
|
54
22
|
this.voices = new _1.DisTubeVoiceManager(this);
|
|
55
|
-
/**
|
|
56
|
-
* DisTube's Handler
|
|
57
|
-
* @type {DisTubeHandler}
|
|
58
|
-
* @private
|
|
59
|
-
*/
|
|
60
23
|
this.handler = new _1.DisTubeHandler(this);
|
|
61
|
-
/**
|
|
62
|
-
* Queues manager
|
|
63
|
-
* @type {QueueManager}
|
|
64
|
-
*/
|
|
65
24
|
this.queues = new _1.QueueManager(this);
|
|
66
|
-
/**
|
|
67
|
-
* DisTube filters
|
|
68
|
-
* @type {Filters}
|
|
69
|
-
*/
|
|
70
25
|
this.filters = { ..._1.defaultFilters, ...this.options.customFilters };
|
|
71
|
-
// Default plugin
|
|
72
26
|
this.options.plugins.push(new _1.HTTPPlugin(), new _1.HTTPSPlugin());
|
|
73
|
-
if (this.options.youtubeDL)
|
|
74
|
-
this.options.plugins.push(new _1.YouTubeDLPlugin(this.options.updateYouTubeDL));
|
|
75
27
|
this.options.plugins.map(p => p.init(this));
|
|
76
|
-
/**
|
|
77
|
-
* Extractor Plugins
|
|
78
|
-
* @type {ExtractorPlugin[]}
|
|
79
|
-
* @private
|
|
80
|
-
*/
|
|
81
28
|
this.extractorPlugins = this.options.plugins.filter((p) => p.type === "extractor");
|
|
82
|
-
/**
|
|
83
|
-
* Custom Plugins
|
|
84
|
-
* @type {CustomPlugin[]}
|
|
85
|
-
* @private
|
|
86
|
-
*/
|
|
87
29
|
this.customPlugins = this.options.plugins.filter((p) => p.type === "custom");
|
|
88
30
|
}
|
|
89
31
|
static get version() {
|
|
90
32
|
return exports.version;
|
|
91
33
|
}
|
|
92
|
-
/**
|
|
93
|
-
* DisTube version
|
|
94
|
-
* @type {string}
|
|
95
|
-
*/
|
|
96
34
|
get version() {
|
|
97
35
|
return exports.version;
|
|
98
36
|
}
|
|
99
37
|
async play(voiceChannel, song, options = {}) {
|
|
100
|
-
if ((0, _1.isMessageInstance)(voiceChannel)) {
|
|
101
|
-
process.emitWarning("Passing Message for DisTube#play is deprecated, use BaseGuildVoiceChannel instead.", "DeprecationWarning");
|
|
102
|
-
const message = voiceChannel;
|
|
103
|
-
if (!song)
|
|
104
|
-
throw new _1.DisTubeError("INVALID_TYPE", ["string", "Song", "SearchResult", "Playlist"], song, "song");
|
|
105
|
-
if (!(0, _1.isMessageInstance)(message))
|
|
106
|
-
throw new _1.DisTubeError("INVALID_TYPE", "Discord.Message", message, "message");
|
|
107
|
-
if (!(0, util_1.isObject)(options))
|
|
108
|
-
throw new _1.DisTubeError("INVALID_TYPE", "object", options, "options");
|
|
109
|
-
const textChannel = message.channel;
|
|
110
|
-
const { skip, unshift, metadata } = { skip: false, unshift: false, ...options };
|
|
111
|
-
const member = message.member;
|
|
112
|
-
const vc = member.voice.channel;
|
|
113
|
-
if (!vc)
|
|
114
|
-
throw new _1.DisTubeError("NOT_IN_VOICE");
|
|
115
|
-
// eslint-disable-next-line deprecation/deprecation
|
|
116
|
-
return this.play(vc, song, {
|
|
117
|
-
member,
|
|
118
|
-
textChannel,
|
|
119
|
-
skip,
|
|
120
|
-
message,
|
|
121
|
-
unshift,
|
|
122
|
-
metadata,
|
|
123
|
-
});
|
|
124
|
-
}
|
|
125
38
|
if (!(0, _1.isSupportedVoiceChannel)(voiceChannel)) {
|
|
126
39
|
throw new _1.DisTubeError("INVALID_TYPE", "BaseGuildVoiceChannel", voiceChannel, "voiceChannel");
|
|
127
40
|
}
|
|
128
41
|
if (!(0, util_1.isObject)(options))
|
|
129
42
|
throw new _1.DisTubeError("INVALID_TYPE", "object", options, "options");
|
|
130
|
-
|
|
131
|
-
const { textChannel, member, skip, message, unshift, metadata } = {
|
|
43
|
+
const { textChannel, member, skip, message, metadata } = {
|
|
132
44
|
member: voiceChannel.guild.me ?? undefined,
|
|
45
|
+
textChannel: options?.message?.channel,
|
|
133
46
|
skip: false,
|
|
134
|
-
unshift: false,
|
|
135
47
|
...options,
|
|
136
48
|
};
|
|
137
49
|
let position = Number(options.position);
|
|
@@ -141,13 +53,15 @@ class DisTube extends tiny_typed_emitter_1.TypedEmitter {
|
|
|
141
53
|
else
|
|
142
54
|
position = 0;
|
|
143
55
|
}
|
|
144
|
-
if (unshift) {
|
|
145
|
-
process.emitWarning("'unshift' option in DisTube#play is deprecated, use 'position' instead.", "DeprecationWarning");
|
|
146
|
-
position = 1;
|
|
147
|
-
}
|
|
148
56
|
if (message && !(0, _1.isMessageInstance)(message)) {
|
|
149
57
|
throw new _1.DisTubeError("INVALID_TYPE", ["Discord.Message", "a falsy value"], message, "options.message");
|
|
150
58
|
}
|
|
59
|
+
if (textChannel && !(0, _1.isTextChannelInstance)(textChannel)) {
|
|
60
|
+
throw new _1.DisTubeError("INVALID_TYPE", "Discord.GuildTextBasedChannel", textChannel, "options.textChannel");
|
|
61
|
+
}
|
|
62
|
+
if (member && !(0, _1.isMemberInstance)(member)) {
|
|
63
|
+
throw new _1.DisTubeError("INVALID_TYPE", "Discord.GuildMember", member, "options.member");
|
|
64
|
+
}
|
|
151
65
|
try {
|
|
152
66
|
if (typeof song === "string") {
|
|
153
67
|
for (const plugin of this.customPlugins) {
|
|
@@ -157,9 +71,9 @@ class DisTube extends tiny_typed_emitter_1.TypedEmitter {
|
|
|
157
71
|
}
|
|
158
72
|
}
|
|
159
73
|
let queue = this.getQueue(voiceChannel);
|
|
160
|
-
const queuing = !!queue && !queue.
|
|
74
|
+
const queuing = !!queue && !queue._taskQueue.hasResolveTask;
|
|
161
75
|
if (queuing)
|
|
162
|
-
await queue?.
|
|
76
|
+
await queue?._taskQueue.queuing(true);
|
|
163
77
|
try {
|
|
164
78
|
if (song instanceof _1.SearchResult && song.type === "playlist")
|
|
165
79
|
song = song.url;
|
|
@@ -205,7 +119,7 @@ class DisTube extends tiny_typed_emitter_1.TypedEmitter {
|
|
|
205
119
|
}
|
|
206
120
|
finally {
|
|
207
121
|
if (queuing)
|
|
208
|
-
queue?.
|
|
122
|
+
queue?._taskQueue.resolve();
|
|
209
123
|
}
|
|
210
124
|
}
|
|
211
125
|
catch (e) {
|
|
@@ -219,51 +133,6 @@ class DisTube extends tiny_typed_emitter_1.TypedEmitter {
|
|
|
219
133
|
this.emitError(e, textChannel);
|
|
220
134
|
}
|
|
221
135
|
}
|
|
222
|
-
/**
|
|
223
|
-
* Play / add a song or playlist from url. Search and play a song if it is not a valid url.
|
|
224
|
-
*
|
|
225
|
-
* @returns {Promise<void>}
|
|
226
|
-
* @param {Discord.BaseGuildVoiceChannel} voiceChannel The voice channel will be joined
|
|
227
|
-
* @param {string|Song|SearchResult|Playlist} song URL | Search string |
|
|
228
|
-
* {@link Song} | {@link SearchResult} | {@link Playlist}
|
|
229
|
-
* @param {Object} [options] Optional options
|
|
230
|
-
* @param {boolean} [options.skip=false]
|
|
231
|
-
* Skip the playing song (if exists) and play the added song/playlist if `position` is 1.
|
|
232
|
-
* If `position` is defined and not equal to 1, it will skip to the next song instead of the added song
|
|
233
|
-
* @param {number} [options.position=0] Position of the song/playlist to add to the queue,
|
|
234
|
-
* <= 0 to add to the end of the queue.
|
|
235
|
-
* @param {boolean} [options.unshift=false] (DEPRECATED) Add the song/playlist to the beginning of the queue
|
|
236
|
-
* (after the playing song if exists)
|
|
237
|
-
* @param {Discord.GuildMember} [options.member] Requested user (default is your bot)
|
|
238
|
-
* @param {Discord.BaseGuildTextChannel} [options.textChannel] Default {@link Queue#textChannel}
|
|
239
|
-
* @param {Discord.Message} [options.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)
|
|
240
|
-
* @param {*} [options.metadata] Optional metadata that can be attached to the song/playlist will be played,
|
|
241
|
-
* This is useful for identification purposes when the song/playlist is passed around in events.
|
|
242
|
-
* See {@link Song#metadata} or {@link Playlist#metadata}
|
|
243
|
-
* @deprecated Use {@link DisTube#play} instead
|
|
244
|
-
*/
|
|
245
|
-
async playVoiceChannel(voiceChannel, song, options = {}) {
|
|
246
|
-
process.emitWarning("DisTube#playVoiceChannel is deprecated, use DisTube#play instead.", "DeprecationWarning");
|
|
247
|
-
return this.play(voiceChannel, song, options);
|
|
248
|
-
}
|
|
249
|
-
/**
|
|
250
|
-
* Create a custom playlist
|
|
251
|
-
* @returns {Promise<Playlist>}
|
|
252
|
-
* @param {Array<string|Song|SearchResult>} songs Array of url, Song or SearchResult
|
|
253
|
-
* @param {Object} [options] Optional options
|
|
254
|
-
* @param {Discord.GuildMember} [options.message] A message from guild channel | A guild member
|
|
255
|
-
* @param {Object} [options.properties] Additional properties such as `name`
|
|
256
|
-
* @param {boolean} [options.parallel=true] Whether or not fetch the songs in parallel
|
|
257
|
-
* @param {*} [options.metadata] Metadata
|
|
258
|
-
* @example
|
|
259
|
-
* const songs = ["https://www.youtube.com/watch?v=xxx", "https://www.youtube.com/watch?v=yyy"];
|
|
260
|
-
* const playlist = await distube.createCustomPlaylist(songs, {
|
|
261
|
-
* member: message.member,
|
|
262
|
-
* properties: { name: "My playlist name" },
|
|
263
|
-
* parallel: true
|
|
264
|
-
* });
|
|
265
|
-
* distube.play(voiceChannel, playlist, { ... });
|
|
266
|
-
*/
|
|
267
136
|
async createCustomPlaylist(songs, options = {}) {
|
|
268
137
|
const { member, properties, parallel, metadata } = { parallel: true, ...options };
|
|
269
138
|
if (!Array.isArray(songs))
|
|
@@ -292,85 +161,6 @@ class DisTube extends tiny_typed_emitter_1.TypedEmitter {
|
|
|
292
161
|
}
|
|
293
162
|
return new _1.Playlist(resolvedSongs, { member, properties, metadata });
|
|
294
163
|
}
|
|
295
|
-
/**
|
|
296
|
-
* <info>Shorthand method of {@link DisTube#createCustomPlaylist} and {@link DisTube#play}
|
|
297
|
-
*
|
|
298
|
-
* If you doesn't have a user message (interaction,...),
|
|
299
|
-
* see {@link DisTube#createCustomPlaylist} example</info>
|
|
300
|
-
*
|
|
301
|
-
* Play or add array of video urls.
|
|
302
|
-
* {@link DisTube#event:playSong} or {@link DisTube#event:addList} will be emitted
|
|
303
|
-
* with `playlist`'s properties include `properties` parameter's properties such as
|
|
304
|
-
* `user`, `songs`, `duration`, `formattedDuration`, `thumbnail` like {@link Playlist}
|
|
305
|
-
* @returns {Promise<void>}
|
|
306
|
-
* @param {Discord.Message} message A message from guild channel
|
|
307
|
-
* @param {Array<string|Song|SearchResult>} songs Array of url, Song or SearchResult
|
|
308
|
-
* @param {Object} [properties={}] Additional properties for playlist such as `name`
|
|
309
|
-
* @param {Object} [options] Optional options
|
|
310
|
-
* @param {boolean} [options.skip=false] Skip the playing song (if exists) and play the added song/playlist instantly
|
|
311
|
-
* @param {boolean} [options.unshift=false] Add the song/playlist to the beginning of the queue
|
|
312
|
-
* (after the playing song if exists)
|
|
313
|
-
* @param {boolean} [options.parallel=true] Whether or not fetch the songs in parallel
|
|
314
|
-
* @deprecated Use {@link DisTube#createCustomPlaylist} and {@link DisTube#play} instead
|
|
315
|
-
*/
|
|
316
|
-
async playCustomPlaylist(message, songs, properties = {}, options = {}) {
|
|
317
|
-
process.emitWarning("DisTube#playCustomPlaylist is deprecated, use DisTube#createCustomPlaylist and DisTube#play instead.", "DeprecationWarning");
|
|
318
|
-
try {
|
|
319
|
-
if (!(0, util_1.isObject)(options))
|
|
320
|
-
throw new _1.DisTubeError("INVALID_TYPE", "object", options, "options");
|
|
321
|
-
// eslint-disable-next-line deprecation/deprecation
|
|
322
|
-
const { skip, unshift, parallel, metadata } = {
|
|
323
|
-
skip: false,
|
|
324
|
-
unshift: false,
|
|
325
|
-
parallel: true,
|
|
326
|
-
...options,
|
|
327
|
-
};
|
|
328
|
-
let position = Number(options.position);
|
|
329
|
-
if (!position) {
|
|
330
|
-
if (skip && position !== 0)
|
|
331
|
-
position = 1;
|
|
332
|
-
else
|
|
333
|
-
position = 0;
|
|
334
|
-
}
|
|
335
|
-
if (unshift)
|
|
336
|
-
position = 1;
|
|
337
|
-
const queue = this.getQueue(message);
|
|
338
|
-
const queuing = queue && !queue.taskQueue.hasResolveTask;
|
|
339
|
-
if (queuing)
|
|
340
|
-
await queue?.taskQueue.queuing(true);
|
|
341
|
-
try {
|
|
342
|
-
const playlist = await this.createCustomPlaylist(songs, {
|
|
343
|
-
member: message.member ?? undefined,
|
|
344
|
-
properties,
|
|
345
|
-
parallel,
|
|
346
|
-
metadata,
|
|
347
|
-
});
|
|
348
|
-
const voice = message.member?.voice?.channel;
|
|
349
|
-
if (!voice)
|
|
350
|
-
throw new _1.DisTubeError("NOT_IN_VOICE");
|
|
351
|
-
await this.play(voice, playlist, { textChannel: message.channel, skip, position, metadata });
|
|
352
|
-
}
|
|
353
|
-
finally {
|
|
354
|
-
if (queuing)
|
|
355
|
-
queue?.taskQueue.resolve();
|
|
356
|
-
}
|
|
357
|
-
}
|
|
358
|
-
catch (e) {
|
|
359
|
-
this.emitError(e, message.channel);
|
|
360
|
-
}
|
|
361
|
-
}
|
|
362
|
-
/**
|
|
363
|
-
* Search for a song. You can customize how user answers instead of send a number.
|
|
364
|
-
* Then use {@link DisTube#play} to play it.
|
|
365
|
-
*
|
|
366
|
-
* @param {string} string The string search for
|
|
367
|
-
* @param {Object} options Search options
|
|
368
|
-
* @param {number} [options.limit=10] Limit the results
|
|
369
|
-
* @param {'video'|'playlist'} [options.type='video'] Type of results (`video` or `playlist`).
|
|
370
|
-
* @param {boolean} [options.safeSearch=false] Whether or not use safe search (YouTube restricted mode)
|
|
371
|
-
* @throws {Error}
|
|
372
|
-
* @returns {Promise<Array<SearchResult>>} Array of results
|
|
373
|
-
*/
|
|
374
164
|
async search(string, options = {}) {
|
|
375
165
|
const opts = { type: "video", limit: 10, safeSearch: false, ...options };
|
|
376
166
|
if (typeof opts.type !== "string" || !["video", "playlist"].includes(opts.type)) {
|
|
@@ -397,309 +187,84 @@ class DisTube extends tiny_typed_emitter_1.TypedEmitter {
|
|
|
397
187
|
return this.search(string, options);
|
|
398
188
|
}
|
|
399
189
|
}
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
* @param {GuildIdResolvable} queue The type can be resolved to give a {@link Queue}
|
|
403
|
-
* @returns {Queue?}
|
|
404
|
-
* @throws {Error}
|
|
405
|
-
* @example
|
|
406
|
-
* client.on('message', (message) => {
|
|
407
|
-
* if (!message.content.startsWith(config.prefix)) return;
|
|
408
|
-
* const args = message.content.slice(config.prefix.length).trim().split(/ +/g);
|
|
409
|
-
* const command = args.shift();
|
|
410
|
-
* if (command == "queue") {
|
|
411
|
-
* const queue = distube.getQueue(message);
|
|
412
|
-
* message.channel.send('Current queue:\n' + queue.songs.map((song, id) =>
|
|
413
|
-
* `**${id+1}**. [${song.name}](${song.url}) - \`${song.formattedDuration}\``
|
|
414
|
-
* ).join("\n"));
|
|
415
|
-
* }
|
|
416
|
-
* });
|
|
417
|
-
*/
|
|
418
|
-
getQueue(queue) {
|
|
419
|
-
return this.queues.get(queue);
|
|
190
|
+
getQueue(guild) {
|
|
191
|
+
return this.queues.get(guild);
|
|
420
192
|
}
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
* @param {GuildIdResolvable} queue The type can be resolved to give a {@link Queue}
|
|
424
|
-
* @returns {Queue} The guild queue
|
|
425
|
-
* @throws {Error}
|
|
426
|
-
*/
|
|
427
|
-
pause(queue) {
|
|
428
|
-
const q = this.getQueue(queue);
|
|
193
|
+
pause(guild) {
|
|
194
|
+
const q = this.getQueue(guild);
|
|
429
195
|
if (!q)
|
|
430
196
|
throw new _1.DisTubeError("NO_QUEUE");
|
|
431
197
|
return q.pause();
|
|
432
198
|
}
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
* @param {GuildIdResolvable} queue The type can be resolved to give a {@link Queue}
|
|
436
|
-
* @returns {Queue} The guild queue
|
|
437
|
-
* @throws {Error}
|
|
438
|
-
*/
|
|
439
|
-
resume(queue) {
|
|
440
|
-
const q = this.getQueue(queue);
|
|
199
|
+
resume(guild) {
|
|
200
|
+
const q = this.getQueue(guild);
|
|
441
201
|
if (!q)
|
|
442
202
|
throw new _1.DisTubeError("NO_QUEUE");
|
|
443
203
|
return q.resume();
|
|
444
204
|
}
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
* @param {GuildIdResolvable} queue The type can be resolved to give a {@link Queue}
|
|
448
|
-
* @returns {Promise<void>}
|
|
449
|
-
* @throws {Error}
|
|
450
|
-
* @example
|
|
451
|
-
* client.on('message', (message) => {
|
|
452
|
-
* if (!message.content.startsWith(config.prefix)) return;
|
|
453
|
-
* const args = message.content.slice(config.prefix.length).trim().split(/ +/g);
|
|
454
|
-
* const command = args.shift();
|
|
455
|
-
* if (command == "stop") {
|
|
456
|
-
* distube.stop(message);
|
|
457
|
-
* message.channel.send("Stopped the queue!");
|
|
458
|
-
* }
|
|
459
|
-
* });
|
|
460
|
-
*/
|
|
461
|
-
stop(queue) {
|
|
462
|
-
const q = this.getQueue(queue);
|
|
205
|
+
stop(guild) {
|
|
206
|
+
const q = this.getQueue(guild);
|
|
463
207
|
if (!q)
|
|
464
208
|
throw new _1.DisTubeError("NO_QUEUE");
|
|
465
209
|
return q.stop();
|
|
466
210
|
}
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
* @param {GuildIdResolvable} queue The type can be resolved to give a {@link Queue}
|
|
470
|
-
* @param {number} percent The percentage of volume you want to set
|
|
471
|
-
* @returns {Queue} The guild queue
|
|
472
|
-
* @throws {Error}
|
|
473
|
-
* @example
|
|
474
|
-
* client.on('message', (message) => {
|
|
475
|
-
* if (!message.content.startsWith(config.prefix)) return;
|
|
476
|
-
* const args = message.content.slice(config.prefix.length).trim().split(/ +/g);
|
|
477
|
-
* const command = args.shift();
|
|
478
|
-
* if (command == "volume")
|
|
479
|
-
* distube.setVolume(message, Number(args[0]));
|
|
480
|
-
* });
|
|
481
|
-
*/
|
|
482
|
-
setVolume(queue, percent) {
|
|
483
|
-
const q = this.getQueue(queue);
|
|
211
|
+
setVolume(guild, percent) {
|
|
212
|
+
const q = this.getQueue(guild);
|
|
484
213
|
if (!q)
|
|
485
214
|
throw new _1.DisTubeError("NO_QUEUE");
|
|
486
215
|
return q.setVolume(percent);
|
|
487
216
|
}
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
* <info>If {@link Queue#autoplay} is `true` and there is no up next song,
|
|
491
|
-
* DisTube will add and play a related song.</info>
|
|
492
|
-
* @param {GuildIdResolvable} queue The type can be resolved to give a {@link Queue}
|
|
493
|
-
* @returns {Promise<Song>} The new Song will be played
|
|
494
|
-
* @throws {Error}
|
|
495
|
-
* @example
|
|
496
|
-
* client.on('message', (message) => {
|
|
497
|
-
* if (!message.content.startsWith(config.prefix)) return;
|
|
498
|
-
* const args = message.content.slice(config.prefix.length).trim().split(/ +/g);
|
|
499
|
-
* const command = args.shift();
|
|
500
|
-
* if (command == "skip")
|
|
501
|
-
* distube.skip(message);
|
|
502
|
-
* });
|
|
503
|
-
*/
|
|
504
|
-
skip(queue) {
|
|
505
|
-
const q = this.getQueue(queue);
|
|
217
|
+
skip(guild) {
|
|
218
|
+
const q = this.getQueue(guild);
|
|
506
219
|
if (!q)
|
|
507
220
|
throw new _1.DisTubeError("NO_QUEUE");
|
|
508
221
|
return q.skip();
|
|
509
222
|
}
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
* @param {GuildIdResolvable} queue The type can be resolved to give a {@link Queue}
|
|
513
|
-
* @returns {Promise<Song>} The new Song will be played
|
|
514
|
-
* @throws {Error}
|
|
515
|
-
* @example
|
|
516
|
-
* client.on('message', (message) => {
|
|
517
|
-
* if (!message.content.startsWith(config.prefix)) return;
|
|
518
|
-
* const args = message.content.slice(config.prefix.length).trim().split(/ +/g);
|
|
519
|
-
* const command = args.shift();
|
|
520
|
-
* if (command == "previous")
|
|
521
|
-
* distube.previous(message);
|
|
522
|
-
* });
|
|
523
|
-
*/
|
|
524
|
-
previous(queue) {
|
|
525
|
-
const q = this.getQueue(queue);
|
|
223
|
+
previous(guild) {
|
|
224
|
+
const q = this.getQueue(guild);
|
|
526
225
|
if (!q)
|
|
527
226
|
throw new _1.DisTubeError("NO_QUEUE");
|
|
528
227
|
return q.previous();
|
|
529
228
|
}
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
* @param {GuildIdResolvable} queue The type can be resolved to give a {@link Queue}
|
|
533
|
-
* @returns {Promise<Queue>} The guild queue
|
|
534
|
-
* @example
|
|
535
|
-
* client.on('message', (message) => {
|
|
536
|
-
* if (!message.content.startsWith(config.prefix)) return;
|
|
537
|
-
* const args = message.content.slice(config.prefix.length).trim().split(/ +/g);
|
|
538
|
-
* const command = args.shift();
|
|
539
|
-
* if (command == "shuffle")
|
|
540
|
-
* distube.shuffle(message);
|
|
541
|
-
* });
|
|
542
|
-
*/
|
|
543
|
-
shuffle(queue) {
|
|
544
|
-
const q = this.getQueue(queue);
|
|
229
|
+
shuffle(guild) {
|
|
230
|
+
const q = this.getQueue(guild);
|
|
545
231
|
if (!q)
|
|
546
232
|
throw new _1.DisTubeError("NO_QUEUE");
|
|
547
233
|
return q.shuffle();
|
|
548
234
|
}
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
* The next one is 1, 2,...
|
|
552
|
-
* The previous one is -1, -2,...
|
|
553
|
-
* @param {GuildIdResolvable} queue The type can be resolved to give a {@link Queue}
|
|
554
|
-
* @param {number} num The song number to play
|
|
555
|
-
* @returns {Promise<Queue>} The guild queue
|
|
556
|
-
* @throws {Error} if `num` is invalid number (0 < num < {@link Queue#songs}.length)
|
|
557
|
-
* @example
|
|
558
|
-
* client.on('message', (message) => {
|
|
559
|
-
* if (!message.content.startsWith(config.prefix)) return;
|
|
560
|
-
* const args = message.content.slice(config.prefix.length).trim().split(/ +/g);
|
|
561
|
-
* const command = args.shift();
|
|
562
|
-
* if (command == "jump")
|
|
563
|
-
* distube.jump(message, parseInt(args[0]))
|
|
564
|
-
* .catch(err => message.channel.send("Invalid song number."));
|
|
565
|
-
* });
|
|
566
|
-
*/
|
|
567
|
-
jump(queue, num) {
|
|
568
|
-
const q = this.getQueue(queue);
|
|
235
|
+
jump(guild, num) {
|
|
236
|
+
const q = this.getQueue(guild);
|
|
569
237
|
if (!q)
|
|
570
238
|
throw new _1.DisTubeError("NO_QUEUE");
|
|
571
239
|
return q.jump(num);
|
|
572
240
|
}
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
* Toggle mode `(Disabled -> Song -> Queue -> Disabled ->...)` if `mode` is `undefined`
|
|
576
|
-
* @param {GuildIdResolvable} queue The type can be resolved to give a {@link Queue}
|
|
577
|
-
* @param {RepeatMode?} [mode] The repeat modes (toggle if `undefined`)
|
|
578
|
-
* @returns {RepeatMode} The new repeat mode
|
|
579
|
-
* @example
|
|
580
|
-
* client.on('message', (message) => {
|
|
581
|
-
* if (!message.content.startsWith(config.prefix)) return;
|
|
582
|
-
* const args = message.content.slice(config.prefix.length).trim().split(/ +/g);
|
|
583
|
-
* const command = args.shift();
|
|
584
|
-
* if (command == "repeat") {
|
|
585
|
-
* let mode = distube.setRepeatMode(message, parseInt(args[0]));
|
|
586
|
-
* mode = mode ? mode == 2 ? "Repeat queue" : "Repeat song" : "Off";
|
|
587
|
-
* message.channel.send("Set repeat mode to `" + mode + "`");
|
|
588
|
-
* }
|
|
589
|
-
* });
|
|
590
|
-
* @example
|
|
591
|
-
* const { RepeatMode } = require("distube");
|
|
592
|
-
* let mode;
|
|
593
|
-
* switch(distube.setRepeatMode(message, parseInt(args[0]))) {
|
|
594
|
-
* case RepeatMode.DISABLED:
|
|
595
|
-
* mode = "Off";
|
|
596
|
-
* break;
|
|
597
|
-
* case RepeatMode.SONG:
|
|
598
|
-
* mode = "Repeat a song";
|
|
599
|
-
* break;
|
|
600
|
-
* case RepeatMode.QUEUE:
|
|
601
|
-
* mode = "Repeat all queue";
|
|
602
|
-
* break;
|
|
603
|
-
* }
|
|
604
|
-
* message.channel.send("Set repeat mode to `" + mode + "`");
|
|
605
|
-
*/
|
|
606
|
-
setRepeatMode(queue, mode) {
|
|
607
|
-
const q = this.getQueue(queue);
|
|
241
|
+
setRepeatMode(guild, mode) {
|
|
242
|
+
const q = this.getQueue(guild);
|
|
608
243
|
if (!q)
|
|
609
244
|
throw new _1.DisTubeError("NO_QUEUE");
|
|
610
245
|
return q.setRepeatMode(mode);
|
|
611
246
|
}
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
* @param {GuildIdResolvable} queue The type can be resolved to give a {@link Queue}
|
|
615
|
-
* @returns {boolean} Autoplay mode state
|
|
616
|
-
* @throws {Error}
|
|
617
|
-
* @example
|
|
618
|
-
* client.on('message', (message) => {
|
|
619
|
-
* if (!message.content.startsWith(config.prefix)) return;
|
|
620
|
-
* const args = message.content.slice(config.prefix.length).trim().split(/ +/g);
|
|
621
|
-
* const command = args.shift();
|
|
622
|
-
* if (command == "autoplay") {
|
|
623
|
-
* const mode = distube.toggleAutoplay(message);
|
|
624
|
-
* message.channel.send("Set autoplay mode to `" + (mode ? "On" : "Off") + "`");
|
|
625
|
-
* }
|
|
626
|
-
* });
|
|
627
|
-
*/
|
|
628
|
-
toggleAutoplay(queue) {
|
|
629
|
-
const q = this.getQueue(queue);
|
|
247
|
+
toggleAutoplay(guild) {
|
|
248
|
+
const q = this.getQueue(guild);
|
|
630
249
|
if (!q)
|
|
631
250
|
throw new _1.DisTubeError("NO_QUEUE");
|
|
632
251
|
q.autoplay = !q.autoplay;
|
|
633
252
|
return q.autoplay;
|
|
634
253
|
}
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
* @param {GuildIdResolvable} queue The type can be resolved to give a {@link Queue}
|
|
638
|
-
* @returns {Promise<Song>} The guild queue
|
|
639
|
-
*/
|
|
640
|
-
addRelatedSong(queue) {
|
|
641
|
-
const q = this.getQueue(queue);
|
|
254
|
+
addRelatedSong(guild) {
|
|
255
|
+
const q = this.getQueue(guild);
|
|
642
256
|
if (!q)
|
|
643
257
|
throw new _1.DisTubeError("NO_QUEUE");
|
|
644
258
|
return q.addRelatedSong();
|
|
645
259
|
}
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
* Available filters: {@link Filters}
|
|
649
|
-
* @param {GuildIdResolvable} queue The type can be resolved to give a {@link Queue}
|
|
650
|
-
* @param {string|false} filter A filter name, `false` to clear all the filters
|
|
651
|
-
* @param {boolean} [force=false] Force enable the input filter(s) even if it's enabled
|
|
652
|
-
* @returns {Array<string>} Enabled filters.
|
|
653
|
-
* @example
|
|
654
|
-
* client.on('message', (message) => {
|
|
655
|
-
* if (!message.content.startsWith(config.prefix)) return;
|
|
656
|
-
* const args = message.content.slice(config.prefix.length).trim().split(/ +/g);
|
|
657
|
-
* const command = args.shift();
|
|
658
|
-
* if ([`3d`, `bassboost`, `echo`, `karaoke`, `nightcore`, `vaporwave`].includes(command)) {
|
|
659
|
-
* const filter = distube.setFilter(message, command);
|
|
660
|
-
* message.channel.send("Current queue filter: " + (filter.join(", ") || "Off"));
|
|
661
|
-
* }
|
|
662
|
-
* });
|
|
663
|
-
*/
|
|
664
|
-
setFilter(queue, filter, force = false) {
|
|
665
|
-
const q = this.getQueue(queue);
|
|
666
|
-
if (!q)
|
|
667
|
-
throw new _1.DisTubeError("NO_QUEUE");
|
|
668
|
-
return q.setFilter(filter, force);
|
|
669
|
-
}
|
|
670
|
-
/**
|
|
671
|
-
* Set the playing time to another position
|
|
672
|
-
* @param {GuildIdResolvable} queue The type can be resolved to give a {@link Queue}
|
|
673
|
-
* @param {number} time Time in seconds
|
|
674
|
-
* @returns {Queue} Seeked queue
|
|
675
|
-
* @example
|
|
676
|
-
* client.on('message', message => {
|
|
677
|
-
* if (!message.content.startsWith(config.prefix)) return;
|
|
678
|
-
* const args = message.content.slice(config.prefix.length).trim().split(/ +/g);
|
|
679
|
-
* const command = args.shift();
|
|
680
|
-
* if (command = 'seek')
|
|
681
|
-
* distube.seek(message, Number(args[0]));
|
|
682
|
-
* });
|
|
683
|
-
*/
|
|
684
|
-
seek(queue, time) {
|
|
685
|
-
const q = this.getQueue(queue);
|
|
260
|
+
seek(guild, time) {
|
|
261
|
+
const q = this.getQueue(guild);
|
|
686
262
|
if (!q)
|
|
687
263
|
throw new _1.DisTubeError("NO_QUEUE");
|
|
688
264
|
return q.seek(time);
|
|
689
265
|
}
|
|
690
|
-
/* eslint-disable no-console */
|
|
691
|
-
/**
|
|
692
|
-
* Emit error event
|
|
693
|
-
* @param {Error} error error
|
|
694
|
-
* @param {Discord.BaseGuildTextChannel} [channel] Text channel where the error is encountered.
|
|
695
|
-
* @private
|
|
696
|
-
*/
|
|
697
266
|
emitError(error, channel) {
|
|
698
|
-
if (
|
|
699
|
-
console.error(error);
|
|
700
|
-
console.warn("This is logged because <Queue>.textChannel is undefined");
|
|
701
|
-
}
|
|
702
|
-
else if (this.listeners("error").length) {
|
|
267
|
+
if (this.listeners("error").length) {
|
|
703
268
|
this.emit("error", channel, error);
|
|
704
269
|
}
|
|
705
270
|
else {
|
|
@@ -711,170 +276,4 @@ class DisTube extends tiny_typed_emitter_1.TypedEmitter {
|
|
|
711
276
|
}
|
|
712
277
|
exports.DisTube = DisTube;
|
|
713
278
|
exports.default = DisTube;
|
|
714
|
-
/**
|
|
715
|
-
* Emitted after DisTube add a new playlist to the playing {@link Queue}.
|
|
716
|
-
*
|
|
717
|
-
* @event DisTube#addList
|
|
718
|
-
* @param {Queue} queue The guild queue
|
|
719
|
-
* @param {Playlist} playlist Playlist info
|
|
720
|
-
* @example
|
|
721
|
-
* distube.on("addList", (queue, playlist) => queue.textChannel.send(
|
|
722
|
-
* `Added \`${playlist.name}\` playlist (${playlist.songs.length} songs) to the queue!`
|
|
723
|
-
* ));
|
|
724
|
-
*/
|
|
725
|
-
/**
|
|
726
|
-
* Emitted after DisTube add a new song to the playing {@link Queue}.
|
|
727
|
-
*
|
|
728
|
-
* @event DisTube#addSong
|
|
729
|
-
* @param {Queue} queue The guild queue
|
|
730
|
-
* @param {Song} song Added song
|
|
731
|
-
* @example
|
|
732
|
-
* distube.on("addSong", (queue, song) => queue.textChannel.send(
|
|
733
|
-
* `Added ${song.name} - \`${song.formattedDuration}\` to the queue by ${song.user}.`
|
|
734
|
-
* ));
|
|
735
|
-
*/
|
|
736
|
-
/**
|
|
737
|
-
* Emitted when there is no user in the voice channel,
|
|
738
|
-
* {@link DisTubeOptions}.leaveOnEmpty is `true` and there is a playing queue.
|
|
739
|
-
*
|
|
740
|
-
* If there is no playing queue (stopped and {@link DisTubeOptions}.leaveOnStop is `false`),
|
|
741
|
-
* it will leave the channel without emitting this event.
|
|
742
|
-
* @event DisTube#empty
|
|
743
|
-
* @param {Queue} queue The guild queue
|
|
744
|
-
* @example
|
|
745
|
-
* distube.on("empty", queue => queue.textChannel.send("Channel is empty. Leaving the channel"))
|
|
746
|
-
*/
|
|
747
|
-
/**
|
|
748
|
-
* Emitted when DisTube encounters an error.
|
|
749
|
-
*
|
|
750
|
-
* @event DisTube#error
|
|
751
|
-
* @param {Discord.BaseGuildTextChannel} channel Text channel where the error is encountered.
|
|
752
|
-
* @param {Error} error The error encountered
|
|
753
|
-
* @example
|
|
754
|
-
* distube.on("error", (channel, error) => channel.send(
|
|
755
|
-
* "An error encountered: " + error
|
|
756
|
-
* ));
|
|
757
|
-
*/
|
|
758
|
-
/**
|
|
759
|
-
* Emitted when there is no more song in the queue and {@link Queue#autoplay} is `false`.
|
|
760
|
-
* DisTube will leave voice channel if {@link DisTubeOptions}.leaveOnFinish is `true`.
|
|
761
|
-
*
|
|
762
|
-
* @event DisTube#finish
|
|
763
|
-
* @param {Queue} queue The guild queue
|
|
764
|
-
* @example
|
|
765
|
-
* distube.on("finish", queue => queue.textChannel.send("No more song in queue"));
|
|
766
|
-
*/
|
|
767
|
-
/**
|
|
768
|
-
* Emitted when DisTube initialize a queue to change queue default properties.
|
|
769
|
-
*
|
|
770
|
-
* @event DisTube#initQueue
|
|
771
|
-
* @param {Queue} queue The guild queue
|
|
772
|
-
* @example
|
|
773
|
-
* distube.on("initQueue", queue => {
|
|
774
|
-
* queue.autoplay = false;
|
|
775
|
-
* queue.volume = 100;
|
|
776
|
-
* });
|
|
777
|
-
*/
|
|
778
|
-
/**
|
|
779
|
-
* Emitted when {@link Queue#autoplay} is `true`, {@link Queue#songs} is empty,
|
|
780
|
-
* and DisTube cannot find related songs to play.
|
|
781
|
-
*
|
|
782
|
-
* @event DisTube#noRelated
|
|
783
|
-
* @param {Queue} queue The guild queue
|
|
784
|
-
* @example
|
|
785
|
-
* distube.on("noRelated", queue => queue.textChannel.send("Can't find related video to play."));
|
|
786
|
-
*/
|
|
787
|
-
/**
|
|
788
|
-
* Emitted when DisTube play a song.
|
|
789
|
-
*
|
|
790
|
-
* If {@link DisTubeOptions}.emitNewSongOnly is `true`,
|
|
791
|
-
* this event is not emitted when looping a song or next song is the previous one.
|
|
792
|
-
*
|
|
793
|
-
* @event DisTube#playSong
|
|
794
|
-
* @param {Queue} queue The guild queue
|
|
795
|
-
* @param {Song} song Playing song
|
|
796
|
-
* @example
|
|
797
|
-
* distube.on("playSong", (queue, song) => queue.textChannel.send(
|
|
798
|
-
* `Playing \`${song.name}\` - \`${song.formattedDuration}\`\nRequested by: ${song.user}`
|
|
799
|
-
* ));
|
|
800
|
-
*/
|
|
801
|
-
/**
|
|
802
|
-
* Emitted when DisTube cannot find any results for the query.
|
|
803
|
-
*
|
|
804
|
-
* @event DisTube#searchNoResult
|
|
805
|
-
* @param {Discord.Message} message The user message called play method
|
|
806
|
-
* @param {string} query The search query
|
|
807
|
-
* @example
|
|
808
|
-
* distube.on("searchNoResult", (message, query) => message.channel.send(`No result found for ${query}!`));
|
|
809
|
-
*/
|
|
810
|
-
/**
|
|
811
|
-
* Emitted when {@link DisTubeOptions|DisTubeOptions.searchSongs} bigger than 0,
|
|
812
|
-
* and song param of {@link DisTube#play} is invalid url.
|
|
813
|
-
* DisTube will wait for user's next message to choose a song manually.
|
|
814
|
-
* <info>{@link https://support.google.com/youtube/answer/7354993|Safe search} is enabled
|
|
815
|
-
* if {@link DisTubeOptions}.nsfw is disabled and the message's channel is not a nsfw channel.</info>
|
|
816
|
-
*
|
|
817
|
-
* @event DisTube#searchResult
|
|
818
|
-
* @param {Discord.Message} message The user message called play method
|
|
819
|
-
* @param {Array<SearchResult>} results Searched results
|
|
820
|
-
* @param {string} query The search query
|
|
821
|
-
* @example
|
|
822
|
-
* // DisTubeOptions.searchSongs > 0
|
|
823
|
-
* distube.on("searchResult", (message, results) => {
|
|
824
|
-
* message.channel.send(`**Choose an option from below**\n${
|
|
825
|
-
* results.map((song, i) => `**${i + 1}**. ${song.name} - \`${song.formattedDuration}\``).join("\n")
|
|
826
|
-
* }\n*Enter anything else or wait 60 seconds to cancel*`);
|
|
827
|
-
* });
|
|
828
|
-
*/
|
|
829
|
-
/**
|
|
830
|
-
* Emitted when {@link DisTubeOptions|DisTubeOptions.searchSongs} bigger than 0,
|
|
831
|
-
* and the search canceled due to {@link DisTubeOptions|DisTubeOptions.searchTimeout}.
|
|
832
|
-
*
|
|
833
|
-
* @event DisTube#searchCancel
|
|
834
|
-
* @param {Discord.Message} message The user message called play method
|
|
835
|
-
* @param {string} query The search query
|
|
836
|
-
* @example
|
|
837
|
-
* // DisTubeOptions.searchSongs > 0
|
|
838
|
-
* distube.on("searchCancel", (message) => message.channel.send(`Searching canceled`));
|
|
839
|
-
*/
|
|
840
|
-
/**
|
|
841
|
-
* Emitted when {@link DisTubeOptions|DisTubeOptions.searchSongs} bigger than 0,
|
|
842
|
-
* and the search canceled due to user's next message is not a number or out of results range.
|
|
843
|
-
*
|
|
844
|
-
* @event DisTube#searchInvalidAnswer
|
|
845
|
-
* @param {Discord.Message} message The user message called play method
|
|
846
|
-
* @param {Discord.Message} answer The answered message of user
|
|
847
|
-
* @param {string} query The search query
|
|
848
|
-
* @example
|
|
849
|
-
* // DisTubeOptions.searchSongs > 0
|
|
850
|
-
* distube.on("searchInvalidAnswer", (message) => message.channel.send(`You answered an invalid number!`));
|
|
851
|
-
*/
|
|
852
|
-
/**
|
|
853
|
-
* Emitted when {@link DisTubeOptions|DisTubeOptions.searchSongs} bigger than 0,
|
|
854
|
-
* and after the user chose a search result to play.
|
|
855
|
-
*
|
|
856
|
-
* @event DisTube#searchDone
|
|
857
|
-
* @param {Discord.Message} message The user message called play method
|
|
858
|
-
* @param {Discord.Message} answer The answered message of user
|
|
859
|
-
* @param {string} query The search query
|
|
860
|
-
*/
|
|
861
|
-
/**
|
|
862
|
-
* Emitted when the bot is disconnected to a voice channel.
|
|
863
|
-
*
|
|
864
|
-
* @event DisTube#disconnect
|
|
865
|
-
* @param {Queue} queue The guild queue
|
|
866
|
-
*/
|
|
867
|
-
/**
|
|
868
|
-
* Emitted when a {@link Queue} is deleted with any reasons.
|
|
869
|
-
*
|
|
870
|
-
* @event DisTube#deleteQueue
|
|
871
|
-
* @param {Queue} queue The guild queue
|
|
872
|
-
*/
|
|
873
|
-
/**
|
|
874
|
-
* Emitted when DisTube finished a song.
|
|
875
|
-
*
|
|
876
|
-
* @event DisTube#finishSong
|
|
877
|
-
* @param {Queue} queue The guild queue
|
|
878
|
-
* @param {Song} song Finished song
|
|
879
|
-
*/
|
|
880
279
|
//# sourceMappingURL=DisTube.js.map
|