Answer the question
In order to leave comments, you need to log in
The node.js script did according to the guide (top 10 in terms of balance) but something does not work. how to solve?
the code itself
updates.hear(/(?:Top|top)/i, (context) => {
let _users = [];
for (let key in users) {
if (users[key] .permission === 0 && !users[key] .ban){
_users.push({
id: key,
balance: users[key] .balance,
});
}
}
return context.send(
"Top 10 by balance:\n" +
_users
. sort((a, b) =>b.balance - a.balance)
.slice(0, 10)
.map((x, i) => `${++i}. @id${x. id} - ${x.balance}`)
.join("\n")
);
});
Answer the question
In order to leave comments, you need to log in
Indeed - something does not work.
But there is a solution - to fix what does not work.
Don't thank.
First, when starting the node, insert --inspect and open devtools google.
And see what the code will do in each loop. What you propose is not entirely appropriate, especially such a format for submitting code)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question