aboutsummaryrefslogtreecommitdiffstats
path: root/src/commands/music.rs
diff options
context:
space:
mode:
authorsalmonik <salmonik@tuta.io>2026-09-09 13:25:45 +0200
committersalmonik <salmonik@tuta.io>2026-09-09 13:25:45 +0200
commitf512d9d22dc3b57bd53834c393304081e9fd4faa (patch)
tree9e959541f4a01c650b31d8b0fb9d6e6118230853 /src/commands/music.rs
parentassistant replies to the message (diff)
downloadsenator-sperma-f512d9d22dc3b57bd53834c393304081e9fd4faa.tar.gz
senator-sperma-f512d9d22dc3b57bd53834c393304081e9fd4faa.zip
message-contextual /grajcuj
Signed-off-by: salmonik <salmonik@tuta.io>
Diffstat (limited to 'src/commands/music.rs')
-rw-r--r--src/commands/music.rs24
1 files changed, 23 insertions, 1 deletions
diff --git a/src/commands/music.rs b/src/commands/music.rs
index 019a015..e528bf5 100644
--- a/src/commands/music.rs
+++ b/src/commands/music.rs
@@ -1,4 +1,6 @@
1use poise::serenity_prelude as serenity; 1use poise::serenity_prelude as serenity;
2use super::utilities::{FileType, extract_urls, file_type};
3
2use tracing::{error, info}; 4use tracing::{error, info};
3 5
4use super::autocomplete::audio_file; 6use super::autocomplete::audio_file;
@@ -459,6 +461,26 @@ async fn send_music_msg(
459 Ok(()) 461 Ok(())
460} 462}
461 463
464/// Right-click a message → play the first audio file, or first URL if no audio files.
465#[poise::command(context_menu_command = "Odtwórz")]
466pub async fn message_grajcuj(ctx: Context<'_>, message: serenity::Message) -> Result<()> {
467 // Files > links: prefer audio attachments first.
468 if let Some(att) = message
469 .attachments
470 .iter()
471 .find(|a| file_type(&a.filename) == FileType::Audio)
472 {
473 return play_impl(ctx, None, Some(att.clone()), false).await;
474 }
475 // Fallback: first URL in message content.
476 if let Some(url) = extract_urls(&message.content).into_iter().next() {
477 return play_impl(ctx, Some(url), None, false).await;
478 }
479 ctx.say(lang::L_MUSIC_NO_AUDIO_ATTACHMENTS).await?;
480 Ok(())
481}
482
483
462pub fn commands() -> Vec<poise::Command<Data, Error>> { 484pub fn commands() -> Vec<poise::Command<Data, Error>> {
463 vec![grajcuj(), stop(), join()] 485 vec![grajcuj(), stop(), join(), message_grajcuj()]
464} 486}