Make embeds link to Tegaki Tuesday

late-submissions
Elnu 2 years ago
parent 8dde342d97
commit c7ac46a427

@ -89,10 +89,11 @@ pub async fn submit(ctx: Context<'_>, submission: serenity::Attachment) -> Resul
Context::Prefix(ctx) => &ctx.msg.attachments, Context::Prefix(ctx) => &ctx.msg.attachments,
}; };
let author = ctx.author(); let author = ctx.author();
let mut images = Vec::new();
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 mut images = submission["images"].as_array_mut().unwrap().clone(); images = submission["images"].as_array_mut().unwrap().clone();
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 {
@ -124,7 +125,7 @@ pub async fn submit(ctx: Context<'_>, submission: serenity::Attachment) -> Resul
image_file.write_all(&image)?; image_file.write_all(&image)?;
image_file.flush()?; image_file.flush()?;
} }
submission["images"] = images.into(); submission["images"] = images.clone().into();
break; break;
} }
} }
@ -200,9 +201,7 @@ 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 None }; for image in images.iter() {
};
for attachment in attachments.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 {
@ -245,7 +244,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(&attachment.url); 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);
} }

Loading…
Cancel
Save