UNPKG

@twurple/easy-bot

Version:

A simplified framework to get a chat bot running easily.

69 lines (68 loc) 2.15 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.JoinEvent = void 0; const tslib_1 = require("tslib"); const shared_utils_1 = require("@d-fischer/shared-utils"); const chat_1 = require("@twurple/chat"); const common_1 = require("@twurple/common"); /** * An event representing a user joining a channel. * * The join/leave events are cached by the Twitch chat server and will be batched and sent every 30-60 seconds. * * Please note that if you have not enabled the `requestMembershipEvents` option * or the channel has more than 1000 connected chatters, this will only react to your own joins. * * @meta category events */ let JoinEvent = class JoinEvent { /** @internal */ constructor(channel, userName, bot) { this._broadcasterName = (0, chat_1.toUserName)(channel); this._userName = userName; this._bot = bot; } /** * The name of the broadcaster. */ get broadcasterName() { return this._broadcasterName; } /** * Gets more information about the broadcaster. */ async getBroadcaster() { return (0, common_1.checkRelationAssertion)(await this._bot.api.users.getUserByName(this.broadcasterName)); } /** * The name of the user. */ get userName() { return this._userName; } /** * Gets more information about the user. */ async getUser() { return (0, common_1.checkRelationAssertion)(await this._bot.api.users.getUserByName(this.userName)); } /** * Leaves the channel. */ leave() { this._bot.leave(this.broadcasterName); } }; exports.JoinEvent = JoinEvent; tslib_1.__decorate([ (0, shared_utils_1.Enumerable)(false) ], JoinEvent.prototype, "_broadcasterName", void 0); tslib_1.__decorate([ (0, shared_utils_1.Enumerable)(false) ], JoinEvent.prototype, "_userName", void 0); tslib_1.__decorate([ (0, shared_utils_1.Enumerable)(false) ], JoinEvent.prototype, "_bot", void 0); exports.JoinEvent = JoinEvent = tslib_1.__decorate([ (0, common_1.rtfm)('easy-bot', 'JoinEvent', 'broadcasterName') ], JoinEvent);