diff --git a/commands/voice.py b/commands/voice.py index 872c272..a58d2f4 100644 --- a/commands/voice.py +++ b/commands/voice.py @@ -5,6 +5,8 @@ import os import threading import time +from main import client + SquogFinalName: str = None SquogPlaying = { @@ -107,5 +109,12 @@ class Voice(commands.Cog): ctx.guild.voice_client.stop() SquogPlaying[ctx.guild.id] = False + @client.event + async def on_voice_state_update(self, member: nextcord.Member, before: nextcord.VoiceState, after: nextcord.VoiceState): + if before.channel and not after.channel: + print(f'{member} left a vc.') + if before.channel.members.__len__() == 0 and member.guild.voice_client and member.guild.voice_client.channel == before.channel: + await before.channel.guild.voice_client.disconnect(force=True) + def setup(bot): bot.add_cog(Voice(bot)) \ No newline at end of file