diff options
| author | salmonik <salmonik@tuta.io> | 2026-11-04 01:16:42 +0100 |
|---|---|---|
| committer | salmonik <salmonik@tuta.io> | 2026-11-04 01:16:42 +0100 |
| commit | 3e1dd940594e72b76de52eb2f5ba7264a49b92b1 (patch) | |
| tree | d17cb1e3eb35d9689632f734e3ffa011e6908270 | |
| parent | cron: simplify the first-fire lookup (diff) | |
| download | senator-sperma-3e1dd940594e72b76de52eb2f5ba7264a49b92b1.tar.gz senator-sperma-3e1dd940594e72b76de52eb2f5ba7264a49b92b1.zip | |
music: announce a directly started track once
| -rw-r--r-- | src/music.rs | 18 |
1 files changed, 10 insertions, 8 deletions
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 { | |||
| 196 | } | 196 | } |
| 197 | } | 197 | } |
| 198 | 198 | ||
| 199 | let played = self.play_next_locked(guild).await?; | 199 | // The command layer posts the "now playing" message for direct |
| 200 | // enqueues, so don't announce here as well. | ||
| 201 | let played = self.play_next_locked(guild, false).await?; | ||
| 200 | Ok(if played { | 202 | Ok(if played { |
| 201 | EnqueueOutcome::Started | 203 | EnqueueOutcome::Started |
| 202 | } else { | 204 | } else { |
| @@ -228,7 +230,7 @@ impl MusicState { | |||
| 228 | return Ok(false); | 230 | return Ok(false); |
| 229 | } | 231 | } |
| 230 | 232 | ||
| 231 | self.play_next_locked(guild).await | 233 | self.play_next_locked(guild, true).await |
| 232 | } | 234 | } |
| 233 | 235 | ||
| 234 | /// Stop playback and drop the queue (does not disconnect from voice). | 236 | /// Stop playback and drop the queue (does not disconnect from voice). |
| @@ -283,7 +285,7 @@ impl MusicState { | |||
| 283 | gm.queue.push_front(request); | 285 | gm.queue.push_front(request); |
| 284 | } | 286 | } |
| 285 | 287 | ||
| 286 | if self.play_next_locked(guild).await? { | 288 | if self.play_next_locked(guild, true).await? { |
| 287 | Ok(()) | 289 | Ok(()) |
| 288 | } else { | 290 | } else { |
| 289 | Err(Error::Custom(lang::L_MUSIC_QUEUE_EMPTY.into())) | 291 | Err(Error::Custom(lang::L_MUSIC_QUEUE_EMPTY.into())) |
| @@ -314,7 +316,7 @@ impl MusicState { | |||
| 314 | 316 | ||
| 315 | /// Pop and play the next playable track. Caller must hold the guild | 317 | /// Pop and play the next playable track. Caller must hold the guild |
| 316 | /// transition lock. | 318 | /// transition lock. |
| 317 | async fn play_next_locked(self: &Arc<Self>, guild: u64) -> Result<bool> { | 319 | async fn play_next_locked(self: &Arc<Self>, guild: u64, announce: bool) -> Result<bool> { |
| 318 | let mut last_error: Option<Error> = None; | 320 | let mut last_error: Option<Error> = None; |
| 319 | loop { | 321 | loop { |
| 320 | let request = { | 322 | let request = { |
| @@ -343,7 +345,7 @@ impl MusicState { | |||
| 343 | } | 345 | } |
| 344 | }; | 346 | }; |
| 345 | 347 | ||
| 346 | let (voice_channel, announce) = { | 348 | let (voice_channel, announce_channel) = { |
| 347 | let map = self.guilds.lock().await; | 349 | let map = self.guilds.lock().await; |
| 348 | match map.get(&guild) { | 350 | match map.get(&guild) { |
| 349 | Some(gm) => (gm.voice, gm.announce), | 351 | Some(gm) => (gm.voice, gm.announce), |
| @@ -393,8 +395,8 @@ impl MusicState { | |||
| 393 | }, | 395 | }, |
| 394 | ); | 396 | ); |
| 395 | 397 | ||
| 396 | if !request.silent { | 398 | if announce && !request.silent { |
| 397 | self.announce_playing(announce, &request).await; | 399 | self.announce_playing(announce_channel, &request).await; |
| 398 | } | 400 | } |
| 399 | return Ok(true); | 401 | return Ok(true); |
| 400 | } | 402 | } |
| @@ -421,7 +423,7 @@ impl MusicState { | |||
| 421 | }; | 423 | }; |
| 422 | 424 | ||
| 423 | if is_current { | 425 | if is_current { |
| 424 | if let Err(e) = self.play_next_locked(guild).await { | 426 | if let Err(e) = self.play_next_locked(guild, true).await { |
| 425 | error!(guild, error = %e, "failed to advance music queue"); | 427 | error!(guild, error = %e, "failed to advance music queue"); |
| 426 | } | 428 | } |
| 427 | } | 429 | } |
