discord-player 5.3.0-dev.1 → 5.3.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/dist/Player.js
CHANGED
|
@@ -23,7 +23,7 @@ class Player extends tiny_typed_emitter_1.TypedEmitter {
|
|
|
23
23
|
/**
|
|
24
24
|
* Creates new Discord Player
|
|
25
25
|
* @param {Client} client The Discord Client
|
|
26
|
-
* @param {PlayerInitOptions} [options
|
|
26
|
+
* @param {PlayerInitOptions} [options] The player init options
|
|
27
27
|
*/
|
|
28
28
|
constructor(client, options = {}) {
|
|
29
29
|
super();
|
|
@@ -80,23 +80,29 @@ class Player extends tiny_typed_emitter_1.TypedEmitter {
|
|
|
80
80
|
return void this.emit("botDisconnect", queue);
|
|
81
81
|
}
|
|
82
82
|
if (!oldState.channelId && newState.channelId && newState.member.id === newState.guild.members.me.id) {
|
|
83
|
-
if (oldState.serverMute
|
|
84
|
-
|
|
83
|
+
if (!oldState.serverMute && newState.serverMute) {
|
|
84
|
+
// state.serverMute can be null
|
|
85
|
+
queue.setPaused(!!newState.serverMute);
|
|
85
86
|
}
|
|
86
|
-
else if (oldState.suppress
|
|
87
|
-
|
|
87
|
+
else if (!oldState.suppress && newState.suppress) {
|
|
88
|
+
// state.suppress can be null
|
|
89
|
+
queue.setPaused(!!newState.suppress);
|
|
90
|
+
if (newState.suppress) {
|
|
88
91
|
newState.guild.members.me.voice.setRequestToSpeak(true).catch(Util_1.Util.noop);
|
|
89
|
-
|
|
92
|
+
}
|
|
90
93
|
}
|
|
91
94
|
}
|
|
92
95
|
if (oldState.channelId === newState.channelId && newState.member.id === newState.guild.members.me.id) {
|
|
93
|
-
if (oldState.serverMute
|
|
94
|
-
|
|
96
|
+
if (!oldState.serverMute && newState.serverMute) {
|
|
97
|
+
// state.serverMute can be null
|
|
98
|
+
queue.setPaused(!!newState.serverMute);
|
|
95
99
|
}
|
|
96
|
-
else if (oldState.suppress
|
|
97
|
-
|
|
100
|
+
else if (!oldState.suppress && newState.suppress) {
|
|
101
|
+
// state.suppress can be null
|
|
102
|
+
queue.setPaused(!!newState.suppress);
|
|
103
|
+
if (newState.suppress) {
|
|
98
104
|
newState.guild.members.me.voice.setRequestToSpeak(true).catch(Util_1.Util.noop);
|
|
99
|
-
|
|
105
|
+
}
|
|
100
106
|
}
|
|
101
107
|
}
|
|
102
108
|
if (queue.connection && !newState.channelId && oldState.channelId === queue.connection.channel.id) {
|
|
@@ -401,9 +407,9 @@ class Player extends tiny_typed_emitter_1.TypedEmitter {
|
|
|
401
407
|
const data = new Track_1.default(this, {
|
|
402
408
|
title: m.track.name ?? "",
|
|
403
409
|
description: m.track.description ?? "",
|
|
404
|
-
author: m.track.artists[0]?.name ?? "Unknown Artist",
|
|
410
|
+
author: m.track.artists?.[0]?.name ?? "Unknown Artist",
|
|
405
411
|
url: m.track.external_urls?.spotify ?? query,
|
|
406
|
-
thumbnail: m.track.album?.images[0]?.url ?? "https://www.scdn.co/i/_global/twitter_card-default.jpg",
|
|
412
|
+
thumbnail: m.track.album?.images?.[0]?.url ?? "https://www.scdn.co/i/_global/twitter_card-default.jpg",
|
|
407
413
|
duration: Util_1.Util.buildTimeCode(Util_1.Util.parseMS(m.track.duration_ms)),
|
|
408
414
|
views: 0,
|
|
409
415
|
requestedBy: options.requestedBy,
|
|
@@ -564,5 +570,12 @@ class Player extends tiny_typed_emitter_1.TypedEmitter {
|
|
|
564
570
|
*[Symbol.iterator]() {
|
|
565
571
|
yield* Array.from(this.queues.values());
|
|
566
572
|
}
|
|
573
|
+
/**
|
|
574
|
+
* Creates `Playlist` instance
|
|
575
|
+
* @param data The data to initialize a playlist
|
|
576
|
+
*/
|
|
577
|
+
createPlaylist(data) {
|
|
578
|
+
return new Playlist_1.Playlist(this, data);
|
|
579
|
+
}
|
|
567
580
|
}
|
|
568
581
|
exports.Player = Player;
|
package/dist/Structures/Queue.js
CHANGED
|
@@ -17,7 +17,7 @@ class Queue {
|
|
|
17
17
|
* Queue constructor
|
|
18
18
|
* @param {Player} player The player that instantiated this queue
|
|
19
19
|
* @param {Guild} guild The guild that instantiated this queue
|
|
20
|
-
* @param {PlayerOptions} [options
|
|
20
|
+
* @param {PlayerOptions} [options] Player options for the queue
|
|
21
21
|
*/
|
|
22
22
|
constructor(player, guild, options = {}) {
|
|
23
23
|
_Queue_instances.add(this);
|
|
@@ -191,9 +191,6 @@ class Queue {
|
|
|
191
191
|
return;
|
|
192
192
|
}
|
|
193
193
|
});
|
|
194
|
-
await this.player.voiceUtils.enterReady(this.connection.voiceConnection, {
|
|
195
|
-
maxTime: this.player.options.connectionTimeout || 30000
|
|
196
|
-
});
|
|
197
194
|
return this;
|
|
198
195
|
}
|
|
199
196
|
/**
|
|
@@ -609,7 +606,7 @@ class Queue {
|
|
|
609
606
|
/**
|
|
610
607
|
* Play stream in a voice/stage channel
|
|
611
608
|
* @param {Track} [src] The track to play (if empty, uses first track from the queue)
|
|
612
|
-
* @param {PlayOptions} [options
|
|
609
|
+
* @param {PlayOptions} [options] The options
|
|
613
610
|
* @returns {Promise<void>}
|
|
614
611
|
*/
|
|
615
612
|
async play(src, options = {}) {
|
|
@@ -720,9 +717,14 @@ class Queue {
|
|
|
720
717
|
this.destroy();
|
|
721
718
|
return void this.player.emit("queueEnd", this);
|
|
722
719
|
}
|
|
723
|
-
|
|
720
|
+
let info = await youtube_sr_1.default.getVideo(track.url)
|
|
724
721
|
.then((x) => x.videos[0])
|
|
725
722
|
.catch(Util_1.Util.noop);
|
|
723
|
+
// fallback
|
|
724
|
+
if (!info)
|
|
725
|
+
info = await youtube_sr_1.default.search(track.author)
|
|
726
|
+
.then((x) => x[0])
|
|
727
|
+
.catch(Util_1.Util.noop);
|
|
726
728
|
if (!info) {
|
|
727
729
|
if (this.options.leaveOnEnd)
|
|
728
730
|
this.destroy();
|
|
@@ -106,7 +106,7 @@ class StreamDispatcher extends tiny_typed_emitter_1.TypedEmitter {
|
|
|
106
106
|
/**
|
|
107
107
|
* Creates stream
|
|
108
108
|
* @param {Readable|Duplex|string} src The stream source
|
|
109
|
-
* @param {object} [ops
|
|
109
|
+
* @param {object} [ops] Options
|
|
110
110
|
* @returns {AudioResource}
|
|
111
111
|
*/
|
|
112
112
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
@@ -19,7 +19,7 @@ class VoiceUtils {
|
|
|
19
19
|
/**
|
|
20
20
|
* Joins a voice channel, creating basic stream dispatch manager
|
|
21
21
|
* @param {StageChannel|VoiceChannel} channel The voice channel
|
|
22
|
-
* @param {object} [options
|
|
22
|
+
* @param {object} [options] Join options
|
|
23
23
|
* @returns {Promise<StreamDispatcher>}
|
|
24
24
|
*/
|
|
25
25
|
async connect(channel, options) {
|
|
@@ -31,7 +31,7 @@ class VoiceUtils {
|
|
|
31
31
|
/**
|
|
32
32
|
* Joins a voice channel
|
|
33
33
|
* @param {StageChannel|VoiceChannel} [channel] The voice/stage channel to join
|
|
34
|
-
* @param {object} [options
|
|
34
|
+
* @param {object} [options] Join options
|
|
35
35
|
* @returns {VoiceConnection}
|
|
36
36
|
*/
|
|
37
37
|
async join(channel, options) {
|
|
@@ -43,16 +43,6 @@ class VoiceUtils {
|
|
|
43
43
|
});
|
|
44
44
|
return conn;
|
|
45
45
|
}
|
|
46
|
-
async enterReady(conn, options = {}) {
|
|
47
|
-
try {
|
|
48
|
-
conn = await (0, voice_1.entersState)(conn, voice_1.VoiceConnectionStatus.Ready, options?.maxTime ?? 20000);
|
|
49
|
-
return conn;
|
|
50
|
-
}
|
|
51
|
-
catch (err) {
|
|
52
|
-
conn.destroy();
|
|
53
|
-
throw err;
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
46
|
/**
|
|
57
47
|
* Disconnects voice connection
|
|
58
48
|
* @param {VoiceConnection} connection The voice connection
|
package/dist/index.d.ts
CHANGED
|
@@ -106,7 +106,7 @@ declare class StreamDispatcher extends TypedEmitter<VoiceEvents> {
|
|
|
106
106
|
/**
|
|
107
107
|
* Creates stream
|
|
108
108
|
* @param {Readable|Duplex|string} src The stream source
|
|
109
|
-
* @param {object} [ops
|
|
109
|
+
* @param {object} [ops] Options
|
|
110
110
|
* @returns {AudioResource}
|
|
111
111
|
*/
|
|
112
112
|
createStream(src: Readable | Duplex | string, ops?: {
|
|
@@ -174,7 +174,7 @@ declare class VoiceUtils {
|
|
|
174
174
|
/**
|
|
175
175
|
* Joins a voice channel, creating basic stream dispatch manager
|
|
176
176
|
* @param {StageChannel|VoiceChannel} channel The voice channel
|
|
177
|
-
* @param {object} [options
|
|
177
|
+
* @param {object} [options] Join options
|
|
178
178
|
* @returns {Promise<StreamDispatcher>}
|
|
179
179
|
*/
|
|
180
180
|
connect(channel: VoiceChannel | StageChannel, options?: {
|
|
@@ -184,16 +184,13 @@ declare class VoiceUtils {
|
|
|
184
184
|
/**
|
|
185
185
|
* Joins a voice channel
|
|
186
186
|
* @param {StageChannel|VoiceChannel} [channel] The voice/stage channel to join
|
|
187
|
-
* @param {object} [options
|
|
187
|
+
* @param {object} [options] Join options
|
|
188
188
|
* @returns {VoiceConnection}
|
|
189
189
|
*/
|
|
190
190
|
join(channel: VoiceChannel | StageChannel, options?: {
|
|
191
191
|
deaf?: boolean;
|
|
192
192
|
maxTime?: number;
|
|
193
193
|
}): Promise<VoiceConnection>;
|
|
194
|
-
enterReady(conn: VoiceConnection, options?: {
|
|
195
|
-
maxTime?: number;
|
|
196
|
-
}): Promise<VoiceConnection>;
|
|
197
194
|
/**
|
|
198
195
|
* Disconnects voice connection
|
|
199
196
|
* @param {VoiceConnection} connection The voice connection
|
|
@@ -246,7 +243,7 @@ declare class Player extends TypedEmitter<PlayerEvents> {
|
|
|
246
243
|
/**
|
|
247
244
|
* Creates new Discord Player
|
|
248
245
|
* @param {Client} client The Discord Client
|
|
249
|
-
* @param {PlayerInitOptions} [options
|
|
246
|
+
* @param {PlayerInitOptions} [options] The player init options
|
|
250
247
|
*/
|
|
251
248
|
constructor(client: Client, options?: PlayerInitOptions);
|
|
252
249
|
/**
|
|
@@ -317,6 +314,11 @@ declare class Player extends TypedEmitter<PlayerEvents> {
|
|
|
317
314
|
*/
|
|
318
315
|
resolveQueue<T>(queueLike: GuildResolvable | Queue): Queue<T>;
|
|
319
316
|
[Symbol.iterator](): Generator<Queue<unknown>, void, undefined>;
|
|
317
|
+
/**
|
|
318
|
+
* Creates `Playlist` instance
|
|
319
|
+
* @param data The data to initialize a playlist
|
|
320
|
+
*/
|
|
321
|
+
createPlaylist(data: PlaylistInitData): Playlist;
|
|
320
322
|
}
|
|
321
323
|
|
|
322
324
|
declare class Queue<T = unknown> {
|
|
@@ -340,7 +342,7 @@ declare class Queue<T = unknown> {
|
|
|
340
342
|
* Queue constructor
|
|
341
343
|
* @param {Player} player The player that instantiated this queue
|
|
342
344
|
* @param {Guild} guild The guild that instantiated this queue
|
|
343
|
-
* @param {PlayerOptions} [options
|
|
345
|
+
* @param {PlayerOptions} [options] Player options for the queue
|
|
344
346
|
*/
|
|
345
347
|
constructor(player: Player, guild: Guild, options?: PlayerOptions);
|
|
346
348
|
/**
|
|
@@ -522,7 +524,7 @@ declare class Queue<T = unknown> {
|
|
|
522
524
|
/**
|
|
523
525
|
* Play stream in a voice/stage channel
|
|
524
526
|
* @param {Track} [src] The track to play (if empty, uses first track from the queue)
|
|
525
|
-
* @param {PlayOptions} [options
|
|
527
|
+
* @param {PlayOptions} [options] The options
|
|
526
528
|
* @returns {Promise<void>}
|
|
527
529
|
*/
|
|
528
530
|
play(src?: Track, options?: PlayOptions): Promise<void>;
|
|
@@ -670,12 +672,12 @@ interface PlayerProgressbarOptions {
|
|
|
670
672
|
* @property {boolean} [leaveOnEmpty=true] If it should leave on empty
|
|
671
673
|
* @property {number} [leaveOnEmptyCooldown=1000] The cooldown in ms
|
|
672
674
|
* @property {boolean} [autoSelfDeaf=true] If it should set the bot in deaf mode
|
|
673
|
-
* @property {YTDLDownloadOptions} [ytdlOptions
|
|
675
|
+
* @property {YTDLDownloadOptions} [ytdlOptions] The youtube download options
|
|
674
676
|
* @property {number} [initialVolume=100] The initial player volume
|
|
675
677
|
* @property {number} [bufferingTimeout=3000] Buffering timeout for the stream
|
|
676
678
|
* @property {boolean} [spotifyBridge=true] If player should bridge spotify source to youtube
|
|
677
679
|
* @property {boolean} [disableVolume=false] If player should disable inline volume
|
|
678
|
-
* @property {
|
|
680
|
+
* @property {number} [volumeSmoothness=0] The volume transition smoothness between volume changes (lower the value to get better result)
|
|
679
681
|
* Setting this or leaving this empty will disable this effect. Example: `volumeSmoothness: 0.1`
|
|
680
682
|
* @property {Function} [onBeforeCreateStream] Runs before creating stream
|
|
681
683
|
*/
|
|
@@ -991,7 +993,7 @@ interface PlaylistJSON {
|
|
|
991
993
|
/**
|
|
992
994
|
* @typedef {object} PlayerInitOptions
|
|
993
995
|
* @property {boolean} [autoRegisterExtractor=true] If it should automatically register `@discord-player/extractor`
|
|
994
|
-
* @property {YTDLDownloadOptions} [ytdlOptions
|
|
996
|
+
* @property {YTDLDownloadOptions} [ytdlOptions] The options passed to `ytdl-core`
|
|
995
997
|
* @property {number} [connectionTimeout=20000] The voice connection timeout
|
|
996
998
|
*/
|
|
997
999
|
interface PlayerInitOptions {
|
|
@@ -1049,8 +1051,8 @@ declare const FilterList: {
|
|
|
1049
1051
|
vibrato: string;
|
|
1050
1052
|
reverse: string;
|
|
1051
1053
|
treble: string;
|
|
1052
|
-
normalizer: string;
|
|
1053
1054
|
normalizer2: string;
|
|
1055
|
+
normalizer: string;
|
|
1054
1056
|
surrounding: string;
|
|
1055
1057
|
pulsator: string;
|
|
1056
1058
|
subboost: string;
|
|
@@ -51,8 +51,8 @@ const FilterList = {
|
|
|
51
51
|
vibrato: "vibrato=f=6.5",
|
|
52
52
|
reverse: "areverse",
|
|
53
53
|
treble: "treble=g=5",
|
|
54
|
-
|
|
55
|
-
|
|
54
|
+
normalizer2: "dynaudnorm=g=101",
|
|
55
|
+
normalizer: "acompressor",
|
|
56
56
|
surrounding: "surround",
|
|
57
57
|
pulsator: "apulsator=hz=1",
|
|
58
58
|
subboost: "asubboost",
|