UNPKG

@twitchfy/chatbot

Version:

A powerful node module to make your own Twitch ChatBot

59 lines (58 loc) 1.62 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.Cheermote = void 0; const Base_1 = require("./Base"); const CheermoteTier_1 = require("./CheermoteTier"); /** * Represents a Twitch cheermote. */ class Cheermote extends Base_1.Base { /** * The type of the cheermote. */ type; /** * The prefix of the cheermote. */ prefix; /** * The tiers of the cheermote. */ tiers; /** * Whether the cheermote is charitable. */ isCharitable; /** * The data of the cheermote returned from the API. */ data; /** * Creates a new instance of the cheermote. * @param chatbot The current instance of the chatbot. * @param data The data of the cheermote returned from the API. */ constructor(chatbot, data) { super(chatbot); this.data = data; this.type = data.type; this.prefix = data.prefix; this.tiers = data.tiers.map(x => new CheermoteTier_1.CheermoteTier(chatbot, this, x)); this.isCharitable = data.is_charitable; } /** * Returns the last updated date of the cheermote in a JavaScript Date object. */ get lastUpdated() { return new Date(this.data.last_updated); } /** * Get the URL of the image of cheermote. * @param options The options to get the URL of the cheermote. * @returns The URL of the image of the cheermote. */ getURL(options) { return this.tiers.find((x) => x.id === options.tier)?.getURL(options) ?? null; } } exports.Cheermote = Cheermote;