Fix leaderboard showing undefined and pinging everyone.
This commit is contained in:
@@ -3,15 +3,15 @@
|
||||
const config = require('config');
|
||||
const style = require('./style');
|
||||
|
||||
function getLeaders(points, _user) {
|
||||
function getLeaders(points, user, ping = false) {
|
||||
return Object.entries(points).sort(([, scoreA], [, scoreB]) => scoreB - scoreA).map(([userKey, score], index) => {
|
||||
const username = userKey.split(':')[1]; // process the points file
|
||||
const username = userKey.split(':')[1] || userKey; // process the points file
|
||||
|
||||
if (index === 0) {
|
||||
return `${style.bold(style.yellow(`${config.usernamePrefix}${username}`))} with ${style.bold(`${score}`)} points`;
|
||||
return `${style.bold(style.yellow(`${ping ? config.usernamePrefix : ''}${username}`))} with ${style.bold(`${score}`)} points`;
|
||||
}
|
||||
|
||||
return `${style.bold(style.cyan(`${config.usernamePrefix}${username}`))} with ${style.bold(`${score}`)} points`;
|
||||
return `${style.bold(style.cyan(`${ping ? config.usernamePrefix : ''}${username}`))} with ${style.bold(`${score}`)} points`;
|
||||
}).join(', ');
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user