stop command now just stops audio. cleaned some code

This commit is contained in:
jellywx 2021-04-10 23:50:44 +01:00
parent d70f790b3d
commit 29dd3532bb
2 changed files with 15 additions and 20 deletions

2
Cargo.lock generated
View File

@ -1838,7 +1838,7 @@ dependencies = [
[[package]] [[package]]
name = "soundfx-rs" name = "soundfx-rs"
version = "1.2.1" version = "1.2.2"
dependencies = [ dependencies = [
"dashmap", "dashmap",
"dotenv", "dotenv",

View File

@ -289,33 +289,23 @@ async fn join_channel(
let call_opt = songbird.get(guild.id); let call_opt = songbird.get(guild.id);
if let Some(call) = call_opt { if let Some(call) = call_opt {
{
// set call to deafen
let _ = call.lock().await.deafen(true).await;
}
(call, Ok(())) (call, Ok(()))
} else { } else {
let (call, res) = songbird.join(guild.id, channel_id).await; let (call, res) = songbird.join(guild.id, channel_id).await;
{
// set call to deafen
let _ = call.lock().await.deafen(true).await;
}
(call, res) (call, res)
} }
} else { } else {
let (call, res) = songbird.join(guild.id, channel_id).await; let (call, res) = songbird.join(guild.id, channel_id).await;
{
// set call to deafen
let _ = call.lock().await.deafen(true).await;
}
(call, res) (call, res)
}; };
{
// set call to deafen
let _ = call.lock().await.deafen(true).await;
}
(call, res) (call, res)
} }
@ -767,9 +757,9 @@ __Available ambience sounds:__
#[command] #[command]
#[permission_level(Managed)] #[permission_level(Managed)]
async fn stop_playing(ctx: &Context, msg: &Message, _args: Args) -> CommandResult { async fn stop_playing(ctx: &Context, msg: &Message, _args: Args) -> CommandResult {
{ let guild_id = msg.guild_id.unwrap();
let guild_id = msg.guild_id.unwrap();
{
let track_count = ctx let track_count = ctx
.data .data
.read() .read()
@ -782,9 +772,14 @@ async fn stop_playing(ctx: &Context, msg: &Message, _args: Args) -> CommandResul
write_lock.insert(guild_id, 0); write_lock.insert(guild_id, 0);
} }
let voice_manager = songbird::get(ctx).await.unwrap(); let songbird = songbird::get(ctx).await.unwrap();
let call_opt = songbird.get(guild_id);
let _ = voice_manager.leave(msg.guild_id.unwrap()).await; if let Some(call) = call_opt {
let mut lock = call.lock().await;
lock.stop();
}
Ok(()) Ok(())
} }