UNPKG

@twitchfy/chatbot

Version:

A powerful node module to make your own Twitch ChatBot

72 lines (71 loc) 1.97 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.Author = void 0; const BaseUser_1 = require("./BaseUser"); const managers_1 = require("./managers"); /** * Represents the author of a received message. * @extends {BaseUser} */ class Author extends BaseUser_1.BaseUser { /** * The name color of the author in HEX RGB format. */ color; /** * The set of badges of the author. */ badges; /** * Creates a new instance of the author. * @param chatbot The current instance of the chatbot. * @param data The data of the user. */ constructor(chatbot, data) { super(chatbot, data); this.badges = new managers_1.BadgeManager(chatbot, data.badges); } /** * Checks if the author is the broadcaster of the chatroom. */ get broadcaster() { return this.badges.has('broadcaster'); } /** * Checks if the author is a moderator of the chatroom. */ get moderator() { return this.badges.has('moderator'); } /** * Checks if the author is a VIP of the chatroom. */ get vip() { return this.badges.has('vip'); } /** * Checks if the author is a subscriber of the channel. */ get subscriber() { return this.badges.has('subscriber'); } /** * Gets the subscription tier of the author. If the author is not a subscriber, it will return a nullish value. */ get subscriptionTier() { const badge = this.badges.get('subscriber'); if (!badge) return null; return Number(badge.id[0]); } /** * Gets the subscription months of the author. If the author is not a subscriber, it will return `0`. */ get subscriptionMonths() { const badge = this.badges.get('subscriber'); if (!badge) return 0; return Number(badge.info); } } exports.Author = Author;