Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- cmd.hear(/^(?:топ)$/i, async (message, bot) => {
- let top = [];
- users.map(x => {
- top.push({balance: x.balance, rating: x.rating, tag: x.tag}) # в базе данных должны быть переменные: balance, rating, tag
- });
- top.sort((a, b) => {
- return b.rating - a.balance;
- });
- let text = ``;
- const find = () => {
- let pos = 1000;
- for (let i = 0; i < top.length; i++)
- {
- if(top[i].id === message.senderId) return pos = i;
- }
- return pos;
- }
- for (let i = 0; i < 10; i++)
- {
- if(!top[i]) return;
- const user = top[i];
- text += `${i === 9 ? `🔟` : `${i + 1}⃣`} @id${user.id} (${user.tag}) — 👑${utils.sp(user.rating)} | $${utils.rn(user.balance)}`; #как в топе будут выглядеть игроки
- }
- return bot(`топ игроков:
- ${text} #выводит топ
- —————————————————
- ${utils.gi(find() + 1)} ${message.user.tag} — 👑${utils.sp(message.user.rating)} | $${utils.rn(message.user.balance)}`); #ваша статистика в топе
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement