@twitchfy/chatbot
Version:
A powerful node module to make your own Twitch ChatBot
57 lines (56 loc) • 1.72 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.BaseCheermote = void 0;
const Cheermote_1 = require("./Cheermote");
const Base_1 = require("./Base");
/**
* Represents a base cheermote returned by the EventSub.
*/
class BaseCheermote extends Base_1.Base {
/**
* The bits that were cheered with the cheermote.
*/
bits;
/**
* The prefix of the cheermote.
*/
prefix;
/**
* The tier level of the cheermote.
*/
tier;
/**
* The data of the cheermote returned by the EventSub.
*/
data;
/**
* Creates a new instance of the base cheermote.
* @param chatbot The current instance of the chatbot.
* @param data The data of the cheermote returned by the EventSub.
*/
constructor(chatbot, data) {
super(chatbot);
this.data = data;
this.bits = data.bits;
this.prefix = data.prefix;
this.tier = data.tier;
}
/**
* The content of the cheermote. This is the prefix followed by the bits cheered.
*/
get content() {
return this.data.prefix + this.data.bits;
}
/**
* Fetches the cheermote from the API returning the information of it.
* @returns The cheermote if it exists. If not it will return `null` (basically this is 99.99% impossible).
*/
async fetch() {
const cheermoteData = await this.chatbot.helixClient.getCheermotes(this.data.broadcaster_id);
const cheermote = cheermoteData.find((x) => x.prefix === this.data.prefix);
if (!cheermote)
return null;
return new Cheermote_1.Cheermote(this.chatbot, cheermote);
}
}
exports.BaseCheermote = BaseCheermote;