async fn upload_file(
        &self,
        update_message: &mut Message,
        file: PathBuf,
        max_upload: u64,
    ) -> CommandResult {
        let file = match &self.start {
            Some(_) => match self.cut_file(&file).await {
                Err(why) => {
                    return self.send_error(&format!("Error: {:}", why)).await;
                }
                Ok(path) => path,
            },
            None => file,
        }; // get size of the file
        let size = get_size(file.as_path())?;

        // sizes smaller then 8mb can be uploaded to discord directly
        if size < MAX_FILE_SIZE && size < max_upload {
            update_message
                .edit(&self.http, |m| m.content("Uploading to Discord ..."))
                .await?;
            self.send_file_to_channel(file).await?;
            // if file is below the setted limit but above the 8mb we can upload it to transfer.sh
        } else if size < MAX_FILE_SIZE {
            update_message
                .edit(&self.http, |m| m.content("Uploading to transfer.sh ..."))
                .await?;
            self.send_file_to_transfersh(&file).await?;
            // else we have to inform the user that the file was too chonky
        } else {
            let max_mb = MAX_FILE_SIZE / 1_000_000;
            return Err(CommandError::from(format!(
                "Your download was larger then {}mb",
                max_mb
            )));
        }

        update_message
            .edit(&self.http, |m| m.content("Done!"))
            .await?;
        Ok(())
    }
///
///  Uploads the file to either discord or transfer.sh depending on the file size.
///
///  Returns an error if the file is way to chonky
///
Uploads the file to either discord or transfer.sh depending on the file size.
Returns an error if the file is way to chonky
Uploads the file to either discord or transfer . sh depending on the file size . Returns an error if the file is way to chonky
async fn upload_file(
        &self,
        update_message: &mut Message,
        file: PathBuf,
        max_upload: u64,
    ) -> CommandResult {
        let file = match &self.start {
            Some(_) => match self.cut_file(&file).await {
                Err(why) => {
                    return self.send_error(&format!("Error: {:}", why)).await;
                }
                Ok(path) => path,
            },
            None => file,
        }; // get size of the file
        let size = get_size(file.as_path())?;
        // sizes smaller then 8mb can be uploaded to discord directly
        if size < MAX_FILE_SIZE && size < max_upload {
            update_message
                .edit(&self.http, |m| m.content("Uploading to Discord ..."))
                .await?;
            self.send_file_to_channel(file).await?;
            // if file is below the setted limit but above the 8mb we can upload it to transfer.sh
        } else if size < MAX_FILE_SIZE {
            update_message
                .edit(&self.http, |m| m.content("Uploading to transfer.sh ..."))
                .await?;
            self.send_file_to_transfersh(&file).await?;
            // else we have to inform the user that the file was too chonky
        } else {
            let max_mb = MAX_FILE_SIZE / 1_000_000;
            return Err(CommandError::from(format!(
                "Your download was larger then {}mb",
                max_mb
            )));
        }
        update_message
            .edit(&self.http, |m| m.content("Done!"))
            .await?;
        Ok(())
    }
async fn upload_file ( & self , update_message : & mut Message , file : PathBuf , max_upload : u64 , ) -> CommandResult { let file = match & self . start { Some ( _ ) => match self . cut_file ( & file ) . await { Err ( why ) => { return self . send_error ( & format ! ( " " why ) ) . await ; } Ok ( path ) => path , } , None => file , } ; // get size of the file let size = get_size ( file . as_path ( ) ) ? ; // sizes smaller then 8mb can be uploaded to discord directly if size < MAX_FILE_SIZE && size < max_upload { update_message . edit ( & self . http , | m | m . content ( " " ) ) . await ? ; self . send_file_to_channel ( file ) . await ? ; // if file is below the setted limit but above the 8mb we can upload it to transfer.sh } else if size < MAX_FILE_SIZE { update_message . edit ( & self . http , | m | m . content ( " " ) ) . await ? ; self . send_file_to_transfersh ( & file ) . await ? ; // else we have to inform the user that the file was too chonky } else { let max_mb = MAX_FILE_SIZE / 1_000_000 ; return Err ( CommandError :: from ( format ! ( " " max_mb ) ) ) ; } update_message . edit ( & self . http , | m | m . content ( " " ) ) . await ? ; Ok ( ( ) ) }
Uploads the file to either discord or transfer.sh depending on the file size.
Uploads the file to either discord or transfer . sh depending on the file size .
&self
update_message
&mut Message
file
PathBuf
max_upload
u64
&self
update_message
&mut Message
file
PathBuf
max_upload
u64