Leaving when noones in vc
This commit is contained in:
parent
0db5ae0797
commit
5cf662333e
@ -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))
|
Loading…
x
Reference in New Issue
Block a user