exit async
This commit is contained in:
parent
d27fbeceef
commit
ccc0515653
14
src/main.rs
14
src/main.rs
@ -791,7 +791,12 @@ pub async fn restart(ctx: CmdContext<'_>) -> Result<(), Error> {
|
||||
.expect("Failed to restart");
|
||||
let player = ctx.data().handle.inner();
|
||||
_ = player.lock().await.shutdown_player().await;
|
||||
std::process::exit(0);
|
||||
// discord will add only when the function returns, so we fire the exit in the background
|
||||
tokio::spawn(async {
|
||||
tokio::time::sleep(Duration::from_secs(2)).await;
|
||||
std::process::exit(0);
|
||||
});
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Shuts down the bot - Note: It cannot be restarted
|
||||
@ -800,8 +805,11 @@ pub async fn shutdown(ctx: CmdContext<'_>) -> Result<(), Error> {
|
||||
ctx.say("Alright then, bye.").await?;
|
||||
let player = ctx.data().handle.inner();
|
||||
_ = player.lock().await.shutdown_player().await;
|
||||
tokio::time::sleep(Duration::from_secs(2)).await;
|
||||
std::process::exit(0);
|
||||
tokio::spawn(async {
|
||||
tokio::time::sleep(Duration::from_secs(2)).await;
|
||||
std::process::exit(0);
|
||||
});
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Save Playlist to file
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user