2021-04-04 22:44:45 +05:00
|
|
|
import Player from '../Player';
|
|
|
|
import { User } from 'discord.js';
|
2021-04-04 22:36:40 +05:00
|
|
|
|
|
|
|
export default class Track {
|
|
|
|
public player!: Player;
|
|
|
|
public title!: string;
|
|
|
|
public description!: string;
|
|
|
|
public author!: string;
|
|
|
|
public url!: string;
|
|
|
|
public thumbnail!: string;
|
|
|
|
public duration!: string;
|
|
|
|
public views!: number;
|
|
|
|
public requestedBy!: User;
|
|
|
|
public fromPlaylist!: boolean;
|
|
|
|
|
|
|
|
constructor(player: Player, data: any) {
|
|
|
|
/**
|
|
|
|
* The player that instantiated this Track
|
|
|
|
*/
|
2021-04-04 22:44:45 +05:00
|
|
|
Object.defineProperty(this, 'player', { value: player, enumerable: false });
|
2021-04-04 22:36:40 +05:00
|
|
|
|
|
|
|
void this._patch(data);
|
|
|
|
}
|
|
|
|
|
|
|
|
private _patch(data: any) {
|
2021-04-04 22:44:45 +05:00
|
|
|
this.title = data.title ?? '';
|
|
|
|
this.description = data.description ?? '';
|
|
|
|
this.author = data.author ?? '';
|
|
|
|
this.url = data.url ?? '';
|
|
|
|
this.thumbnail = typeof data.thumbnail === 'object' ? data.thumbnail.url : data.thumbnail;
|
|
|
|
this.duration = data.duration ?? '';
|
2021-04-04 22:36:40 +05:00
|
|
|
this.views = data.views ?? 0;
|
|
|
|
this.requestedBy = data.requestedBy;
|
|
|
|
this.fromPlaylist = Boolean(data.fromPlaylist);
|
|
|
|
}
|
2021-04-04 22:44:45 +05:00
|
|
|
}
|