UNPKG

@twitchfy/chatbot

Version:

A powerful node module to make your own Twitch ChatBot

67 lines (66 loc) 1.77 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.BaseMessage = void 0; const Base_1 = require("./Base"); const BaseUser_1 = require("./BaseUser"); /** * The base class for a message. */ class BaseMessage extends Base_1.Base { /** * The id of the message. */ id; /** * The content of the message. */ content; /** * The author of the message. */ author; /** * The base data of the message. */ data; /** * Creates a new instance of the base message. * @param chatbot The current instance of the chatbot. * @param data The base data of the message. */ constructor(chatbot, data) { super(chatbot); this.data = data; this.id = data.id; this.content = data.content; this.author = new BaseUser_1.BaseUser(chatbot, { id: data.user_id, login: data.user_login, display_name: data.user_name }); } /** * Deletes the message from the chatroom. * @returns */ async delete() { return await this.chatbot.messages.delete(this.data.chatroom_id, this.id); } /** * Replies to the message. * @param message The message to reply with. * @returns The message that was sent as a reply. */ async reply(message) { return await this.chatbot.messages.send(this.data.chatroom_id, message, { replyMessageId: this.id }); } /** * The Id of the chatroom where the message was sent. */ get chatroomId() { return this.data.chatroom_id; } /** * Whether the message was sent by the chatbot. */ get self() { return this.author.id === this.chatbot.userId; } } exports.BaseMessage = BaseMessage;