discord-player 5.3.2-dev.2 → 5.3.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 +607 -583
- package/dist/Structures/ExtractorModel.js +65 -65
- package/dist/Structures/PlayerError.js +48 -48
- package/dist/Structures/Playlist.js +108 -108
- package/dist/Structures/Queue.js +830 -795
- package/dist/Structures/Track.js +155 -155
- package/dist/VoiceInterface/StreamDispatcher.js +226 -226
- package/dist/VoiceInterface/VoiceUtils.js +65 -65
- package/dist/VoiceInterface/VolumeTransformer.js +120 -120
- package/dist/index.d.ts +1224 -1163
- package/dist/index.js +38 -34
- package/dist/smoothVolume.js +15 -15
- package/dist/types/types.js +58 -58
- package/dist/utils/AudioFilters.js +95 -97
- package/dist/utils/FFmpegStream.js +53 -53
- package/dist/utils/QueryResolver.js +68 -68
- package/dist/utils/Util.js +136 -135
- package/package.json +1 -1
|
@@ -1,65 +1,65 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ExtractorModel = void 0;
|
|
4
|
-
class ExtractorModel {
|
|
5
|
-
/**
|
|
6
|
-
* Model for raw Discord Player extractors
|
|
7
|
-
* @param {string} extractorName Name of the extractor
|
|
8
|
-
* @param {object} data Extractor object
|
|
9
|
-
*/
|
|
10
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
11
|
-
constructor(extractorName, data) {
|
|
12
|
-
/**
|
|
13
|
-
* The extractor name
|
|
14
|
-
* @type {string}
|
|
15
|
-
*/
|
|
16
|
-
this.name = extractorName;
|
|
17
|
-
/**
|
|
18
|
-
* The raw model
|
|
19
|
-
* @name ExtractorModel#_raw
|
|
20
|
-
* @type {any}
|
|
21
|
-
* @private
|
|
22
|
-
*/
|
|
23
|
-
Object.defineProperty(this, "_raw", { value: data, configurable: false, writable: false, enumerable: false });
|
|
24
|
-
}
|
|
25
|
-
/**
|
|
26
|
-
* Method to handle requests from `Player.play()`
|
|
27
|
-
* @param {string} query Query to handle
|
|
28
|
-
* @returns {Promise<ExtractorModelData>}
|
|
29
|
-
*/
|
|
30
|
-
async handle(query) {
|
|
31
|
-
const data = await this._raw.getInfo(query);
|
|
32
|
-
if (!data)
|
|
33
|
-
return null;
|
|
34
|
-
return {
|
|
35
|
-
playlist: data.playlist ?? null,
|
|
36
|
-
data: data.info?.map((m) => ({
|
|
37
|
-
title: m.title,
|
|
38
|
-
duration: m.duration,
|
|
39
|
-
thumbnail: m.thumbnail,
|
|
40
|
-
engine: m.engine,
|
|
41
|
-
views: m.views,
|
|
42
|
-
author: m.author,
|
|
43
|
-
description: m.description,
|
|
44
|
-
url: m.url,
|
|
45
|
-
source: m.source || "arbitrary"
|
|
46
|
-
})) ?? []
|
|
47
|
-
};
|
|
48
|
-
}
|
|
49
|
-
/**
|
|
50
|
-
* Method used by Discord Player to validate query with this extractor
|
|
51
|
-
* @param {string} query The query to validate
|
|
52
|
-
* @returns {boolean}
|
|
53
|
-
*/
|
|
54
|
-
validate(query) {
|
|
55
|
-
return Boolean(this._raw.validate(query));
|
|
56
|
-
}
|
|
57
|
-
/**
|
|
58
|
-
* The extractor version
|
|
59
|
-
* @type {string}
|
|
60
|
-
*/
|
|
61
|
-
get version() {
|
|
62
|
-
return this._raw.version ?? "0.0.0";
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
exports.ExtractorModel = ExtractorModel;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ExtractorModel = void 0;
|
|
4
|
+
class ExtractorModel {
|
|
5
|
+
/**
|
|
6
|
+
* Model for raw Discord Player extractors
|
|
7
|
+
* @param {string} extractorName Name of the extractor
|
|
8
|
+
* @param {object} data Extractor object
|
|
9
|
+
*/
|
|
10
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
11
|
+
constructor(extractorName, data) {
|
|
12
|
+
/**
|
|
13
|
+
* The extractor name
|
|
14
|
+
* @type {string}
|
|
15
|
+
*/
|
|
16
|
+
this.name = extractorName;
|
|
17
|
+
/**
|
|
18
|
+
* The raw model
|
|
19
|
+
* @name ExtractorModel#_raw
|
|
20
|
+
* @type {any}
|
|
21
|
+
* @private
|
|
22
|
+
*/
|
|
23
|
+
Object.defineProperty(this, "_raw", { value: data, configurable: false, writable: false, enumerable: false });
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Method to handle requests from `Player.play()`
|
|
27
|
+
* @param {string} query Query to handle
|
|
28
|
+
* @returns {Promise<ExtractorModelData>}
|
|
29
|
+
*/
|
|
30
|
+
async handle(query) {
|
|
31
|
+
const data = await this._raw.getInfo(query);
|
|
32
|
+
if (!data)
|
|
33
|
+
return null;
|
|
34
|
+
return {
|
|
35
|
+
playlist: data.playlist ?? null,
|
|
36
|
+
data: data.info?.map((m) => ({
|
|
37
|
+
title: m.title,
|
|
38
|
+
duration: m.duration,
|
|
39
|
+
thumbnail: m.thumbnail,
|
|
40
|
+
engine: m.engine,
|
|
41
|
+
views: m.views,
|
|
42
|
+
author: m.author,
|
|
43
|
+
description: m.description,
|
|
44
|
+
url: m.url,
|
|
45
|
+
source: m.source || "arbitrary"
|
|
46
|
+
})) ?? []
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Method used by Discord Player to validate query with this extractor
|
|
51
|
+
* @param {string} query The query to validate
|
|
52
|
+
* @returns {boolean}
|
|
53
|
+
*/
|
|
54
|
+
validate(query) {
|
|
55
|
+
return Boolean(this._raw.validate(query));
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* The extractor version
|
|
59
|
+
* @type {string}
|
|
60
|
+
*/
|
|
61
|
+
get version() {
|
|
62
|
+
return this._raw.version ?? "0.0.0";
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
exports.ExtractorModel = ExtractorModel;
|
|
@@ -1,48 +1,48 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.PlayerError = exports.ErrorStatusCode = void 0;
|
|
4
|
-
var ErrorStatusCode;
|
|
5
|
-
(function (ErrorStatusCode) {
|
|
6
|
-
ErrorStatusCode["STREAM_ERROR"] = "StreamError";
|
|
7
|
-
ErrorStatusCode["AUDIO_PLAYER_ERROR"] = "AudioPlayerError";
|
|
8
|
-
ErrorStatusCode["PLAYER_ERROR"] = "PlayerError";
|
|
9
|
-
ErrorStatusCode["NO_AUDIO_RESOURCE"] = "NoAudioResource";
|
|
10
|
-
ErrorStatusCode["UNKNOWN_GUILD"] = "UnknownGuild";
|
|
11
|
-
ErrorStatusCode["INVALID_ARG_TYPE"] = "InvalidArgType";
|
|
12
|
-
ErrorStatusCode["UNKNOWN_EXTRACTOR"] = "UnknownExtractor";
|
|
13
|
-
ErrorStatusCode["INVALID_EXTRACTOR"] = "InvalidExtractor";
|
|
14
|
-
ErrorStatusCode["INVALID_CHANNEL_TYPE"] = "InvalidChannelType";
|
|
15
|
-
ErrorStatusCode["INVALID_TRACK"] = "InvalidTrack";
|
|
16
|
-
ErrorStatusCode["UNKNOWN_REPEAT_MODE"] = "UnknownRepeatMode";
|
|
17
|
-
ErrorStatusCode["TRACK_NOT_FOUND"] = "TrackNotFound";
|
|
18
|
-
ErrorStatusCode["NO_CONNECTION"] = "NoConnection";
|
|
19
|
-
ErrorStatusCode["DESTROYED_QUEUE"] = "DestroyedQueue";
|
|
20
|
-
})(ErrorStatusCode = exports.ErrorStatusCode || (exports.ErrorStatusCode = {}));
|
|
21
|
-
class PlayerError extends Error {
|
|
22
|
-
constructor(message, code = ErrorStatusCode.PLAYER_ERROR) {
|
|
23
|
-
super();
|
|
24
|
-
this.createdAt = new Date();
|
|
25
|
-
this.message = `[${code}] ${message}`;
|
|
26
|
-
this.statusCode = code;
|
|
27
|
-
this.name = code;
|
|
28
|
-
Error.captureStackTrace(this);
|
|
29
|
-
}
|
|
30
|
-
get createdTimestamp() {
|
|
31
|
-
return this.createdAt.getTime();
|
|
32
|
-
}
|
|
33
|
-
valueOf() {
|
|
34
|
-
return this.statusCode;
|
|
35
|
-
}
|
|
36
|
-
toJSON() {
|
|
37
|
-
return {
|
|
38
|
-
stack: this.stack,
|
|
39
|
-
code: this.statusCode,
|
|
40
|
-
message: this.message,
|
|
41
|
-
created: this.createdTimestamp
|
|
42
|
-
};
|
|
43
|
-
}
|
|
44
|
-
toString() {
|
|
45
|
-
return this.stack;
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
exports.PlayerError = PlayerError;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PlayerError = exports.ErrorStatusCode = void 0;
|
|
4
|
+
var ErrorStatusCode;
|
|
5
|
+
(function (ErrorStatusCode) {
|
|
6
|
+
ErrorStatusCode["STREAM_ERROR"] = "StreamError";
|
|
7
|
+
ErrorStatusCode["AUDIO_PLAYER_ERROR"] = "AudioPlayerError";
|
|
8
|
+
ErrorStatusCode["PLAYER_ERROR"] = "PlayerError";
|
|
9
|
+
ErrorStatusCode["NO_AUDIO_RESOURCE"] = "NoAudioResource";
|
|
10
|
+
ErrorStatusCode["UNKNOWN_GUILD"] = "UnknownGuild";
|
|
11
|
+
ErrorStatusCode["INVALID_ARG_TYPE"] = "InvalidArgType";
|
|
12
|
+
ErrorStatusCode["UNKNOWN_EXTRACTOR"] = "UnknownExtractor";
|
|
13
|
+
ErrorStatusCode["INVALID_EXTRACTOR"] = "InvalidExtractor";
|
|
14
|
+
ErrorStatusCode["INVALID_CHANNEL_TYPE"] = "InvalidChannelType";
|
|
15
|
+
ErrorStatusCode["INVALID_TRACK"] = "InvalidTrack";
|
|
16
|
+
ErrorStatusCode["UNKNOWN_REPEAT_MODE"] = "UnknownRepeatMode";
|
|
17
|
+
ErrorStatusCode["TRACK_NOT_FOUND"] = "TrackNotFound";
|
|
18
|
+
ErrorStatusCode["NO_CONNECTION"] = "NoConnection";
|
|
19
|
+
ErrorStatusCode["DESTROYED_QUEUE"] = "DestroyedQueue";
|
|
20
|
+
})(ErrorStatusCode = exports.ErrorStatusCode || (exports.ErrorStatusCode = {}));
|
|
21
|
+
class PlayerError extends Error {
|
|
22
|
+
constructor(message, code = ErrorStatusCode.PLAYER_ERROR) {
|
|
23
|
+
super();
|
|
24
|
+
this.createdAt = new Date();
|
|
25
|
+
this.message = `[${code}] ${message}`;
|
|
26
|
+
this.statusCode = code;
|
|
27
|
+
this.name = code;
|
|
28
|
+
Error.captureStackTrace(this);
|
|
29
|
+
}
|
|
30
|
+
get createdTimestamp() {
|
|
31
|
+
return this.createdAt.getTime();
|
|
32
|
+
}
|
|
33
|
+
valueOf() {
|
|
34
|
+
return this.statusCode;
|
|
35
|
+
}
|
|
36
|
+
toJSON() {
|
|
37
|
+
return {
|
|
38
|
+
stack: this.stack,
|
|
39
|
+
code: this.statusCode,
|
|
40
|
+
message: this.message,
|
|
41
|
+
created: this.createdTimestamp
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
toString() {
|
|
45
|
+
return this.stack;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
exports.PlayerError = PlayerError;
|
|
@@ -1,108 +1,108 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Playlist = void 0;
|
|
4
|
-
class Playlist {
|
|
5
|
-
/**
|
|
6
|
-
* Playlist constructor
|
|
7
|
-
* @param {Player} player The player
|
|
8
|
-
* @param {PlaylistInitData} data The data
|
|
9
|
-
*/
|
|
10
|
-
constructor(player, data) {
|
|
11
|
-
/**
|
|
12
|
-
* The player
|
|
13
|
-
* @name Playlist#player
|
|
14
|
-
* @type {Player}
|
|
15
|
-
* @readonly
|
|
16
|
-
*/
|
|
17
|
-
this.player = player;
|
|
18
|
-
/**
|
|
19
|
-
* The tracks in this playlist
|
|
20
|
-
* @name Playlist#tracks
|
|
21
|
-
* @type {Track[]}
|
|
22
|
-
*/
|
|
23
|
-
this.tracks = data.tracks ?? [];
|
|
24
|
-
/**
|
|
25
|
-
* The author of this playlist
|
|
26
|
-
* @name Playlist#author
|
|
27
|
-
* @type {object}
|
|
28
|
-
*/
|
|
29
|
-
this.author = data.author;
|
|
30
|
-
/**
|
|
31
|
-
* The description
|
|
32
|
-
* @name Playlist#description
|
|
33
|
-
* @type {string}
|
|
34
|
-
*/
|
|
35
|
-
this.description = data.description;
|
|
36
|
-
/**
|
|
37
|
-
* The thumbnail of this playlist
|
|
38
|
-
* @name Playlist#thumbnail
|
|
39
|
-
* @type {string}
|
|
40
|
-
*/
|
|
41
|
-
this.thumbnail = data.thumbnail;
|
|
42
|
-
/**
|
|
43
|
-
* The playlist type:
|
|
44
|
-
* - `album`
|
|
45
|
-
* - `playlist`
|
|
46
|
-
* @name Playlist#type
|
|
47
|
-
* @type {string}
|
|
48
|
-
*/
|
|
49
|
-
this.type = data.type;
|
|
50
|
-
/**
|
|
51
|
-
* The source of this playlist:
|
|
52
|
-
* - `youtube`
|
|
53
|
-
* - `soundcloud`
|
|
54
|
-
* - `spotify`
|
|
55
|
-
* - `arbitrary`
|
|
56
|
-
* @name Playlist#source
|
|
57
|
-
* @type {string}
|
|
58
|
-
*/
|
|
59
|
-
this.source = data.source;
|
|
60
|
-
/**
|
|
61
|
-
* The playlist id
|
|
62
|
-
* @name Playlist#id
|
|
63
|
-
* @type {string}
|
|
64
|
-
*/
|
|
65
|
-
this.id = data.id;
|
|
66
|
-
/**
|
|
67
|
-
* The playlist url
|
|
68
|
-
* @name Playlist#url
|
|
69
|
-
* @type {string}
|
|
70
|
-
*/
|
|
71
|
-
this.url = data.url;
|
|
72
|
-
/**
|
|
73
|
-
* The playlist title
|
|
74
|
-
* @type {string}
|
|
75
|
-
*/
|
|
76
|
-
this.title = data.title;
|
|
77
|
-
/**
|
|
78
|
-
* @name Playlist#rawPlaylist
|
|
79
|
-
* @type {any}
|
|
80
|
-
* @readonly
|
|
81
|
-
*/
|
|
82
|
-
}
|
|
83
|
-
*[Symbol.iterator]() {
|
|
84
|
-
yield* this.tracks;
|
|
85
|
-
}
|
|
86
|
-
/**
|
|
87
|
-
* JSON representation of this playlist
|
|
88
|
-
* @param {boolean} [withTracks=true] If it should build json with tracks
|
|
89
|
-
* @returns {PlaylistJSON}
|
|
90
|
-
*/
|
|
91
|
-
toJSON(withTracks = true) {
|
|
92
|
-
const payload = {
|
|
93
|
-
id: this.id,
|
|
94
|
-
url: this.url,
|
|
95
|
-
title: this.title,
|
|
96
|
-
description: this.description,
|
|
97
|
-
thumbnail: this.thumbnail,
|
|
98
|
-
type: this.type,
|
|
99
|
-
source: this.source,
|
|
100
|
-
author: this.author,
|
|
101
|
-
tracks: []
|
|
102
|
-
};
|
|
103
|
-
if (withTracks)
|
|
104
|
-
payload.tracks = this.tracks.map((m) => m.toJSON(true));
|
|
105
|
-
return payload;
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
exports.Playlist = Playlist;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Playlist = void 0;
|
|
4
|
+
class Playlist {
|
|
5
|
+
/**
|
|
6
|
+
* Playlist constructor
|
|
7
|
+
* @param {Player} player The player
|
|
8
|
+
* @param {PlaylistInitData} data The data
|
|
9
|
+
*/
|
|
10
|
+
constructor(player, data) {
|
|
11
|
+
/**
|
|
12
|
+
* The player
|
|
13
|
+
* @name Playlist#player
|
|
14
|
+
* @type {Player}
|
|
15
|
+
* @readonly
|
|
16
|
+
*/
|
|
17
|
+
this.player = player;
|
|
18
|
+
/**
|
|
19
|
+
* The tracks in this playlist
|
|
20
|
+
* @name Playlist#tracks
|
|
21
|
+
* @type {Track[]}
|
|
22
|
+
*/
|
|
23
|
+
this.tracks = data.tracks ?? [];
|
|
24
|
+
/**
|
|
25
|
+
* The author of this playlist
|
|
26
|
+
* @name Playlist#author
|
|
27
|
+
* @type {object}
|
|
28
|
+
*/
|
|
29
|
+
this.author = data.author;
|
|
30
|
+
/**
|
|
31
|
+
* The description
|
|
32
|
+
* @name Playlist#description
|
|
33
|
+
* @type {string}
|
|
34
|
+
*/
|
|
35
|
+
this.description = data.description;
|
|
36
|
+
/**
|
|
37
|
+
* The thumbnail of this playlist
|
|
38
|
+
* @name Playlist#thumbnail
|
|
39
|
+
* @type {string}
|
|
40
|
+
*/
|
|
41
|
+
this.thumbnail = data.thumbnail;
|
|
42
|
+
/**
|
|
43
|
+
* The playlist type:
|
|
44
|
+
* - `album`
|
|
45
|
+
* - `playlist`
|
|
46
|
+
* @name Playlist#type
|
|
47
|
+
* @type {string}
|
|
48
|
+
*/
|
|
49
|
+
this.type = data.type;
|
|
50
|
+
/**
|
|
51
|
+
* The source of this playlist:
|
|
52
|
+
* - `youtube`
|
|
53
|
+
* - `soundcloud`
|
|
54
|
+
* - `spotify`
|
|
55
|
+
* - `arbitrary`
|
|
56
|
+
* @name Playlist#source
|
|
57
|
+
* @type {string}
|
|
58
|
+
*/
|
|
59
|
+
this.source = data.source;
|
|
60
|
+
/**
|
|
61
|
+
* The playlist id
|
|
62
|
+
* @name Playlist#id
|
|
63
|
+
* @type {string}
|
|
64
|
+
*/
|
|
65
|
+
this.id = data.id;
|
|
66
|
+
/**
|
|
67
|
+
* The playlist url
|
|
68
|
+
* @name Playlist#url
|
|
69
|
+
* @type {string}
|
|
70
|
+
*/
|
|
71
|
+
this.url = data.url;
|
|
72
|
+
/**
|
|
73
|
+
* The playlist title
|
|
74
|
+
* @type {string}
|
|
75
|
+
*/
|
|
76
|
+
this.title = data.title;
|
|
77
|
+
/**
|
|
78
|
+
* @name Playlist#rawPlaylist
|
|
79
|
+
* @type {any}
|
|
80
|
+
* @readonly
|
|
81
|
+
*/
|
|
82
|
+
}
|
|
83
|
+
*[Symbol.iterator]() {
|
|
84
|
+
yield* this.tracks;
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* JSON representation of this playlist
|
|
88
|
+
* @param {boolean} [withTracks=true] If it should build json with tracks
|
|
89
|
+
* @returns {PlaylistJSON}
|
|
90
|
+
*/
|
|
91
|
+
toJSON(withTracks = true) {
|
|
92
|
+
const payload = {
|
|
93
|
+
id: this.id,
|
|
94
|
+
url: this.url,
|
|
95
|
+
title: this.title,
|
|
96
|
+
description: this.description,
|
|
97
|
+
thumbnail: this.thumbnail,
|
|
98
|
+
type: this.type,
|
|
99
|
+
source: this.source,
|
|
100
|
+
author: this.author,
|
|
101
|
+
tracks: []
|
|
102
|
+
};
|
|
103
|
+
if (withTracks)
|
|
104
|
+
payload.tracks = this.tracks.map((m) => m.toJSON(true));
|
|
105
|
+
return payload;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
exports.Playlist = Playlist;
|