@twitchfy/chatbot
Version:
A powerful node module to make your own Twitch ChatBot
41 lines (40 loc) • 1.8 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.ChatBotMessageManager = void 0;
const Base_1 = require("../Base");
const BaseMessage_1 = require("../BaseMessage");
/**
* The message manager of the chatbot.
*/
class ChatBotMessageManager extends Base_1.Base {
/**
* Creates a new instance of the message manager.
* @param chatbot The current instance of the chatbot.
*/
constructor(chatbot) {
super(chatbot);
}
/**
* Deletes a specific message from a chatroom.
* @param chatroomId The id of the chatroom where the message will be deleted.
* @param id The id of the message to delete.
* @returns
*/
async delete(chatroomId, id) {
return await this.chatbot.helixClient.deleteMessage(id, chatroomId, this.chatbot.userId);
}
/**
*
* @param chatroomId The id of the chatroom where the message will be sent.
* @param message The message to send.
* @param options The options to send the message. See {@link MessageOptions}.
* @returns A class representation of the message. See {@link BaseMessage}.
*/
async send(chatroomId, message, options) {
const messageData = await this.chatbot.helixClient.sendChatMessage({ message, broadcaster_id: chatroomId, sender_id: this.chatbot.userId, reply_parent_message_id: options?.replyMessageId });
if (messageData.drop_reason)
throw new Error(messageData.drop_reason.message);
return new BaseMessage_1.BaseMessage(this.chatbot, { id: messageData.message_id, content: message, user_id: this.chatbot.user.id, user_login: this.chatbot.user.username, user_name: this.chatbot.user.displayName, chatroom_id: chatroomId });
}
}
exports.ChatBotMessageManager = ChatBotMessageManager;