magmastream 2.9.2-dev.7 → 2.9.2-dev.8

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/index.d.ts CHANGED
@@ -3477,6 +3477,12 @@ declare abstract class TrackUtils {
3477
3477
  * @returns Whether the search result is valid.
3478
3478
  */
3479
3479
  static isErrorOrEmptySearchResult(result: SearchResult): result is ErrorOrEmptySearchResult;
3480
+ /**
3481
+ * Revives a track.
3482
+ * @param track The track to revive.
3483
+ * @returns The revived track.
3484
+ */
3485
+ static revive(track: Track): Track;
3480
3486
  }
3481
3487
  declare abstract class AutoPlayUtils {
3482
3488
  private static manager;
@@ -240,14 +240,15 @@ class JsonQueue {
240
240
  * @returns The current track.
241
241
  */
242
242
  async getCurrent() {
243
- return await this.readJSON(this.currentPath);
243
+ const track = await this.readJSON(this.currentPath);
244
+ return track ? Utils_1.TrackUtils.revive(track) : null;
244
245
  }
245
246
  /**
246
247
  * @returns The previous tracks.
247
248
  */
248
249
  async getPrevious() {
249
250
  const data = await this.readJSON(this.previousPath);
250
- return Array.isArray(data) ? data : [];
251
+ return Array.isArray(data) ? data.map(Utils_1.TrackUtils.revive) : [];
251
252
  }
252
253
  /**
253
254
  * @returns The tracks in the queue from start to end.
@@ -545,7 +546,7 @@ class JsonQueue {
545
546
  */
546
547
  async getQueue() {
547
548
  const data = await this.readJSON(this.queuePath);
548
- return Array.isArray(data) ? data : [];
549
+ return Array.isArray(data) ? data.map(Utils_1.TrackUtils.revive) : [];
549
550
  }
550
551
  /**
551
552
  * @returns The previous path.
@@ -706,7 +706,8 @@ class RedisQueue {
706
706
  * Deserializes a track from a string.
707
707
  */
708
708
  deserialize(data) {
709
- return JSON.parse(data);
709
+ const track = JSON.parse(data);
710
+ return Utils_1.TrackUtils.revive(track);
710
711
  }
711
712
  /**
712
713
  * @returns The previous key.
@@ -168,6 +168,20 @@ class TrackUtils {
168
168
  static isErrorOrEmptySearchResult(result) {
169
169
  return result.loadType === Enums_1.LoadTypes.Empty || result.loadType === Enums_1.LoadTypes.Error;
170
170
  }
171
+ /**
172
+ * Revives a track.
173
+ * @param track The track to revive.
174
+ * @returns The revived track.
175
+ */
176
+ static revive(track) {
177
+ if (!track)
178
+ return track;
179
+ track.displayThumbnail = function (size = "default") {
180
+ const finalSize = SIZES.find((s) => s === size) ?? "default";
181
+ return this.uri.includes("youtube") ? `https://img.youtube.com/vi/${this.identifier}/${finalSize}.jpg` : null;
182
+ }.bind(track);
183
+ return track;
184
+ }
171
185
  }
172
186
  exports.TrackUtils = TrackUtils;
173
187
  class AutoPlayUtils {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "magmastream",
3
- "version": "2.9.2-dev.7",
3
+ "version": "2.9.2-dev.8",
4
4
  "description": "A user-friendly Lavalink client designed for NodeJS.",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",