()
| 62 | |
| 63 | // Function to get the bottom 10 users by XP |
| 64 | async function getBottom10Users() { |
| 65 | try { |
| 66 | const data = loadUserData(); |
| 67 | |
| 68 | // Convert data to an array of objects and sort by XP in ascending order |
| 69 | const sortedUsers = Object.keys(data) |
| 70 | .map(jid => ({ jid, xp: data[jid].xp, messages: data[jid].messages })) |
| 71 | .sort((a, b) => b.xp - a.xp) |
| 72 | .slice(0, 10); // Get top 10 users |
| 73 | |
| 74 | return sortedUsers; |
| 75 | } catch (error) { |
| 76 | console.error("Error retrieving bottom 10 users:", error); |
| 77 | return []; // Return an empty array in case of error |
| 78 | } |
| 79 | } |
| 80 | |
| 81 | module.exports = { |
| 82 | ajouterOuMettreAJourUserData, |
nothing calls this directly
no test coverage detected