Skip to content

Commit 83fa37b

Browse files
committed
Cleanup leaderboard code
1 parent 3d3b4cb commit 83fa37b

File tree

1 file changed

+8
-23
lines changed

1 file changed

+8
-23
lines changed

src/mahoji/commands/leaderboard.ts

Lines changed: 8 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,6 @@ import { getUsername, getUsernameSync } from '@/lib/util.js';
2828

2929
const LB_PAGE_SIZE = 10;
3030

31-
function lbMsg(str: string, ironmanOnly?: boolean) {
32-
return {
33-
content: `Showing you the ${str} leaderboard, click the buttons to change pages.${
34-
ironmanOnly ? ' Showing only ironmen.' : ''
35-
}`,
36-
ephemeral: true
37-
};
38-
}
39-
4031
async function bulkGetUsernames(userIDs: string[]) {
4132
await Promise.all(uniqueArr(userIDs).map(id => getUsername(id)));
4233
}
@@ -94,7 +85,13 @@ async function doMenuWrapper({
9485
`${getPos(c, i)}**${user.full_name ?? (await getUsername(user.id))}:** ${formatter ? formatter(user.score) : user.score.toLocaleString()}`
9586
);
9687
const pageText = (await Promise.all(unwaited)).join('\n');
97-
return { embeds: [new EmbedBuilder().setTitle(title).setDescription(pageText)] };
88+
return {
89+
embeds: [
90+
new EmbedBuilder()
91+
.setTitle(`${title}${ironmanOnly ? ' (Ironmen Only)' : ''}`)
92+
.setDescription(pageText)
93+
]
94+
};
9895
};
9996
pages.push(makePage);
10097
}
@@ -103,19 +100,7 @@ async function doMenuWrapper({
103100
}
104101

105102
return interaction.makePaginatedMessage({
106-
pages: pages.map((p, i) => {
107-
if (isFunction(p)) {
108-
return p;
109-
}
110-
111-
return {
112-
embeds: [
113-
new EmbedBuilder()
114-
.setTitle(`${lbMsg(title, ironmanOnly).content} (Page ${i + 1}/${pages.length})`)
115-
.setDescription(p)
116-
]
117-
};
118-
})
103+
pages
119104
});
120105
}
121106

0 commit comments

Comments
 (0)