mirror of
https://github.com/Threnklyn/MinecraftChat.git
synced 2026-05-18 20:33:28 +02:00
30 lines
675 B
JavaScript
30 lines
675 B
JavaScript
var stringToCode = require('../utils').stringToCode;
|
|
|
|
module.exports = (extra) => {
|
|
|
|
var string = '';
|
|
|
|
// for each piece of text
|
|
extra.forEach((data) => {
|
|
|
|
// get the text out of the element
|
|
var text;
|
|
if (typeof data === 'string') {
|
|
text = data;
|
|
} else if (typeof data === 'object') {
|
|
text = data.text;
|
|
}
|
|
|
|
// if text is available
|
|
if (text) {
|
|
text = text.replace(/§k/ig, ''); // remove crazy format
|
|
text = text.replace(/§l/ig, ''); // remove bold format
|
|
string += '§' + stringToCode(data.color) + text; // add the color code to the string
|
|
}
|
|
|
|
});
|
|
|
|
return string;
|
|
|
|
};
|