discord-player 5.3.0-dev.3 → 5.3.2-dev.0
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 +582 -581
- 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 +785 -769
- package/dist/Structures/Track.js +155 -155
- package/dist/VoiceInterface/StreamDispatcher.js +225 -225
- package/dist/VoiceInterface/VoiceUtils.js +65 -65
- package/dist/VoiceInterface/VolumeTransformer.js +120 -120
- package/dist/index.d.ts +1126 -1122
- package/dist/index.js +33 -33
- package/dist/smoothVolume.js +13 -13
- package/dist/types/types.js +58 -58
- package/dist/utils/AudioFilters.js +97 -98
- package/dist/utils/FFmpegStream.js +53 -53
- package/dist/utils/QueryResolver.js +68 -68
- package/dist/utils/Util.js +135 -133
- package/package.json +22 -16
package/dist/Structures/Track.js
CHANGED
|
@@ -1,155 +1,155 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Track = void 0;
|
|
4
|
-
const discord_js_1 = require("discord.js");
|
|
5
|
-
class Track {
|
|
6
|
-
/**
|
|
7
|
-
* Track constructor
|
|
8
|
-
* @param {Player} player The player that instantiated this Track
|
|
9
|
-
* @param {RawTrackData} data Track data
|
|
10
|
-
*/
|
|
11
|
-
constructor(player, data) {
|
|
12
|
-
this.raw = {};
|
|
13
|
-
this.id = discord_js_1.SnowflakeUtil.generate().toString();
|
|
14
|
-
/**
|
|
15
|
-
* The player that instantiated this Track
|
|
16
|
-
* @name Track#player
|
|
17
|
-
* @type {Player}
|
|
18
|
-
* @readonly
|
|
19
|
-
*/
|
|
20
|
-
Object.defineProperty(this, "player", { value: player, enumerable: false });
|
|
21
|
-
/**
|
|
22
|
-
* Title of this track
|
|
23
|
-
* @name Track#title
|
|
24
|
-
* @type {string}
|
|
25
|
-
*/
|
|
26
|
-
/**
|
|
27
|
-
* Description of this track
|
|
28
|
-
* @name Track#description
|
|
29
|
-
* @type {string}
|
|
30
|
-
*/
|
|
31
|
-
/**
|
|
32
|
-
* Author of this track
|
|
33
|
-
* @name Track#author
|
|
34
|
-
* @type {string}
|
|
35
|
-
*/
|
|
36
|
-
/**
|
|
37
|
-
* URL of this track
|
|
38
|
-
* @name Track#url
|
|
39
|
-
* @type {string}
|
|
40
|
-
*/
|
|
41
|
-
/**
|
|
42
|
-
* Thumbnail of this track
|
|
43
|
-
* @name Track#thumbnail
|
|
44
|
-
* @type {string}
|
|
45
|
-
*/
|
|
46
|
-
/**
|
|
47
|
-
* Duration of this track
|
|
48
|
-
* @name Track#duration
|
|
49
|
-
* @type {string}
|
|
50
|
-
*/
|
|
51
|
-
/**
|
|
52
|
-
* Views count of this track
|
|
53
|
-
* @name Track#views
|
|
54
|
-
* @type {number}
|
|
55
|
-
*/
|
|
56
|
-
/**
|
|
57
|
-
* Person who requested this track
|
|
58
|
-
* @name Track#requestedBy
|
|
59
|
-
* @type {User}
|
|
60
|
-
*/
|
|
61
|
-
/**
|
|
62
|
-
* If this track belongs to playlist
|
|
63
|
-
* @name Track#fromPlaylist
|
|
64
|
-
* @type {boolean}
|
|
65
|
-
*/
|
|
66
|
-
/**
|
|
67
|
-
* Raw track data
|
|
68
|
-
* @name Track#raw
|
|
69
|
-
* @type {RawTrackData}
|
|
70
|
-
*/
|
|
71
|
-
/**
|
|
72
|
-
* The track id
|
|
73
|
-
* @name Track#id
|
|
74
|
-
* @type {Snowflake}
|
|
75
|
-
* @readonly
|
|
76
|
-
*/
|
|
77
|
-
/**
|
|
78
|
-
* The playlist which track belongs
|
|
79
|
-
* @name Track#playlist
|
|
80
|
-
* @type {Playlist}
|
|
81
|
-
*/
|
|
82
|
-
void this._patch(data);
|
|
83
|
-
}
|
|
84
|
-
_patch(data) {
|
|
85
|
-
this.title = (0, discord_js_1.escapeMarkdown)(data.title ?? "");
|
|
86
|
-
this.author = data.author ?? "";
|
|
87
|
-
this.url = data.url ?? "";
|
|
88
|
-
this.thumbnail = data.thumbnail ?? "";
|
|
89
|
-
this.duration = data.duration ?? "";
|
|
90
|
-
this.views = data.views ?? 0;
|
|
91
|
-
this.requestedBy = data.requestedBy;
|
|
92
|
-
this.playlist = data.playlist;
|
|
93
|
-
// raw
|
|
94
|
-
Object.defineProperty(this, "raw", { value: Object.assign({}, { source: data.raw?.source ?? data.source }, data.raw ?? data), enumerable: false });
|
|
95
|
-
}
|
|
96
|
-
/**
|
|
97
|
-
* The queue in which this track is located
|
|
98
|
-
* @type {Queue}
|
|
99
|
-
*/
|
|
100
|
-
get queue() {
|
|
101
|
-
return this.player.queues.find((q) => q.tracks.some((ab) => ab.id === this.id));
|
|
102
|
-
}
|
|
103
|
-
/**
|
|
104
|
-
* The track duration in millisecond
|
|
105
|
-
* @type {number}
|
|
106
|
-
*/
|
|
107
|
-
get durationMS() {
|
|
108
|
-
const times = (n, t) => {
|
|
109
|
-
let tn = 1;
|
|
110
|
-
for (let i = 0; i < t; i++)
|
|
111
|
-
tn *= n;
|
|
112
|
-
return t <= 0 ? 1000 : tn * 1000;
|
|
113
|
-
};
|
|
114
|
-
return this.duration
|
|
115
|
-
.split(":")
|
|
116
|
-
.reverse()
|
|
117
|
-
.map((m, i) => parseInt(m) * times(60, i))
|
|
118
|
-
.reduce((a, c) => a + c, 0);
|
|
119
|
-
}
|
|
120
|
-
/**
|
|
121
|
-
* Returns source of this track
|
|
122
|
-
* @type {TrackSource}
|
|
123
|
-
*/
|
|
124
|
-
get source() {
|
|
125
|
-
return this.raw.source ?? "arbitrary";
|
|
126
|
-
}
|
|
127
|
-
/**
|
|
128
|
-
* String representation of this track
|
|
129
|
-
* @returns {string}
|
|
130
|
-
*/
|
|
131
|
-
toString() {
|
|
132
|
-
return `${this.title} by ${this.author}`;
|
|
133
|
-
}
|
|
134
|
-
/**
|
|
135
|
-
* Raw JSON representation of this track
|
|
136
|
-
* @returns {TrackJSON}
|
|
137
|
-
*/
|
|
138
|
-
toJSON(hidePlaylist) {
|
|
139
|
-
return {
|
|
140
|
-
id: this.id,
|
|
141
|
-
title: this.title,
|
|
142
|
-
description: this.description,
|
|
143
|
-
author: this.author,
|
|
144
|
-
url: this.url,
|
|
145
|
-
thumbnail: this.thumbnail,
|
|
146
|
-
duration: this.duration,
|
|
147
|
-
durationMS: this.durationMS,
|
|
148
|
-
views: this.views,
|
|
149
|
-
requestedBy: this.requestedBy?.id,
|
|
150
|
-
playlist: hidePlaylist ? null : this.playlist?.toJSON() ?? null
|
|
151
|
-
};
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
exports.Track = Track;
|
|
155
|
-
exports.default = Track;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Track = void 0;
|
|
4
|
+
const discord_js_1 = require("discord.js");
|
|
5
|
+
class Track {
|
|
6
|
+
/**
|
|
7
|
+
* Track constructor
|
|
8
|
+
* @param {Player} player The player that instantiated this Track
|
|
9
|
+
* @param {RawTrackData} data Track data
|
|
10
|
+
*/
|
|
11
|
+
constructor(player, data) {
|
|
12
|
+
this.raw = {};
|
|
13
|
+
this.id = discord_js_1.SnowflakeUtil.generate().toString();
|
|
14
|
+
/**
|
|
15
|
+
* The player that instantiated this Track
|
|
16
|
+
* @name Track#player
|
|
17
|
+
* @type {Player}
|
|
18
|
+
* @readonly
|
|
19
|
+
*/
|
|
20
|
+
Object.defineProperty(this, "player", { value: player, enumerable: false });
|
|
21
|
+
/**
|
|
22
|
+
* Title of this track
|
|
23
|
+
* @name Track#title
|
|
24
|
+
* @type {string}
|
|
25
|
+
*/
|
|
26
|
+
/**
|
|
27
|
+
* Description of this track
|
|
28
|
+
* @name Track#description
|
|
29
|
+
* @type {string}
|
|
30
|
+
*/
|
|
31
|
+
/**
|
|
32
|
+
* Author of this track
|
|
33
|
+
* @name Track#author
|
|
34
|
+
* @type {string}
|
|
35
|
+
*/
|
|
36
|
+
/**
|
|
37
|
+
* URL of this track
|
|
38
|
+
* @name Track#url
|
|
39
|
+
* @type {string}
|
|
40
|
+
*/
|
|
41
|
+
/**
|
|
42
|
+
* Thumbnail of this track
|
|
43
|
+
* @name Track#thumbnail
|
|
44
|
+
* @type {string}
|
|
45
|
+
*/
|
|
46
|
+
/**
|
|
47
|
+
* Duration of this track
|
|
48
|
+
* @name Track#duration
|
|
49
|
+
* @type {string}
|
|
50
|
+
*/
|
|
51
|
+
/**
|
|
52
|
+
* Views count of this track
|
|
53
|
+
* @name Track#views
|
|
54
|
+
* @type {number}
|
|
55
|
+
*/
|
|
56
|
+
/**
|
|
57
|
+
* Person who requested this track
|
|
58
|
+
* @name Track#requestedBy
|
|
59
|
+
* @type {User}
|
|
60
|
+
*/
|
|
61
|
+
/**
|
|
62
|
+
* If this track belongs to playlist
|
|
63
|
+
* @name Track#fromPlaylist
|
|
64
|
+
* @type {boolean}
|
|
65
|
+
*/
|
|
66
|
+
/**
|
|
67
|
+
* Raw track data
|
|
68
|
+
* @name Track#raw
|
|
69
|
+
* @type {RawTrackData}
|
|
70
|
+
*/
|
|
71
|
+
/**
|
|
72
|
+
* The track id
|
|
73
|
+
* @name Track#id
|
|
74
|
+
* @type {Snowflake}
|
|
75
|
+
* @readonly
|
|
76
|
+
*/
|
|
77
|
+
/**
|
|
78
|
+
* The playlist which track belongs
|
|
79
|
+
* @name Track#playlist
|
|
80
|
+
* @type {Playlist}
|
|
81
|
+
*/
|
|
82
|
+
void this._patch(data);
|
|
83
|
+
}
|
|
84
|
+
_patch(data) {
|
|
85
|
+
this.title = (0, discord_js_1.escapeMarkdown)(data.title ?? "");
|
|
86
|
+
this.author = data.author ?? "";
|
|
87
|
+
this.url = data.url ?? "";
|
|
88
|
+
this.thumbnail = data.thumbnail ?? "";
|
|
89
|
+
this.duration = data.duration ?? "";
|
|
90
|
+
this.views = data.views ?? 0;
|
|
91
|
+
this.requestedBy = data.requestedBy;
|
|
92
|
+
this.playlist = data.playlist;
|
|
93
|
+
// raw
|
|
94
|
+
Object.defineProperty(this, "raw", { value: Object.assign({}, { source: data.raw?.source ?? data.source }, data.raw ?? data), enumerable: false });
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* The queue in which this track is located
|
|
98
|
+
* @type {Queue}
|
|
99
|
+
*/
|
|
100
|
+
get queue() {
|
|
101
|
+
return this.player.queues.find((q) => q.tracks.some((ab) => ab.id === this.id));
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* The track duration in millisecond
|
|
105
|
+
* @type {number}
|
|
106
|
+
*/
|
|
107
|
+
get durationMS() {
|
|
108
|
+
const times = (n, t) => {
|
|
109
|
+
let tn = 1;
|
|
110
|
+
for (let i = 0; i < t; i++)
|
|
111
|
+
tn *= n;
|
|
112
|
+
return t <= 0 ? 1000 : tn * 1000;
|
|
113
|
+
};
|
|
114
|
+
return this.duration
|
|
115
|
+
.split(":")
|
|
116
|
+
.reverse()
|
|
117
|
+
.map((m, i) => parseInt(m) * times(60, i))
|
|
118
|
+
.reduce((a, c) => a + c, 0);
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Returns source of this track
|
|
122
|
+
* @type {TrackSource}
|
|
123
|
+
*/
|
|
124
|
+
get source() {
|
|
125
|
+
return this.raw.source ?? "arbitrary";
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* String representation of this track
|
|
129
|
+
* @returns {string}
|
|
130
|
+
*/
|
|
131
|
+
toString() {
|
|
132
|
+
return `${this.title} by ${this.author}`;
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Raw JSON representation of this track
|
|
136
|
+
* @returns {TrackJSON}
|
|
137
|
+
*/
|
|
138
|
+
toJSON(hidePlaylist) {
|
|
139
|
+
return {
|
|
140
|
+
id: this.id,
|
|
141
|
+
title: this.title,
|
|
142
|
+
description: this.description,
|
|
143
|
+
author: this.author,
|
|
144
|
+
url: this.url,
|
|
145
|
+
thumbnail: this.thumbnail,
|
|
146
|
+
duration: this.duration,
|
|
147
|
+
durationMS: this.durationMS,
|
|
148
|
+
views: this.views,
|
|
149
|
+
requestedBy: this.requestedBy?.id,
|
|
150
|
+
playlist: hidePlaylist ? null : this.playlist?.toJSON() ?? null
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
exports.Track = Track;
|
|
155
|
+
exports.default = Track;
|