From 3e1dd940594e72b76de52eb2f5ba7264a49b92b1 Mon Sep 17 00:00:00 2001 From: salmonik Date: Wed, 4 Nov 2026 01:16:42 +0100 Subject: music: announce a directly started track once --- src/music.rs | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/music.rs b/src/music.rs index 1461f6a..ac88631 100644 --- a/src/music.rs +++ b/src/music.rs @@ -196,7 +196,9 @@ impl MusicState { } } - let played = self.play_next_locked(guild).await?; + // The command layer posts the "now playing" message for direct + // enqueues, so don't announce here as well. + let played = self.play_next_locked(guild, false).await?; Ok(if played { EnqueueOutcome::Started } else { @@ -228,7 +230,7 @@ impl MusicState { return Ok(false); } - self.play_next_locked(guild).await + self.play_next_locked(guild, true).await } /// Stop playback and drop the queue (does not disconnect from voice). @@ -283,7 +285,7 @@ impl MusicState { gm.queue.push_front(request); } - if self.play_next_locked(guild).await? { + if self.play_next_locked(guild, true).await? { Ok(()) } else { Err(Error::Custom(lang::L_MUSIC_QUEUE_EMPTY.into())) @@ -314,7 +316,7 @@ impl MusicState { /// Pop and play the next playable track. Caller must hold the guild /// transition lock. - async fn play_next_locked(self: &Arc, guild: u64) -> Result { + async fn play_next_locked(self: &Arc, guild: u64, announce: bool) -> Result { let mut last_error: Option = None; loop { let request = { @@ -343,7 +345,7 @@ impl MusicState { } }; - let (voice_channel, announce) = { + let (voice_channel, announce_channel) = { let map = self.guilds.lock().await; match map.get(&guild) { Some(gm) => (gm.voice, gm.announce), @@ -393,8 +395,8 @@ impl MusicState { }, ); - if !request.silent { - self.announce_playing(announce, &request).await; + if announce && !request.silent { + self.announce_playing(announce_channel, &request).await; } return Ok(true); } @@ -421,7 +423,7 @@ impl MusicState { }; if is_current { - if let Err(e) = self.play_next_locked(guild).await { + if let Err(e) = self.play_next_locked(guild, true).await { error!(guild, error = %e, "failed to advance music queue"); } } -- cgit v1.2.3