@bot.event
async def on_voice_state_update(member, before, after):
voice = discord.utils.get(bot.voice_clients, guild=member.guild)
if voice and voice.is_connected():
if len(voice.channel.members) == 1:
await voice.disconnect()
async def on_voice_state_update(self, member: discord.Member, before: discord.VoiceState, after: discord.VoiceState):
if after.channel is None:
members = before.channel.members
if len(members) == 1:
if members[0].id == self.bot.user.id:
await before.channel.guild.voice_client.disconnect(force=False)