aboutsummaryrefslogtreecommitdiffstats
path: root/src/bot/music.rs
diff options
context:
space:
mode:
authorJokler <jokler@protonmail.com>2020-01-25 16:30:37 +0100
committerJokler <jokler@protonmail.com>2020-01-29 20:39:27 +0100
commit7be0a2f10f0cfeb89b2f498cfae316b35dcb0814 (patch)
tree78474e06ce8c84f99569394345f4b9d7387f4b22 /src/bot/music.rs
parent972adef5626706f9a192ff784ecc22d1a56b1fe4 (diff)
downloadpokebot-7be0a2f10f0cfeb89b2f498cfae316b35dcb0814.tar.gz
pokebot-7be0a2f10f0cfeb89b2f498cfae316b35dcb0814.zip
Fix quit method not stopping audio playback
Diffstat (limited to 'src/bot/music.rs')
-rw-r--r--src/bot/music.rs7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/bot/music.rs b/src/bot/music.rs
index 3677796..4d67f88 100644
--- a/src/bot/music.rs
+++ b/src/bot/music.rs
@@ -44,7 +44,6 @@ pub struct MusicBot {
state: Arc<Mutex<State>>,
}
-#[derive(Debug)]
pub struct MusicBotArgs {
pub name: String,
pub owner: Option<ClientId>,
@@ -53,6 +52,7 @@ pub struct MusicBotArgs {
pub id: Identity,
pub channel: String,
pub verbose: u8,
+ pub disconnect_cb: Box<dyn FnMut(String) + Send + Sync>,
}
impl MusicBot {
@@ -104,7 +104,7 @@ impl MusicBot {
}
let bot = Arc::new(Self {
- name: args.name,
+ name: args.name.clone(),
player,
teamspeak: connection,
playlist,
@@ -112,11 +112,14 @@ impl MusicBot {
});
let cbot = bot.clone();
+ let mut disconnect_cb = args.disconnect_cb;
+ let name = args.name;
let msg_loop = async move {
'outer: loop {
while let Some(msg) = rx.recv().await {
if let MusicBotMessage::Quit(reason) = msg {
cbot.with_teamspeak(|ts| ts.disconnect(&reason));
+ disconnect_cb(name);
break 'outer;
}
cbot.on_message(msg).await.unwrap();