Support leaderboards with under 10 users

main
Elnu 2 years ago
parent ab30279375
commit 31adf7efe8

@ -375,7 +375,7 @@ pub async fn leaderboard(ctx: &Context<'_>) -> Result<(), Error> {
let mut top_submitters: Vec<(&String, &u32)> = submission_counts.iter().collect();
top_submitters.sort_by(|a, b| b.1.cmp(a.1));
let mut leaderboard_html = String::from("<table id=\"leaderboard\">");
for (i, (id, count)) in top_submitters[0..LENGTH].iter().enumerate() {
for (i, (id, count)) in top_submitters[0..std::cmp::min(top_submitters.len(), LENGTH)].iter().enumerate() {
let place = i + 1;
let user = serenity::UserId(id.parse::<u64>().unwrap())
.to_user(&ctx.serenity_context().http)

Loading…
Cancel
Save