exit async

This commit is contained in:
hendrik 2025-05-20 02:55:47 +02:00
parent d27fbeceef
commit ccc0515653

View File

@ -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