UNPKG

@twurple/easy-bot

Version:

A simplified framework to get a chat bot running easily.

75 lines (74 loc) 2.07 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.WhisperEvent = void 0; const tslib_1 = require("tslib"); const shared_utils_1 = require("@d-fischer/shared-utils"); const common_1 = require("@twurple/common"); /** * An event representing a whisper message. * * @meta category events */ let WhisperEvent = class WhisperEvent { /** @internal */ constructor(userName, text, msg, bot) { this._userName = userName; this._text = text; this._msg = msg; this._bot = bot; } /** * The ID of the user who sent the message. */ get userId() { return this._msg.userInfo.userId; } /** * The name of the user who sent the message. */ get userName() { return this._userName; } /** * The display name of the user who sent the message. */ get userDisplayName() { return this._msg.userInfo.displayName; } /** * Gets more information about the user who sent the message. */ async getUser() { return (0, common_1.checkRelationAssertion)(await this._bot.api.users.getUserById(this.userId)); } /** * The text of the message. */ get text() { return this._text; } /** * Replies to the message. * * @param text The text to send as a reply. */ async reply(text) { await this._bot.whisperById(this.userId, text); } }; exports.WhisperEvent = WhisperEvent; tslib_1.__decorate([ (0, shared_utils_1.Enumerable)(false) ], WhisperEvent.prototype, "_userName", void 0); tslib_1.__decorate([ (0, shared_utils_1.Enumerable)(false) ], WhisperEvent.prototype, "_text", void 0); tslib_1.__decorate([ (0, shared_utils_1.Enumerable)(false) ], WhisperEvent.prototype, "_msg", void 0); tslib_1.__decorate([ (0, shared_utils_1.Enumerable)(false) ], WhisperEvent.prototype, "_bot", void 0); exports.WhisperEvent = WhisperEvent = tslib_1.__decorate([ (0, common_1.rtfm)('easy-bot', 'WhisperEvent', 'userId') ], WhisperEvent);