From f471d4caefff51d49b69551412f4859d99f674a2 Mon Sep 17 00:00:00 2001 From: salmonik Date: Fri, 6 Nov 2026 21:34:53 +0100 Subject: revert required permissions Signed-off-by: salmonik --- src/commands/utilities.rs | 62 +++++++++++++++++++++++++++++------------------ 1 file changed, 39 insertions(+), 23 deletions(-) (limited to 'src/commands/utilities.rs') diff --git a/src/commands/utilities.rs b/src/commands/utilities.rs index f43b30e..f585d83 100644 --- a/src/commands/utilities.rs +++ b/src/commands/utilities.rs @@ -4,11 +4,11 @@ use poise::serenity_prelude as serenity; use tracing::warn; use super::autocomplete::any_file; -use crate::music::sanitize_yt_url; use crate::Data; use crate::copyparty::{html_decode, percent_decode, redact_url}; use crate::error::{Error, Result}; use crate::lang; +use crate::music::sanitize_yt_url; type Context<'a> = poise::Context<'a, Data, Error>; @@ -90,19 +90,12 @@ fn safe_basename(name: &str) -> String { /// Create a unique per-operation directory and return /// `(directory, input_path, output_path)`. Concurrent commands can never /// overwrite or delete each other's files. -async fn temp_op( - original: &str, - output_name: &str, -) -> std::io::Result<(String, String, String)> { +async fn temp_op(original: &str, output_name: &str) -> std::io::Result<(String, String, String)> { let safe = safe_basename(original); let ext = ext_of(&safe) .map(|ext| format!(".{ext}")) .unwrap_or_default(); - let dir = format!( - "{}/op_{}", - crate::config::temp_path(), - uuid::Uuid::new_v4() - ); + let dir = format!("{}/op_{}", crate::config::temp_path(), uuid::Uuid::new_v4()); tokio::fs::create_dir_all(&dir).await?; let input_path = format!("{dir}/input{ext}"); let output_path = format!("{dir}/{}", safe_basename(output_name)); @@ -303,7 +296,10 @@ async fn compress_attachment_bytes( /// Compress audio bytes for playback using Vorbis (symphonia-decodable). /// Uses Vorbis instead of Opus because symphonia 0.6 lacks an Opus decoder. /// Returns the compressed .ogg bytes on success. -pub(crate) async fn compress_audio_bytes(input_bytes: &[u8], original_name: &str) -> Option> { +pub(crate) async fn compress_audio_bytes( + input_bytes: &[u8], + original_name: &str, +) -> Option> { let safe_name = safe_basename(original_name); let stem = stem_of(&safe_name).to_string(); let out_filename = format!("compressed_{stem}.ogg"); @@ -378,9 +374,28 @@ pub(crate) fn extract_urls(content: &str) -> Vec { b.is_ascii_alphanumeric() || matches!( b, - b'-' | b'.' | b'_' | b'~' | b':' | b'/' | b'?' | b'#' | b'[' | b']' | b'@' - | b'!' | b'$' | b'&' | b'\'' | b'(' | b')' | b'*' | b'+' | b',' | b';' - | b'%' | b'=' + b'-' | b'.' + | b'_' + | b'~' + | b':' + | b'/' + | b'?' + | b'#' + | b'[' + | b']' + | b'@' + | b'!' + | b'$' + | b'&' + | b'\'' + | b'(' + | b')' + | b'*' + | b'+' + | b',' + | b';' + | b'%' + | b'=' ) } let bytes = content.as_bytes(); @@ -445,9 +460,10 @@ async fn find_downloaded_file(dir: &str) -> Option<(String, String)> { Err(_) => continue, }; if let Some((t, _)) = &newest - && *t >= mtime { - continue; - } + && *t >= mtime + { + continue; + } newest = Some((mtime, entry.path().to_string_lossy().into_owned())); } newest.map(|(_, p)| { @@ -540,8 +556,10 @@ async fn run_download( Ok(result) => result.map_err(|e| Error::Custom(lang::fmt_ytdlp_err(&e)))?, Err(_) => { let _ = tokio::fs::remove_dir_all(&dl_dir).await; - ctx.say(lang::fmt_download_failed("download timed out after 10 minutes")) - .await?; + ctx.say(lang::fmt_download_failed( + "download timed out after 10 minutes", + )) + .await?; return Ok(()); } }; @@ -1043,7 +1061,7 @@ pub async fn message_download(ctx: Context<'_>, message: serenity::Message) -> R } /// Echo text to channel -#[poise::command(slash_command, required_permissions = "MANAGE_MESSAGES")] +#[poise::command(slash_command)] pub async fn say(ctx: Context<'_>, #[description = "Message to send"] text: String) -> Result<()> { // Acknowledge the interaction with an invisible ephemeral reply, delete it, // then post the actual text as a normal channel message (not a reply to the @@ -1059,9 +1077,7 @@ pub async fn say(ctx: Context<'_>, #[description = "Message to send"] text: Stri warn!("say: failed to delete ephemeral acknowledgement: {e}"); } - ctx.channel_id() - .say(ctx.serenity_context(), &text) - .await?; + ctx.channel_id().say(ctx.serenity_context(), &text).await?; Ok(()) } -- cgit v1.2.3