|
|
@ -315,6 +315,7 @@ pub async fn images(ctx: Context<'_>) -> Result<(), Error> {
|
|
|
|
prefix_command,
|
|
|
|
prefix_command,
|
|
|
|
slash_command,
|
|
|
|
slash_command,
|
|
|
|
ephemeral,
|
|
|
|
ephemeral,
|
|
|
|
|
|
|
|
broadcast_typing,
|
|
|
|
description_localized(
|
|
|
|
description_localized(
|
|
|
|
"en-US",
|
|
|
|
"en-US",
|
|
|
|
"Delete images from your current submission using image numbers from the images command."
|
|
|
|
"Delete images from your current submission using image numbers from the images command."
|
|
|
@ -326,6 +327,9 @@ pub async fn imagedelete(ctx: Context<'_>, number: i32) -> Result<(), Error> {
|
|
|
|
.await?;
|
|
|
|
.await?;
|
|
|
|
return Ok(());
|
|
|
|
return Ok(());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if let Context::Application(_) = ctx {
|
|
|
|
|
|
|
|
ctx.defer_ephemeral().await?;
|
|
|
|
|
|
|
|
}
|
|
|
|
let challenge_number = get_challenge_number();
|
|
|
|
let challenge_number = get_challenge_number();
|
|
|
|
let mut submission_data = get_current_submission_data();
|
|
|
|
let mut submission_data = get_current_submission_data();
|
|
|
|
for (i, submission) in submission_data.iter_mut().enumerate() {
|
|
|
|
for (i, submission) in submission_data.iter_mut().enumerate() {
|
|
|
@ -396,6 +400,12 @@ pub async fn imagedelete(ctx: Context<'_>, number: i32) -> Result<(), Error> {
|
|
|
|
Path::new(old).extension().unwrap().to_str().unwrap()
|
|
|
|
Path::new(old).extension().unwrap().to_str().unwrap()
|
|
|
|
);
|
|
|
|
);
|
|
|
|
let to = format!("{}/{}", submission_images_dir, new);
|
|
|
|
let to = format!("{}/{}", submission_images_dir, new);
|
|
|
|
|
|
|
|
if old.eq(&new) {
|
|
|
|
|
|
|
|
// TODO: This could be made more efficient by
|
|
|
|
|
|
|
|
// automatically starting iteration just after deleted image
|
|
|
|
|
|
|
|
// since only images with later indexes will be affected
|
|
|
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
}
|
|
|
|
fs_extra::file::move_file(from, to, &fs_extra::file::CopyOptions::default())
|
|
|
|
fs_extra::file::move_file(from, to, &fs_extra::file::CopyOptions::default())
|
|
|
|
.unwrap();
|
|
|
|
.unwrap();
|
|
|
|
*image = new.into();
|
|
|
|
*image = new.into();
|
|
|
|