UNPKG

@twitchfy/chatbot

Version:

A powerful node module to make your own Twitch ChatBot

41 lines (40 loc) 1.31 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.BadgeManager = void 0; const Base_1 = require("../Base"); /** * Represents an user badge's manager. */ class BadgeManager extends Base_1.Base { /** * The data containing the user's badges returned by the EventSub. * @internal */ data; /** * Creates a new instance of the badge manager. * @param chatbot The current instance of the chatbot. * @param data The data containing the user's badges returned by the EventSub. */ constructor(chatbot, data) { super(chatbot); this.data = data; } /** * Checks if the user has a specific badge. * @param id The id of the badge to check. Possible values could be `subscriber`, `vip, `moderator`. * @returns A boolean determining whether the user has the badge. */ has(id) { return !!this.get(id); } /** * Gets a user's badge. * @param id The id of the badge to get. Possible values could be `subscriber`, `vip, `moderator`. * @returns The badge if the user has it. If not it will return `undefined`. */ get(id) { return this.data.find(badge => badge.setId.toLowerCase() === id.toLowerCase()); } } exports.BadgeManager = BadgeManager;