-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
leaderboard.ts
46 lines (43 loc) · 1.21 KB
/
leaderboard.ts
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
39
40
41
42
43
44
45
46
import * as app from "#app"
export default new app.Command({
name: "leaderboard",
aliases: ["lb", "ladder", "top", "rank"],
description: "Show all leaderboards",
channelType: "guild",
options: [
app.option({
name: "lines",
description: "Number of lines to show per page",
type: "number",
default: 15,
aliases: ["line", "count"],
validate: (value) => value > 0 && value <= 50,
}),
],
async run(message) {
const guild = await app.getGuild(message.guild, { forceExists: true })
const ladders = [
app.ratingLadder(guild._id),
app.activeLadder(guild._id),
app.pointLadder,
app.coinLadder,
]
return message.channel.send({
embeds: [
new app.EmbedBuilder().setTitle("Leaderboards").setFields(
await Promise.all(
ladders.map(async (ladder) => ({
name: ladder.options.title,
value:
(await ladder.fetchPage({
pageIndex: 0,
pageLineCount: message.args.lines,
})) || `${app.emote(message, "Cross")} No ladder available`,
inline: false,
})),
),
),
],
})
},
})