From ad5e5ae08bace9c5065365e1b71fe5abff529ce4 Mon Sep 17 00:00:00 2001 From: salmonik Date: Wed, 9 Sep 2026 13:31:32 +0200 Subject: /grajcuj plays video-like extensions too Signed-off-by: salmonik --- src/commands/autocomplete.rs | 3 ++- src/commands/music.rs | 15 +++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) (limited to 'src/commands') diff --git a/src/commands/autocomplete.rs b/src/commands/autocomplete.rs index 434870c..a909738 100644 --- a/src/commands/autocomplete.rs +++ b/src/commands/autocomplete.rs @@ -197,7 +197,8 @@ pub async fn audio_file( timed_search( ctx, partial, - &["mp3", "wav", "ogg", "flac", "m4a", "opus"], + &["mp3", "wav", "ogg", "flac", "m4a", "opus", "aac", "wma", "oga", + "mp4", "webm", "mkv", "avi", "mov", "flv", "wmv", "m4v", "mpg", "mpeg", "3gp", "ts"], ) .await } diff --git a/src/commands/music.rs b/src/commands/music.rs index e528bf5..8739a5b 100644 --- a/src/commands/music.rs +++ b/src/commands/music.rs @@ -174,7 +174,8 @@ async fn resolve_source( .search( &name, 5, - &["mp3", "wav", "ogg", "flac", "m4a", "opus", "mp4"], + &["mp3", "wav", "ogg", "flac", "m4a", "opus", "aac", "wma", "oga", + "mp4", "webm", "mkv", "avi", "mov", "flv", "wmv", "m4v", "mpg", "mpeg", "3gp", "ts"], ) .await .map_err(|e| { @@ -461,15 +462,13 @@ async fn send_music_msg( Ok(()) } -/// Right-click a message → play the first audio file, or first URL if no audio files. +/// Right-click a message → play the first audio/video file, or first URL. #[poise::command(context_menu_command = "Odtwórz")] pub async fn message_grajcuj(ctx: Context<'_>, message: serenity::Message) -> Result<()> { - // Files > links: prefer audio attachments first. - if let Some(att) = message - .attachments - .iter() - .find(|a| file_type(&a.filename) == FileType::Audio) - { + // Files > links: prefer audio/video attachments first. + if let Some(att) = message.attachments.iter().find(|a| { + matches!(file_type(&a.filename), FileType::Audio | FileType::Video) + }) { return play_impl(ctx, None, Some(att.clone()), false).await; } // Fallback: first URL in message content. -- cgit v1.2.3