Driver: Fix incorrect leave behaviour in Drop handler
Sending poison messages should suffice to kill the voice session: attempting to `.leave()`. Fixes #88. This was tested using `cargo make ready` and the modified `serenity/voice/` example.
This commit is contained in:
@@ -18,4 +18,4 @@ features = ["client", "standard_framework", "voice", "rustls_backend"]
|
|||||||
|
|
||||||
[dependencies.tokio]
|
[dependencies.tokio]
|
||||||
version = "1.0"
|
version = "1.0"
|
||||||
features = ["macros", "rt-multi-thread"]
|
features = ["macros", "rt-multi-thread", "signal"]
|
||||||
|
|||||||
@@ -63,7 +63,12 @@ async fn main() {
|
|||||||
.await
|
.await
|
||||||
.expect("Err creating client");
|
.expect("Err creating client");
|
||||||
|
|
||||||
|
tokio::spawn(async move {
|
||||||
let _ = client.start().await.map_err(|why| println!("Client ended: {:?}", why));
|
let _ = client.start().await.map_err(|why| println!("Client ended: {:?}", why));
|
||||||
|
});
|
||||||
|
|
||||||
|
tokio::signal::ctrl_c().await;
|
||||||
|
println!("Received Ctrl-C, shutting down.");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[command]
|
#[command]
|
||||||
|
|||||||
@@ -308,7 +308,6 @@ impl Drop for Driver {
|
|||||||
/// Leaves the current connected voice channel, if connected to one, and
|
/// Leaves the current connected voice channel, if connected to one, and
|
||||||
/// forgets all configurations relevant to this Handler.
|
/// forgets all configurations relevant to this Handler.
|
||||||
fn drop(&mut self) {
|
fn drop(&mut self) {
|
||||||
self.leave();
|
|
||||||
let _ = self.sender.send(CoreMessage::Poison);
|
let _ = self.sender.send(CoreMessage::Poison);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user