@myncraftjs/colorchat
Version:
Myncraftjs colorchat package
18 lines (17 loc) • 726 B
JavaScript
import colorizer, { colorizeExtra } from "./colorizer";
import prismarineChat from "prismarine-chat";
export { colorizer as colorizeText };
export { colorizeExtra } from "./colorizer";
export default function colorChat(bot, opt) {
const ChatMessage = prismarineChat(bot.version);
bot.on("messagestr", (msg, pos, jsonMsg) => {
let colorizedMsg = colorizeExtra(jsonMsg.json);
if (colorizedMsg.length === 0 && msg) {
colorizedMsg = colorizer("white", msg, pos == "system");
}
if (colorizedMsg.length !== 0)
bot.emit("chatColorized", colorizedMsg, pos, jsonMsg);
else if (msg.length !== 0)
bot.emit("chatColorized", msg, pos, jsonMsg);
});
}