|
|
@ -93,7 +93,7 @@ pub async fn submit(ctx: Context<'_>, submission: serenity::Attachment) -> Resul
|
|
|
|
for (i, submission) in submission_data.iter_mut().enumerate() {
|
|
|
|
for (i, submission) in submission_data.iter_mut().enumerate() {
|
|
|
|
if is_matching_submission(&submission, author) {
|
|
|
|
if is_matching_submission(&submission, author) {
|
|
|
|
existing_submitter = true;
|
|
|
|
existing_submitter = true;
|
|
|
|
let images: Vec<String> = submission["images"].as_array_mut().unwrap().clone().iter().map(|value| value.as_str().unwrap().to_owned()).collect();
|
|
|
|
let mut images: Vec<String> = submission["images"].as_array_mut().unwrap().clone().iter().map(|value| value.as_str().unwrap().to_owned()).collect();
|
|
|
|
for attachment in attachments.iter() {
|
|
|
|
for attachment in attachments.iter() {
|
|
|
|
let extension;
|
|
|
|
let extension;
|
|
|
|
if let Some(content_type) = &attachment.content_type {
|
|
|
|
if let Some(content_type) = &attachment.content_type {
|
|
|
@ -118,6 +118,7 @@ pub async fn submit(ctx: Context<'_>, submission: serenity::Attachment) -> Resul
|
|
|
|
images.len() + 1,
|
|
|
|
images.len() + 1,
|
|
|
|
extension
|
|
|
|
extension
|
|
|
|
);
|
|
|
|
);
|
|
|
|
|
|
|
|
images.push(file_name.clone().into());
|
|
|
|
let image = reqwest::get(&attachment.url).await?.bytes().await?;
|
|
|
|
let image = reqwest::get(&attachment.url).await?.bytes().await?;
|
|
|
|
let mut image_file =
|
|
|
|
let mut image_file =
|
|
|
|
File::create(format!("{}/{}", submission_images_dir, file_name))?;
|
|
|
|
File::create(format!("{}/{}", submission_images_dir, file_name))?;
|
|
|
@ -227,11 +228,7 @@ pub async fn submit(ctx: Context<'_>, submission: serenity::Attachment) -> Resul
|
|
|
|
.await
|
|
|
|
.await
|
|
|
|
.unwrap()
|
|
|
|
.unwrap()
|
|
|
|
.accent_colour;
|
|
|
|
.accent_colour;
|
|
|
|
let mut pathbuf = std::path::PathBuf::new();
|
|
|
|
|
|
|
|
pathbuf.push(&submission_images_dir);
|
|
|
|
|
|
|
|
pathbuf.push(&image);
|
|
|
|
|
|
|
|
channel.send_message(&ctx.discord().http, |m| {
|
|
|
|
channel.send_message(&ctx.discord().http, |m| {
|
|
|
|
m.add_file(&pathbuf);
|
|
|
|
|
|
|
|
m.embed(|e| {
|
|
|
|
m.embed(|e| {
|
|
|
|
let username = format!("{}#{}", author.name, author.discriminator);
|
|
|
|
let username = format!("{}#{}", author.name, author.discriminator);
|
|
|
|
let n = get_challenge_number();
|
|
|
|
let n = get_challenge_number();
|
|
|
@ -250,14 +247,14 @@ pub async fn submit(ctx: Context<'_>, submission: serenity::Attachment) -> Resul
|
|
|
|
.name(username)
|
|
|
|
.name(username)
|
|
|
|
.url(format!("https://discord.com/users/{}", author.id));
|
|
|
|
.url(format!("https://discord.com/users/{}", author.id));
|
|
|
|
e.set_author(embed_author);
|
|
|
|
e.set_author(embed_author);
|
|
|
|
e.image(format!("attachment://{image}"));
|
|
|
|
e.image(format!("https://tegakituesday.com/{n}/{image}"));
|
|
|
|
if let Some(accent_color) = accent_color {
|
|
|
|
if let Some(accent_color) = accent_color {
|
|
|
|
e.color(accent_color);
|
|
|
|
e.color(accent_color);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
e
|
|
|
|
e
|
|
|
|
});
|
|
|
|
});
|
|
|
|
m
|
|
|
|
m
|
|
|
|
}).await?;
|
|
|
|
}).await.unwrap();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else if invalid_types {
|
|
|
|
} else if invalid_types {
|
|
|
|