|
|
|
@ -388,7 +388,10 @@ 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..std::cmp::min(top_submitters.len(), 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)
|
|
|
|
@ -401,7 +404,10 @@ pub async fn leaderboard(ctx: &Context<'_>) -> Result<(), Error> {
|
|
|
|
|
// New usernames have #0000 discriminator
|
|
|
|
|
// Can't use User trait user.display_name() because of muted span
|
|
|
|
|
if discriminator != 0 {
|
|
|
|
|
leaderboard_html.push_str(&format!("<span class=\"muted\">#{:0>4}</span>", discriminator));
|
|
|
|
|
leaderboard_html.push_str(&format!(
|
|
|
|
|
"<span class=\"muted\">#{:0>4}</span>",
|
|
|
|
|
discriminator
|
|
|
|
|
));
|
|
|
|
|
}
|
|
|
|
|
leaderboard_html.push_str(&format!("</span></a></td><td>{count}</td></tr>"));
|
|
|
|
|
}
|
|
|
|
|