forked from sk7295/FALTU-BOT
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtopexp.js
More file actions
38 lines (32 loc) · 978 Bytes
/
topexp.js
File metadata and controls
38 lines (32 loc) · 978 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
module.exports = {
config: {
name: "topexp",
aliases: ['ranktop'],
version: "1.0",
author: "OTINXSANDIP",
role: 0,
shortDescription: {
en: "Top 10 Exp users"
},
longDescription: {
en: ""
},
category: "group",
guide: {
en: "{pn}"
}
},
onStart: async function ({ api, args, message, event, usersData }) {
const allUsers = await usersData.getAll();
// Filter out users with no experience points
const usersWithExp = allUsers.filter(user => user.exp > 0);
if (usersWithExp.length < 10) {
message.reply("There are not enough users with experience points to display a top 10.");
return;
}
const topExp = usersWithExp.sort((a, b) => b.exp - a.exp).slice(0, 10);
const topUsersList = topExp.map((user, index) => `${index + 1}. ${user.name}: ${user.exp}`);
const messageText = `Top 10 Rank Users:\n${topUsersList.join('\n')}`;
message.reply(messageText);
}
};