Added target user to chat.

This commit is contained in:
Niels Simenon
2023-05-06 01:32:30 +02:00
parent 650a8d2ec9
commit c85ec3440b
3 changed files with 430 additions and 4 deletions

View File

@@ -3,7 +3,12 @@
const config = require('config');
const style = require('./style');
function getLeaders(points, user, { ping = true, limit = 20, skip = [] } = {}) {
function getLeaders(points, user, {
ping = true,
limit = 20,
skip = [],
pointsWord = 'points',
} = {}) {
return Object.entries(points)
.filter(([userKey]) => !skip.includes(userKey))
.sort(([, scoreA], [, scoreB]) => scoreB - scoreA)
@@ -12,7 +17,7 @@ function getLeaders(points, user, { ping = true, limit = 20, skip = [] } = {}) {
const username = userKey.split(':')[1] || userKey; // process the points file
if (index === 0) {
return `${style.bold(style.yellow(`${ping || username === user.username ? config.usernamePrefix : ''}${username}`))} with ${style.bold(`${score}`)} points`;
return `${style.bold(style.yellow(`${ping || username === user.username ? config.usernamePrefix : ''}${username}`))} with ${style.bold(`${score}`)} ${pointsWord}`;
}
return `${style.bold(style.cyan(`${ping ? config.usernamePrefix : ''}${username}`))} with ${style.bold(`${score}`)} points`;