diff options
| author | salmonik <salmonik@tuta.io> | 2026-11-02 15:23:51 +0100 |
|---|---|---|
| committer | salmonik <salmonik@tuta.io> | 2026-11-02 15:23:51 +0100 |
| commit | d4ab83f20956fba09133571e14a9a64244b33d64 (patch) | |
| tree | 1f47dd4b1a2307ff806e3d90b63775fccb820c07 /src/music.rs | |
| parent | say: post text as a normal message after an invisible ack (diff) | |
| download | senator-sperma-d4ab83f20956fba09133571e14a9a64244b33d64.tar.gz senator-sperma-d4ab83f20956fba09133571e14a9a64244b33d64.zip | |
cron: keep scheduled audio silent
Add a per-track silent flag. Cron already uses play_now (interrupt the
current track), but play_next_locked still announced the track to the last
known text channel; suppress playing and failure announcements for silent
tracks, including when a cron track fails to prepare.
Diffstat (limited to '')
| -rw-r--r-- | src/music.rs | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/src/music.rs b/src/music.rs index 8dfc4f8..1461f6a 100644 --- a/src/music.rs +++ b/src/music.rs | |||
| @@ -47,6 +47,9 @@ pub struct TrackRequest { | |||
| 47 | /// re-upload the file alongside the "playing" message. | 47 | /// re-upload the file alongside the "playing" message. |
| 48 | pub reupload: Option<(String, String)>, | 48 | pub reupload: Option<(String, String)>, |
| 49 | pub requester: Option<serenity::UserId>, | 49 | pub requester: Option<serenity::UserId>, |
| 50 | /// Suppress the "playing" and failure announcements for this track. | ||
| 51 | /// Cron audio uses this so scheduled playback stays silent. | ||
| 52 | pub silent: bool, | ||
| 50 | } | 53 | } |
| 51 | 54 | ||
| 52 | /// Where an enqueued track goes relative to the current playback. | 55 | /// Where an enqueued track goes relative to the current playback. |
| @@ -331,8 +334,10 @@ impl MusicState { | |||
| 331 | Ok(input) => input, | 334 | Ok(input) => input, |
| 332 | Err(e) => { | 335 | Err(e) => { |
| 333 | warn!(track = %request.display_name, error = %e, "failed to prepare queued track"); | 336 | warn!(track = %request.display_name, error = %e, "failed to prepare queued track"); |
| 334 | let message = lang::fmt_music_track_failed(&request.display_name, &e); | 337 | if !request.silent { |
| 335 | self.announce_failure(guild, message).await; | 338 | let message = lang::fmt_music_track_failed(&request.display_name, &e); |
| 339 | self.announce_failure(guild, message).await; | ||
| 340 | } | ||
| 336 | last_error = Some(e); | 341 | last_error = Some(e); |
| 337 | continue; | 342 | continue; |
| 338 | } | 343 | } |
| @@ -388,7 +393,9 @@ impl MusicState { | |||
| 388 | }, | 393 | }, |
| 389 | ); | 394 | ); |
| 390 | 395 | ||
| 391 | self.announce_playing(announce, &request).await; | 396 | if !request.silent { |
| 397 | self.announce_playing(announce, &request).await; | ||
| 398 | } | ||
| 392 | return Ok(true); | 399 | return Ok(true); |
| 393 | } | 400 | } |
| 394 | } | 401 | } |
