import Message from "./Message.js"; /** * @description Class for text messages * @since 1.0 * @author MiTask */ class TextMessage extends Message { /** * @since 1.0 * @author MiTask * @constructor * @param {String} peerName Peer username * @param {String} peerAvatar Peer avatar URL * @param {String} topic Chat room topic string * @param {Number} timestamp UNIX Timestamp * @param {String} message Text of the message */ constructor(peerName, peerAvatar, topic, timestamp, message) { super("message", peerName, peerAvatar, topic, timestamp); this.message = message; } /** * @since 1.0 * @author MiTask * @returns {String} JSON String with all of the information about the message */ toJsonString() { return JSON.stringify({ ...this.toJson(), message: this.message, }); } /** * @since 1.0 * @author MiTask * @param {Client} bot Bot Client class * @param {String} message Text of the message * @returns {TextMessage} TextMessage class */ static new(bot, message) { return new TextMessage(bot.botName, bot.botAvatar, bot.currentTopic, Date.now(), message); } } export default TextMessage;