Set voice to none when not initiated by bot (i.e. disconnect from server admin)
authorjweigele <jweigele@local>
Sat, 19 Jun 2021 16:43:53 +0000 (09:43 -0700)
committerjweigele <jweigele@local>
Sat, 19 Jun 2021 16:43:53 +0000 (09:43 -0700)
grahbot.py

index 693251a3f3d74fa49eaac3ebe825803a3c4e3ddf..84e64bdf3f1f3a886ecf195a7917af809e34bbe8 100755 (executable)
@@ -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__':