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

Loading…
Cancel
Save