aboutsummaryrefslogtreecommitdiff
path: root/src/commands.rs
diff options
context:
space:
mode:
authorNathan Perry <avaglir@gmail.com>2018-02-14 02:56:09 -0500
committerNathan Perry <avaglir@gmail.com>2018-02-14 02:56:09 -0500
commit49af4053df8e40d584c43f856e4d6bb3b8432698 (patch)
tree31aec40e2bb26e59a486aa73f0aa02e3a8f39b95 /src/commands.rs
parent0e30b074c1e27f11141ff6c74e6dc948a981603b (diff)
thulani leaves when he is done playing
Diffstat (limited to 'src/commands.rs')
-rw-r--r--src/commands.rs20
1 files changed, 18 insertions, 2 deletions
diff --git a/src/commands.rs b/src/commands.rs
index 83eba45..952a41a 100644
--- a/src/commands.rs
+++ b/src/commands.rs
@@ -76,7 +76,23 @@ impl PlayQueue {
let allow_continue = queue.playing.clone().map_or(false, |x| !x.audio.lock().finished);
- if allow_continue || queue.queue.is_empty() {
+ if allow_continue {
+ sleep();
+ continue;
+ }
+
+ if queue.queue.is_empty() {
+ if queue.playing.is_some() { // must be finished
+ assert!({
+ let audio_lck = queue.playing.clone().unwrap().audio;
+ let audio = audio_lck.lock();
+ audio.finished
+ });
+
+ let mut manager = voice_manager.lock();
+ manager.leave(*TARGET_GUILD_ID);
+ }
+
sleep();
continue;
}
@@ -93,7 +109,6 @@ impl PlayQueue {
};
let mut manager = voice_manager.lock();
-
let handler = manager.join(*TARGET_GUILD_ID, must_env_lookup::<u64>("VOICE_CHANNEL"));
match handler {
@@ -269,6 +284,7 @@ command!(die(ctx, msg) {
if let Some(handler) = manager.get_mut(*TARGET_GUILD_ID) {
handler.stop();
+ handler.leave();
} else {
send(msg.channel_id, "YOU die", msg.tts)?;
debug!("got die with no handler attached");