patch if comp[""] text is 0

This commit is contained in:
Yaode_owo 2024-07-30 01:14:44 -04:00
parent 877919ddbb
commit b339d327c5

View file

@ -14,7 +14,7 @@ function parseCommand(message) {
function inject(bot) {
bot.on('systemChat', (packet) => {
// console.log(packet)
console.log(packet)
const jsonmsg = JSON.parse(packet.formattedMessage);
const msg = parseMinecraftMessage(packet.formattedMessage);
const nocolormsg = parseMinecraftMessageNoColor(packet.formattedMessage);
@ -105,7 +105,7 @@ function parseMinecraftMessage(component) {
if (comp.text) {
text += comp.text;
}
if (comp[""]) {
if (typeof comp[""] === 'string' || typeof comp[""] === 'number' && comp[""] !== undefined && comp[""] !== null) { // fix if text is {"":0} show false
text += comp[""]; // after 1337 years, i found issue at here
}
if (typeof comp === 'string' || typeof comp === 'number') {
@ -168,7 +168,6 @@ function parseMinecraftColor(color) {
function parseMinecraftFormat(format) {
let result = '';
console.log(format)
if (format.bold) result += ansiFormatCodes['bold'];
if (format.italic) result += ansiFormatCodes['italic'];
if (format.underlined) result += ansiFormatCodes['underlined'];
@ -193,7 +192,7 @@ function parseMinecraftMessageNoColor(component) {
text += comp.text;
}
if (comp[""]) {
text += extractText(comp[""]);
text += comp[""];
}
if (typeof comp === 'string' || typeof comp === 'number') {
text += comp;