How to make a leaderboard command with keyv?
Hey! I’m running the latest version of djs and using v 19 of node. I am using keyv for my economy commands and I would like to make a leaderboard. How do I get the top people if i use keyv.get(
${interaction.user.username}_balance
}?2 Replies
- What's your exact discord.js
npm list discord.js
and node node -v
version?
- Not a discord.js issue? Check out #other-js-ts.
- Consider reading #how-to-get-help to improve your question!
- Explain what exactly your issue is.
- Post the full error stack trace, not just the top part!
- Show your code!
- Issue solved? Press the button!this is what I got after making some experiment
you can convert the Map to an array using
for...of
loop and compare the array by using sort.
Example:
So by using this, you can get the top user by get the first value of the array (array[0]
)
btw this is the output of this code