fix: indexing
Node.js CI / Lint and Test (push) Successful in 39s

This commit is contained in:
2025-08-15 00:08:53 -07:00
parent 71566a83ed
commit 2543341d3c
+2 -2
View File
@@ -27,14 +27,14 @@ export const leaderboard: Command = async(pavelle, interaction) => {
}); });
const topTen = sorted.slice(0, 10).map((member, index) => { const topTen = sorted.slice(0, 10).map((member, index) => {
return `- **#${index.toString()}:** <@${member.userId}> - ${member.points.toString()} point(s).`; return `- **#${(index + 1).toString()}:** <@${member.userId}> - ${member.points.toString()} point(s).`;
}). }).
join("\n"); join("\n");
const yourScore = sorted.find((member) => { const yourScore = sorted.find((member) => {
return member.userId === interaction.member.id; return member.userId === interaction.member.id;
}); });
const yourRank = yourScore const yourRank = yourScore
? `You are rank #${sorted.indexOf(yourScore).toString()} with ${yourScore.points.toString()} points.` ? `You are rank #${(sorted.indexOf(yourScore) + 1).toString()} with ${yourScore.points.toString()} points.`
: "You are not ranked. Try throwing some stuff!"; : "You are not ranked. Try throwing some stuff!";
await interaction.editReply({ await interaction.editReply({
allowedMentions: { allowedMentions: {