diff options
Diffstat (limited to 'src/bot/music.rs')
| -rw-r--r-- | src/bot/music.rs | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/src/bot/music.rs b/src/bot/music.rs index fd1a7da..0bb5274 100644 --- a/src/bot/music.rs +++ b/src/bot/music.rs @@ -336,17 +336,11 @@ impl MusicBot { client: _, old_channel, } => { - let my_channel = self.my_channel(); - if old_channel == my_channel && self.user_count(my_channel) <= 1 { - self.quit(String::from("Channel is empty")); - } + self.on_client_left_channel(old_channel); } MusicBotMessage::ClientDisconnected { id: _, client } => { let old_channel = client.channel; - let my_channel = self.my_channel(); - if old_channel == my_channel && self.user_count(my_channel) <= 1 { - self.quit(String::from("Channel is empty")); - } + self.on_client_left_channel(old_channel); } MusicBotMessage::StateChange(state) => { self.on_state(state)?; @@ -357,6 +351,13 @@ impl MusicBot { Ok(()) } + fn on_client_left_channel(&self, old_channel: ChannelId) { + let my_channel = self.my_channel(); + if old_channel == my_channel && self.user_count(my_channel) <= 1 { + self.quit(String::from("Channel is empty")); + } + } + pub fn quit(&self, reason: String) { self.player.quit(reason); } |
