aboutsummaryrefslogtreecommitdiff
path: root/src/cleaners/rank.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/cleaners/rank.ts')
-rw-r--r--src/cleaners/rank.ts84
1 files changed, 43 insertions, 41 deletions
diff --git a/src/cleaners/rank.ts b/src/cleaners/rank.ts
index d565502..0a3a4a7 100644
--- a/src/cleaners/rank.ts
+++ b/src/cleaners/rank.ts
@@ -22,48 +22,50 @@ export interface CleanRank {
/** Response cleaning (reformatting to be nicer) */
export function cleanRank({
- packageRank,
- newPackageRank,
- monthlyPackageRank,
- rankPlusColor,
- rank,
- prefix
+ packageRank,
+ newPackageRank,
+ monthlyPackageRank,
+ rankPlusColor,
+ rank,
+ prefix
}: HypixelPlayer): CleanRank {
- let name
- let color
- let colored
- if (prefix) { // derive values from prefix
- colored = prefix
- color = minecraftColorCodes[colored.match(/§./)[0][1]]
- name = colored.replace(/§./g, '').replace(/[\[\]]/g, '')
- } else {
- name = monthlyPackageRank
- || rank
- || newPackageRank?.replace('_PLUS', '+')
- || packageRank?.replace('_PLUS', '+')
+ let name
+ let color
+ let colored
+ if (prefix) { // derive values from prefix
+ colored = prefix
+ color = minecraftColorCodes[colored.match(/§./)[0][1]]
+ name = colored.replace(/§./g, '').replace(/[\[\]]/g, '')
+ } else {
+ if (monthlyPackageRank !== 'NONE')
+ name = monthlyPackageRank
+ else
+ name = rank
+ || newPackageRank?.replace('_PLUS', '+')
+ || packageRank?.replace('_PLUS', '+')
- // MVP++ is called Superstar for some reason
- if (name === 'SUPERSTAR') name = 'MVP++'
- // YouTube rank is called YouTuber, change this to the proper name
- else if (name === 'YOUTUBER') name = 'YOUTUBE'
- else if (name === undefined) name = 'NONE'
+ // MVP++ is called Superstar for some reason
+ if (name === 'SUPERSTAR') name = 'MVP++'
+ // YouTube rank is called YouTuber, change this to the proper name
+ else if (name === 'YOUTUBER') name = 'YOUTUBE'
+ else if (name === undefined) name = 'NONE'
- const plusColor = rankPlusColor ? colorCodeFromName(rankPlusColor) : null
- color = minecraftColorCodes[rankColors[name]]
- const rankColorPrefix = rankColors[name] ? '§' + rankColors[name] : ''
- const nameWithoutPlus = name.split('+')[0]
- const plusesInName = '+'.repeat(name.split('+').length - 1)
- if (plusColor && plusesInName.length >= 1)
- colored = `${rankColorPrefix}[${nameWithoutPlus}§${plusColor}${plusesInName}${rankColorPrefix}]`
- else if (name !== 'NONE')
- colored = `${rankColorPrefix}[${name}]`
- else
- // nons don't have a prefix
- colored = `${rankColorPrefix}`
- }
- return {
- name,
- color,
- colored
- }
+ const plusColor = rankPlusColor ? colorCodeFromName(rankPlusColor) : null
+ color = minecraftColorCodes[rankColors[name]]
+ const rankColorPrefix = rankColors[name] ? '§' + rankColors[name] : ''
+ const nameWithoutPlus = name.split('+')[0]
+ const plusesInName = '+'.repeat(name.split('+').length - 1)
+ if (plusColor && plusesInName.length >= 1)
+ colored = `${rankColorPrefix}[${nameWithoutPlus}§${plusColor}${plusesInName}${rankColorPrefix}]`
+ else if (name !== 'NONE')
+ colored = `${rankColorPrefix}[${name}]`
+ else
+ // nons don't have a prefix
+ colored = `${rankColorPrefix}`
+ }
+ return {
+ name,
+ color,
+ colored
+ }
}