From 239d8cabf20505b15c6d3270445212fe07be05be Mon Sep 17 00:00:00 2001 From: jweigele Date: Sat, 19 Jun 2021 09:43:53 -0700 Subject: [PATCH] Set voice to none when not initiated by bot (i.e. disconnect from server admin) --- grahbot.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/grahbot.py b/grahbot.py index 693251a..84e64bd 100755 --- a/grahbot.py +++ b/grahbot.py @@ -523,10 +523,13 @@ class GrahDiscordBot(discord.Client, HornClient, HornProm): await self.prom_voice_channel(before.channel, 0) if after.channel is not None: await self.prom_voice_channel(after.channel, 1) - if before.channel is not None and after.channel is not None and before.channel != after.channel: + if before.channel is not None and before.channel != after.channel: log.debug('Before != after and channels differ, setting the VC appropriately') - # try to get the already established VC and resave - self.state.set_voice(after.channel.guild, self.state.get_voice(after.channel.guild)) + if after.channel is None: + self.state.set_voice(before.channel.guild, None) + else: + # try to get the already established VC and resave + self.state.set_voice(before.channel.guild, self.state.get_voice(before.channel.guild)) if __name__ == '__main__': -- 2.30.2