From 6153cd642162e67ccddf3e756b1009479c8cbf83 Mon Sep 17 00:00:00 2001 From: Torsten Date: Thu, 8 Sep 2016 16:01:42 +0200 Subject: [PATCH] Fix saying goodbye when user in diff. voice channel changes state --- src/main.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/main.rs b/src/main.rs index df878de..21daf17 100644 --- a/src/main.rs +++ b/src/main.rs @@ -171,14 +171,18 @@ fn main() { if let Some(channel_id) = voice_state.channel_id { if channel_id == voice_channel_id { if !voice_users.contains(&user_id) { + // User joined voice_users.insert(user_id); say_hello(&discord, &user_id, &status_channel_id, &mut connection, &server_id); } } else { - voice_users.remove(&user_id); + if voice_users.contains(&user_id) { + // User in observed voice channel left + voice_users.remove(&user_id); - say_goodbye(&discord, &user_id, &status_channel_id, &mut connection, &server_id); + say_goodbye(&discord, &user_id, &status_channel_id, &mut connection, &server_id); + } } } else { // Only say goodbye if the user was prev. known to us (that is he/she was in our observed voice channel)