param { String } text param { String } link export function addLink ( text , link ) { if ( ! link . match ( "^https?://" ) ) { link = "https://" + link ; } return "[" + link + "]" + text + "[]" ; } param { Number } n param { Number } min param { Number } max function clampInt ( n , min , max ) { if ( n > max ) { n = max ; } else if ( min > n ) { n = min ; } return n ; } param { String } text param { Number } red param { Number } green param { Number } blue param { Number } alpha export function addColor ( text , red , green , blue , alpha = 255 ) { red = clampInt ( red , 0 , 255 ) ; green = clampInt ( green , 0 , 255 ) ; blue = clampInt ( blue , 0 , 255 ) ; alpha = clampInt ( alpha , 0 , 255 ) ; let redHex , greenHex , blueHex , alphaHex ; redHex = red < 16 ? "0" + red . toString ( 16 ) : red . toString ( 16 ) ; greenHex = green < 16 ? "0" + green . toString ( 16 ) : green . toString ( 16 ) ; blueHex = blue < 16 ? "0" + blue . toString ( 16 ) : blue . toString ( 16 ) ; alphaHex = alpha < 16 ? "0" + alpha . toString ( 16 ) : alpha . toString ( 16 ) ; return "[" + redHex + greenHex + blueHex + alphaHex + "]" + text + "[]" ; }