Skip to content

Commit

Permalink
fix polerank
Browse files Browse the repository at this point in the history
  • Loading branch information
ender-null committed May 5, 2024
1 parent 82851a3 commit 9953af4
Showing 1 changed file with 18 additions and 20 deletions.
38 changes: 18 additions & 20 deletions src/plugins/pole.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,28 +165,26 @@ export class PolePlugin extends PluginBase {
});
text = `<b>${this.strings.ranking}:</b>`;
const rank = this.sortRanking(ranking, 'points');
rank.map(async (user) => {
text += `\n • ${await getFullName(this.bot, user.uid, false)}: <b>${user.points}</b> ${this.strings.points}`;
});
for (const user of rank) {
const name = await getFullName(this.bot, user.uid, false);
text += `\n - ${name}: <b>${user.points}</b> ${this.strings.points}`;
}

await Promise.all(
types.map(async (type) => {
let section = `\n\n<b>${capitalize(this.strings[type + 's'])}:</b>`;
let empty = true;
const rank = this.sortRanking(ranking, type);
await Promise.all(
rank.map(async (user) => {
if (user[type]) {
empty = false;
section += `\n • ${await getFullName(this.bot, user.uid, false)}: <b>${user[type]}</b> ${this.strings[type + 's']}`;
}
}),
);
if (!empty) {
text += section;
for (const type of types) {
let section = `\n\n<b>${capitalize(this.strings[type + 's'])}:</b>`;
let empty = true;
const rank = this.sortRanking(ranking, type);
for (const user of rank) {
if (user[type]) {
empty = false;
const name = await getFullName(this.bot, user.uid, false);
section += `\n - ${name}: <b>${user[type]}</b> ${this.strings[type + 's']}`;
}
}),
);
}
if (!empty) {
text += section;
}
}
} else {
this.bot.replyMessage(msg, this.bot.errors.noResults);
}
Expand Down

0 comments on commit 9953af4

Please sign in to comment.