diff options
author | mat <github@matdoes.dev> | 2021-06-29 18:03:19 -0500 |
---|---|---|
committer | mat <github@matdoes.dev> | 2021-06-29 18:03:19 -0500 |
commit | 568c74568c1397ea0db329b205e6ff6fd80eabd4 (patch) | |
tree | d277de555558d404715208889f9459500552ac6a /src | |
parent | 49ff24343e1c964b6cb82fdf76957ffd2f27d049 (diff) | |
download | skyblock-api-568c74568c1397ea0db329b205e6ff6fd80eabd4.tar.gz skyblock-api-568c74568c1397ea0db329b205e6ff6fd80eabd4.tar.bz2 skyblock-api-568c74568c1397ea0db329b205e6ff6fd80eabd4.zip |
fix youtube rank displaying wrongly
closes #49
Diffstat (limited to 'src')
-rw-r--r-- | src/cleaners/rank.ts | 25 |
1 files changed, 19 insertions, 6 deletions
diff --git a/src/cleaners/rank.ts b/src/cleaners/rank.ts index 76bf518..4892bf2 100644 --- a/src/cleaners/rank.ts +++ b/src/cleaners/rank.ts @@ -30,12 +30,13 @@ export function cleanRank({ rank, prefix }: HypixelPlayer): CleanRank { - let name - let color - let colored + let name: string | undefined + let color: string + let colored: string + let bracketColor: string | undefined if (prefix) { // derive values from prefix colored = prefix - color = minecraftColorCodes[colored.match(/§./)[0][1]] + color = minecraftColorCodes[colored.match(/§./)![0][1]] name = colored.replace(/§./g, '').replace(/[\[\]]/g, '') } else { if (monthlyPackageRank && monthlyPackageRank !== 'NONE') @@ -54,6 +55,7 @@ export function cleanRank({ // YouTube rank is called YouTuber, change this to the proper name case 'YOUTUBER': name = 'YOUTUBE' + bracketColor = 'c' break case 'GAME_MASTER': name = 'GM' @@ -68,12 +70,23 @@ export function cleanRank({ const plusColor = rankPlusColor ? colorCodeFromName(rankPlusColor) : null color = minecraftColorCodes[rankColors[name]] - const rankColorPrefix = rankColors[name] ? '§' + rankColors[name] : '' + let rankColorPrefix = rankColors[name] ? '§' + rankColors[name] : '' + + // the text is white, but only in the prefix + if (name === 'YOUTUBE') + rankColorPrefix = '§f' + const nameWithoutPlus = name.split('+')[0] const plusesInName = '+'.repeat(name.split('+').length - 1) if (plusColor && plusesInName.length >= 1) - colored = `${rankColorPrefix}[${nameWithoutPlus}§${plusColor}${plusesInName}${rankColorPrefix}]` + if (bracketColor) + colored = `§${bracketColor}[${rankColorPrefix}${nameWithoutPlus}§${plusColor}${plusesInName}${rankColorPrefix}§${bracketColor}]` + else + colored = `${rankColorPrefix}[${nameWithoutPlus}§${plusColor}${plusesInName}${rankColorPrefix}]` else if (name !== 'NONE') + if (bracketColor) + colored = `§${bracketColor}[${rankColorPrefix}${name}§${bracketColor}]` + else colored = `${rankColorPrefix}[${name}]` else // nons don't have a prefix |