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.
@@ -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;