Update for new usernames

main
Elnu 2 years ago
parent 31adf7efe8
commit 5e6bb8f2d0

@ -149,11 +149,17 @@ pub async fn submit(ctx: Context<'_>, submission: serenity::Attachment) -> Resul
break;
}
}
let username = if author.discriminator == 0 { // new usernames
author.name.clone()
} else {
format!("{}#{}", author.name, author.discriminator)
};
let username = &username;
if !existing_submitter {
let mut submitter_data = Map::new();
submitter_data.insert(
String::from("username"),
format!("{}#{}", author.name, author.discriminator).into(),
username.clone().into(),
);
let mut images: Vec<String> = Vec::new();
for (i, attachment) in attachments.iter().enumerate() {
@ -173,10 +179,9 @@ pub async fn submit(ctx: Context<'_>, submission: serenity::Attachment) -> Resul
}
requires_rebuild = true;
let file_name = format!(
"{}-{}-{}-{}{}.{}",
"{}-{}-{}{}.{}",
submission_data.len() + 1,
slugify(&author.name),
author.discriminator,
timestamp,
if i == 0 {
"".to_owned()
@ -256,7 +261,6 @@ pub async fn submit(ctx: Context<'_>, submission: serenity::Attachment) -> Resul
channel
.send_message(&ctx.serenity_context().http, |m| {
m.embed(|e| {
let username = format!("{}#{}", author.name, author.discriminator);
let domain = get_domain();
let n = get_challenge_number();
let mut description = format!(

@ -384,7 +384,12 @@ pub async fn leaderboard(ctx: &Context<'_>) -> Result<(), Error> {
let profile = format!("https://discord.com/users/{id}");
let name = &user.name;
let discriminator = user.discriminator;
leaderboard_html.push_str(&format!("<tr><td>{place}</td><td><a href=\"{profile}\" target=\"_blank\" class=\"no-underline\"><img src=\"{avatar}\" onerror=\"this.src='/default.png'\"> <span class=\"underline\">{name}<span class=\"muted\">#{:0>4}</span></span></a></td><td>{count}</td></tr>", discriminator));
leaderboard_html.push_str(&format!("<tr><td>{place}</td><td><a href=\"{profile}\" target=\"_blank\" class=\"no-underline\"><img src=\"{avatar}\" onerror=\"this.src='/default.png'\"> <span class=\"underline\">{name}"));
// New usernames have #0000 discriminator
if discriminator != 0 {
leaderboard_html.push_str(&format!("<span class=\"muted\">#{:0>4}</span>", discriminator));
}
leaderboard_html.push_str(&format!("</span></a></td><td>{count}</td></tr>"));
}
leaderboard_html.push_str("</table>");
let mut file = std::fs::OpenOptions::new()

Loading…
Cancel
Save