main
Elnu 2 years ago
parent ac7909da8d
commit 74b0e6141a

@ -152,10 +152,7 @@ pub async fn submit(ctx: Context<'_>, submission: serenity::Attachment) -> Resul
let username = &username;
if !existing_submitter {
let mut submitter_data = Map::new();
submitter_data.insert(
String::from("username"),
username.clone().into(),
);
submitter_data.insert(String::from("username"), username.clone().into());
let mut images: Vec<String> = Vec::new();
for (i, attachment) in attachments.iter().enumerate() {
let extension;

@ -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>"));
}

Loading…
Cancel
Save