Tentative embed fix via reuploading

late-submissions
Elnu 2 years ago
parent c7ac46a427
commit e0f164338a

@ -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;
images = submission["images"].as_array_mut().unwrap().clone(); images = submission["images"].as_array_mut().unwrap().clone().iter().map(|value| value.to_string()).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 {
@ -201,7 +201,8 @@ pub async fn submit(ctx: Context<'_>, submission: serenity::Attachment) -> Resul
let invite = if data.contains_key("invite") { let invite = if data.contains_key("invite") {
Some(data["invite"].as_str().unwrap()) Some(data["invite"].as_str().unwrap())
} else { } else {
None }; for image in images.iter() { None };
for image in images.iter() {
for (other_guild_id, data) in guild_data.iter() { for (other_guild_id, data) in guild_data.iter() {
let here = other_guild_id.eq(&ctx.guild_id().unwrap().as_u64().to_string()); let here = other_guild_id.eq(&ctx.guild_id().unwrap().as_u64().to_string());
if !repost_here && here { if !repost_here && here {
@ -225,7 +226,11 @@ 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();
@ -244,7 +249,7 @@ 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!("https://tegakituesday.com/{n}/{image}")); e.image(format!("attachment://{image}"));
if let Some(accent_color) = accent_color { if let Some(accent_color) = accent_color {
e.color(accent_color); e.color(accent_color);
} }

Loading…
Cancel
Save