diff options
| author | salmonik <salmonik@tuta.io> | 2026-07-30 15:09:51 +0200 |
|---|---|---|
| committer | salmonik <salmonik@tuta.io> | 2026-07-30 15:09:51 +0200 |
| commit | 7a565f377203ba8e01574952014a23dfa8d94fa3 (patch) | |
| tree | 9bf25a5f618fd79b9c9911ea670f9d4b3d2bba99 /src/commands/music.rs | |
| parent | fix assistant and senator (diff) | |
| download | senator-sperma-7a565f377203ba8e01574952014a23dfa8d94fa3.tar.gz senator-sperma-7a565f377203ba8e01574952014a23dfa8d94fa3.zip | |
fix: auto completion timing out before ready + fix preexisting warns
Diffstat (limited to 'src/commands/music.rs')
| -rw-r--r-- | src/commands/music.rs | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/src/commands/music.rs b/src/commands/music.rs index d2861e4..05abb9c 100644 --- a/src/commands/music.rs +++ b/src/commands/music.rs | |||
| @@ -220,11 +220,10 @@ fn redact_url(url: &str) -> &str { | |||
| 220 | /// yt-dlp only needs `?v=ID`; extra `&` params can cause failures. | 220 | /// yt-dlp only needs `?v=ID`; extra `&` params can cause failures. |
| 221 | pub(crate) fn sanitize_yt_url(url: &str) -> String { | 221 | pub(crate) fn sanitize_yt_url(url: &str) -> String { |
| 222 | let lower = url.to_lowercase(); | 222 | let lower = url.to_lowercase(); |
| 223 | if lower.contains("youtube.com/") || lower.contains("youtu.be/") { | 223 | if (lower.contains("youtube.com/") || lower.contains("youtu.be/")) |
| 224 | if let Some(pos) = url.find('&') { | 224 | && let Some(pos) = url.find('&') { |
| 225 | return url[..pos].to_string(); | 225 | return url[..pos].to_string(); |
| 226 | } | 226 | } |
| 227 | } | ||
| 228 | url.to_string() | 227 | url.to_string() |
| 229 | } | 228 | } |
| 230 | 229 | ||
| @@ -241,7 +240,7 @@ async fn play_impl( | |||
| 241 | ) -> Result<()> { | 240 | ) -> Result<()> { |
| 242 | ctx.defer().await?; | 241 | ctx.defer().await?; |
| 243 | 242 | ||
| 244 | let guild_id = ctx.guild_id().ok_or_else(|| lang::err_not_in_guild())?; | 243 | let guild_id = ctx.guild_id().ok_or_else(lang::err_not_in_guild)?; |
| 245 | 244 | ||
| 246 | let channel_id = ctx | 245 | let channel_id = ctx |
| 247 | .serenity_context() | 246 | .serenity_context() |
| @@ -252,7 +251,7 @@ async fn play_impl( | |||
| 252 | .get(&ctx.author().id) | 251 | .get(&ctx.author().id) |
| 253 | .and_then(|vs| vs.channel_id) | 252 | .and_then(|vs| vs.channel_id) |
| 254 | }) | 253 | }) |
| 255 | .ok_or_else(|| lang::err_not_in_voice())?; | 254 | .ok_or_else(lang::err_not_in_voice)?; |
| 256 | 255 | ||
| 257 | let src = resolve_source(ctx, melodia, file).await?; | 256 | let src = resolve_source(ctx, melodia, file).await?; |
| 258 | 257 | ||
| @@ -373,7 +372,7 @@ async fn play_impl( | |||
| 373 | /// Stop playback and disconnect from voice | 372 | /// Stop playback and disconnect from voice |
| 374 | #[poise::command(slash_command)] | 373 | #[poise::command(slash_command)] |
| 375 | pub async fn stop(ctx: Context<'_>) -> Result<()> { | 374 | pub async fn stop(ctx: Context<'_>) -> Result<()> { |
| 376 | let guild_id = ctx.guild_id().ok_or_else(|| lang::err_not_in_guild())?; | 375 | let guild_id = ctx.guild_id().ok_or_else(lang::err_not_in_guild)?; |
| 377 | ctx.data().voice_manager.disconnect(guild_id).await?; | 376 | ctx.data().voice_manager.disconnect(guild_id).await?; |
| 378 | ctx.data().music_tracks.lock().await.remove(&guild_id.get()); | 377 | ctx.data().music_tracks.lock().await.remove(&guild_id.get()); |
| 379 | ctx.send( | 378 | ctx.send( |
| @@ -389,7 +388,7 @@ pub async fn stop(ctx: Context<'_>) -> Result<()> { | |||
| 389 | #[poise::command(slash_command)] | 388 | #[poise::command(slash_command)] |
| 390 | pub async fn join(ctx: Context<'_>) -> Result<()> { | 389 | pub async fn join(ctx: Context<'_>) -> Result<()> { |
| 391 | ctx.defer().await?; | 390 | ctx.defer().await?; |
| 392 | let guild_id = ctx.guild_id().ok_or_else(|| lang::err_not_in_guild())?; | 391 | let guild_id = ctx.guild_id().ok_or_else(lang::err_not_in_guild)?; |
| 393 | 392 | ||
| 394 | let channel_id = ctx.serenity_context().cache.guild(guild_id).and_then(|g| { | 393 | let channel_id = ctx.serenity_context().cache.guild(guild_id).and_then(|g| { |
| 395 | g.voice_states | 394 | g.voice_states |
