@twitchfy/chatbot
Version:
A powerful node module to make your own Twitch ChatBot
45 lines (44 loc) • 1.15 kB
JavaScript
;
/* eslint-disable @typescript-eslint/ban-ts-comment */
Object.defineProperty(exports, "__esModule", { value: true });
exports.BaseClip = void 0;
const Base_1 = require("./Base");
/**
* Represents the base class for all clips.
*/
class BaseClip extends Base_1.Base {
/**
* The id of the clip.
*/
id;
/**
* The url of the clip.
*/
url;
/**
* Creates a new instance of the clip.
* @param chatbot The current instance of the chatbot.
* @param data The data of the clip returned from the API.
*/
constructor(chatbot, data) {
super(chatbot);
this.id = data.id;
// @ts-ignore
this.url = data.url || data.edit_url.split('/edit')[0];
}
/**
*
* @returns The url of the clip.
*/
toString() {
return this.url;
}
/**
* Fetches the information of the clip from the API.
* @returns The fetched clip. Returns null if the clip was not found (probably because it was not cached yet).
*/
async fetch() {
return this.chatbot.clip({ id: this.id });
}
}
exports.BaseClip = BaseClip;