Advertisement
Guest User

Untitled

a guest
Apr 4th, 2020
169
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. cmd.hear(/^(?:топ)$/i, async (message, bot) => {
  2. let top = [];
  3. users.map(x => {
  4. top.push({balance: x.balance, rating: x.rating, tag: x.tag}) # в базе данных должны быть переменные: balance, rating, tag
  5. });
  6.  
  7. top.sort((a, b) => {
  8. return b.rating - a.balance;
  9. });
  10.  
  11. let text = ``;
  12. const find = () => {
  13.  
  14. let pos = 1000;
  15.  
  16. for (let i = 0; i < top.length; i++)
  17. {
  18. if(top[i].id === message.senderId) return pos = i;
  19. }
  20. return pos;
  21. }
  22.  
  23. for (let i = 0; i < 10; i++)
  24. {
  25. if(!top[i]) return;
  26. const user = top[i];
  27.  
  28. text += `${i === 9 ? `🔟` : `${i + 1}⃣`} @id${user.id} (${user.tag}) — 👑${utils.sp(user.rating)} | $${utils.rn(user.balance)}`; #как в топе будут выглядеть игроки
  29. }
  30.  
  31. return bot(`топ игроков:
  32. ${text} #выводит топ
  33. —————————————————
  34. ${utils.gi(find() + 1)} ${message.user.tag} — 👑${utils.sp(message.user.rating)} | $${utils.rn(message.user.balance)}`); #ваша статистика в топе
  35.  
  36. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement